Skip to content

Commit

Permalink
Address PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aterga committed Jan 15, 2025
1 parent ea888d5 commit 48cef74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion rs/nns/governance/canister/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,20 @@ fn update_neuron(neuron: Neuron) -> Option<GovernanceError> {

#[cfg(feature = "test")]
#[update]
/// Internal method for calling update_neuron.
/// Adopt the (currently open) proposal with `proposal_id` in a testing environment.
///
/// This function simulates a 100% YES vote rate for a given proposal.
///
/// ### Applicability
///
/// Testing with the golden state often involves open proposals that had been created
/// before the state snapshot was taken. This function allows observing the effect that such
/// proposals would have.
///
/// When possible, it is recommended to avoid using this function, instead creating a powerful
/// neuron that gets proposals adopted in testing. Calling this function may result in a less
/// realistic scenario, e.g., it does not guaranteed that the tally and the ballots will remain
/// synchronized for `proposal_id`.
fn adopt_proposal(proposal_id: ProposalIdProto) -> Option<GovernanceError> {
debug_log("adopt_proposal");
governance_mut()
Expand Down
8 changes: 4 additions & 4 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,7 @@ impl Governance {

assert_eq!(proposal_data.status(), ProposalStatus::Open);

let Some(mut tally) = proposal_data.latest_tally else {
let Some(tally) = proposal_data.latest_tally.as_mut() else {
panic!("No tally specified for proposal {}", proposal_id.id);
};

Expand All @@ -2317,9 +2317,9 @@ impl Governance {
"Bug in test-only code"
);

proposal_data.latest_tally.replace(tally);

// Ensure that the proposal action will be processed ASAP.
// Ensure that the proposal action will be processed ASAP (this ensures that
// the precondition of `Governance.process_proposals()` holds in the post-state
// of this function).
self.closest_proposal_deadline_timestamp_seconds = now;

Ok(())
Expand Down

0 comments on commit 48cef74

Please sign in to comment.