Skip to content

Commit

Permalink
Test that following causes voting power to refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-wong-dfinity-org committed Oct 30, 2024
1 parent 8f2e696 commit dfd0570
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions rs/nns/governance/tests/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,18 @@ async fn test_all_follow_proposer() {
driver.get_fake_ledger(),
driver.get_fake_cmc(),
);

// Later, we'll inspect the same field again to verify that voting power
// refresh actually took place. This is just to make sure that the later
// value is different from this earlier one.
assert_eq!(
gov.with_neuron(&NeuronId { id: 5 }, |neuron| {
neuron.voting_power_refreshed_timestamp_seconds()
})
.unwrap(),
DEFAULT_VOTING_POWER_REFRESHED_TIMESTAMP_SECONDS,
);

// Add following for 5 and 6 for 1.
gov.manage_neuron(
// Must match neuron 5's serialized_id.
Expand All @@ -1754,6 +1766,22 @@ async fn test_all_follow_proposer() {
.unwrap()
.panic_if_error("Manage neuron failed");

// Assert that neuron 5's voting power was refreshed. More concretely,
// verifying that neuron 5's voting_power_refreshed_timestamp_seconds
// changed from before. (Earlier, we saw that this field had a different
// value, to wit, DEFAULT_VOTING_POWER_REFRESHED_TIMESTAMP_SECONDS)
assert_ne!(
DEFAULT_TEST_START_TIMESTAMP_SECONDS,
DEFAULT_VOTING_POWER_REFRESHED_TIMESTAMP_SECONDS,
);
assert_eq!(
gov.with_neuron(&NeuronId { id: 5 }, |neuron| {
neuron.voting_power_refreshed_timestamp_seconds()
})
.unwrap(),
DEFAULT_TEST_START_TIMESTAMP_SECONDS,
);

gov.manage_neuron(
// Must match neuron 6's serialized_id.
&principal(6),
Expand Down

0 comments on commit dfd0570

Please sign in to comment.