Skip to content

Commit

Permalink
Merge branch 'jason/NNS1-3059' into 'master'
Browse files Browse the repository at this point in the history
fix(sns): NNS1-3059 Stop returning payload_text_rendering within list_proposals

Large fields should not be returned in list_proposals, consistent with other large fields such as logos in ManageLedgerParameters/ManageSnsMetadata and byte payloads in UpgradeSnsControlledCansiter and ExecuteGenericNervousSystemFunction.

Closes NNS1-3059 

Closes NNS1-3059

See merge request dfinity-lab/public/ic!19164
  • Loading branch information
jasonz-dfinity committed May 8, 2024
2 parents 0b21f36 + 00a3b37 commit cd5224a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rs/sns/governance/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ impl ProposalData {
failure_reason,
reward_event_round,
wait_for_quiet_state,
payload_text_rendering,
payload_text_rendering: _,
is_eligible_for_rewards,
initial_voting_period_seconds,
wait_for_quiet_deadline_increase_seconds,
Expand Down Expand Up @@ -2128,7 +2128,6 @@ impl ProposalData {
failure_reason: failure_reason.clone(),
reward_event_round: *reward_event_round,
wait_for_quiet_state: wait_for_quiet_state.clone(),
payload_text_rendering: payload_text_rendering.clone(),
is_eligible_for_rewards: *is_eligible_for_rewards,
initial_voting_period_seconds: *initial_voting_period_seconds,
wait_for_quiet_deadline_increase_seconds: *wait_for_quiet_deadline_increase_seconds,
Expand All @@ -2138,6 +2137,7 @@ impl ProposalData {
action_auxiliary: action_auxiliary.clone(),

// The following fields are truncated:
payload_text_rendering: None,
proposal: proposal.as_ref().map(Proposal::limited_for_list_proposals),
ballots: limited_ballots,
}
Expand Down Expand Up @@ -4409,7 +4409,7 @@ Version {
}

#[test]
fn limited_proposal_data_for_list_proposals_truncate_ballots() {
fn limited_proposal_data_for_list_proposals_truncate_ballots_and_text_rendering() {
let ballots = (100..300)
.map(|i| {
(
Expand All @@ -4429,6 +4429,9 @@ Version {
..Default::default()
}),
ballots,
payload_text_rendering: Some(
"# Motion Proposal: ## Motion Text: some motion text".to_string(),
),
..Default::default()
};
let caller_neurons = (0..1000).map(|i| i.to_string()).collect::<HashSet<_>>();
Expand All @@ -4451,6 +4454,7 @@ Version {
limited_proposal_data,
ProposalData {
ballots: expected_ballots,
payload_text_rendering: None,
..original_proposal_data
}
);
Expand Down

0 comments on commit cd5224a

Please sign in to comment.