diff --git a/rs/tests/src/rosetta_tests/lib.rs b/rs/tests/src/rosetta_tests/lib.rs index 209b6151002..50fc3344b76 100644 --- a/rs/tests/src/rosetta_tests/lib.rs +++ b/rs/tests/src/rosetta_tests/lib.rs @@ -624,7 +624,7 @@ pub fn create_custom_neuron( .to_vec(), controller: Some(pid), created_timestamp_seconds, - aging_since_timestamp_seconds: created_timestamp_seconds + 10, + aging_since_timestamp_seconds: u64::MAX, dissolve_state: Some(DissolveState::WhenDissolvedTimestampSeconds(0)), cached_neuron_stake_e8s: Tokens::new(10, 0).unwrap().get_e8s(), kyc_verified: true, @@ -673,7 +673,7 @@ pub fn create_neuron( .to_vec(), controller: Some(principal_id), created_timestamp_seconds, - aging_since_timestamp_seconds: created_timestamp_seconds + 10, + aging_since_timestamp_seconds: u64::MAX, dissolve_state: Some(DissolveState::WhenDissolvedTimestampSeconds(0)), cached_neuron_stake_e8s: Tokens::new(10, 0).unwrap().get_e8s(), kyc_verified: true, diff --git a/rs/tests/src/rosetta_tests/tests/neuron_dissolve.rs b/rs/tests/src/rosetta_tests/tests/neuron_dissolve.rs index 52e8c9f28c9..50b4df954c4 100644 --- a/rs/tests/src/rosetta_tests/tests/neuron_dissolve.rs +++ b/rs/tests/src/rosetta_tests/tests/neuron_dissolve.rs @@ -24,21 +24,23 @@ pub fn test(env: TestEnv) { let mut ledger_balances = HashMap::new(); // Create neurons. - let one_year_from_now = 60 * 60 * 24 * 365 - + std::time::SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs(); + let now = std::time::SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs(); + let one_year_from_now = 60 * 60 * 24 * 365 + now; let mut neurons = TestNeurons::new(2000, &mut ledger_balances); let neuron1 = neurons.create(|neuron| { - neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)) + neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)); + neuron.aging_since_timestamp_seconds = now; }); let neuron2 = neurons.create(|neuron| { - neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)) + neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)); + neuron.aging_since_timestamp_seconds = now; }); - let neuron3 = neurons.create(|neuron| neuron.dissolve_state = None); + let neuron3 = neurons.create(|_| {}); // Create Rosetta and ledger clients. let neurons = neurons.get_neurons(); diff --git a/rs/tests/src/rosetta_tests/tests/neuron_info.rs b/rs/tests/src/rosetta_tests/tests/neuron_info.rs index a053275452f..f9fdf974c4b 100644 --- a/rs/tests/src/rosetta_tests/tests/neuron_info.rs +++ b/rs/tests/src/rosetta_tests/tests/neuron_info.rs @@ -35,9 +35,14 @@ pub fn test(env: TestEnv) { // Create neurons. let mut neurons = TestNeurons::new(2000, &mut ledger_balances); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_secs(); let neuron1 = neurons.create(|neuron| { neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(2 * 365 * 24 * 60 * 60)); + neuron.aging_since_timestamp_seconds = now; neuron.maturity_e8s_equivalent = 345_000_000; neuron.kyc_verified = true; neuron.followees = HashMap::from([ @@ -65,6 +70,7 @@ pub fn test(env: TestEnv) { 3 * 365 * 24 * 60 * 60, ), ); + neuron.aging_since_timestamp_seconds = now; neuron.maturity_e8s_equivalent = 678_000_000; neuron.kyc_verified = true; neuron.followees = HashMap::from([ @@ -92,6 +98,7 @@ pub fn test(env: TestEnv) { 3 * 365 * 24 * 60 * 60, ), ); + neuron.aging_since_timestamp_seconds = now; neuron.maturity_e8s_equivalent = 679_000_000; neuron.kyc_verified = true; neuron.followees = HashMap::from([ diff --git a/rs/tests/src/rosetta_tests/tests/neuron_maturity.rs b/rs/tests/src/rosetta_tests/tests/neuron_maturity.rs index 289820d5d48..c9593ce0be8 100644 --- a/rs/tests/src/rosetta_tests/tests/neuron_maturity.rs +++ b/rs/tests/src/rosetta_tests/tests/neuron_maturity.rs @@ -34,7 +34,6 @@ pub fn test(env: TestEnv) { // Create neurons. let mut neurons = TestNeurons::new(2000, &mut ledger_balances); let neuron_setup = |neuron: &mut Neuron| { - neuron.dissolve_state = None; neuron.maturity_e8s_equivalent = 420_000_000; }; let neuron1 = neurons.create(neuron_setup); diff --git a/rs/tests/src/rosetta_tests/tests/neuron_spawn.rs b/rs/tests/src/rosetta_tests/tests/neuron_spawn.rs index 209aebe8c7e..9b2b351b0e1 100644 --- a/rs/tests/src/rosetta_tests/tests/neuron_spawn.rs +++ b/rs/tests/src/rosetta_tests/tests/neuron_spawn.rs @@ -28,15 +28,12 @@ pub fn test(env: TestEnv) { let mut neurons = TestNeurons::new(2000, &mut ledger_balances); let neuron1 = neurons.create(|neuron| { - neuron.dissolve_state = None; neuron.maturity_e8s_equivalent = 500_000_000; }); let neuron2 = neurons.create(|neuron| { - neuron.dissolve_state = None; neuron.maturity_e8s_equivalent = 4_000; }); let neuron3 = neurons.create(|neuron| { - neuron.dissolve_state = None; neuron.maturity_e8s_equivalent = 500_000_000; }); diff --git a/rs/tests/src/rosetta_tests/tests/neuron_voting.rs b/rs/tests/src/rosetta_tests/tests/neuron_voting.rs index fcb43f42954..95f8c903b8d 100644 --- a/rs/tests/src/rosetta_tests/tests/neuron_voting.rs +++ b/rs/tests/src/rosetta_tests/tests/neuron_voting.rs @@ -28,11 +28,11 @@ pub fn test(env: TestEnv) { let _logger = env.logger(); let mut ledger_balances = HashMap::new(); - let one_year_from_now = 60 * 60 * 24 * 365 - + std::time::SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs(); + let now = std::time::SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs(); + let one_year_from_now = 60 * 60 * 24 * 365 + now; //We need to know the identity of the agent before we create the neurons. //The controller of the neuron has to be the agent principal otherwise we cannot make proposals and vote on them. @@ -44,6 +44,7 @@ pub fn test(env: TestEnv) { let mut neurons = TestNeurons::new(2000, &mut ledger_balances); let neuron_setup = |neuron: &mut Neuron| { neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)); + neuron.aging_since_timestamp_seconds = now; neuron.maturity_e8s_equivalent = 420_000_000; neuron.controller = Some(agent_principal.into()); neuron.account = @@ -56,6 +57,7 @@ pub fn test(env: TestEnv) { //Setup for non proposal making entities let neuron_setup = |neuron: &mut Neuron| { neuron.dissolve_state = Some(DissolveState::DissolveDelaySeconds(one_year_from_now)); + neuron.aging_since_timestamp_seconds = now; neuron.maturity_e8s_equivalent = 420_000_000; }; let neuron2 = neurons.create(neuron_setup);