From dfd0570b90473518962701629278994013b8ec5c Mon Sep 17 00:00:00 2001 From: Daniel Wong Date: Wed, 30 Oct 2024 12:09:58 +0100 Subject: [PATCH] Test that following causes voting power to refresh. --- rs/nns/governance/tests/governance.rs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/rs/nns/governance/tests/governance.rs b/rs/nns/governance/tests/governance.rs index 7593f1234142..dc3acff7ba67 100644 --- a/rs/nns/governance/tests/governance.rs +++ b/rs/nns/governance/tests/governance.rs @@ -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. @@ -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),