diff --git a/crates/node/src/shell/testing/node.rs b/crates/node/src/shell/testing/node.rs index 5b92d3184d..a6e67d3987 100644 --- a/crates/node/src/shell/testing/node.rs +++ b/crates/node/src/shell/testing/node.rs @@ -363,8 +363,6 @@ impl MockNode { } pub fn next_epoch(&mut self) -> Epoch { - let header_time = #[allow(clippy::disallowed_methods)] - DateTimeUtc::now(); { let mut locked = self.shell.lock().unwrap(); @@ -372,19 +370,22 @@ impl MockNode { locked.state.in_mem().get_last_block_height() + 1; locked.state.in_mem_mut().next_epoch_min_start_height = next_epoch_height; - locked.state.in_mem_mut().next_epoch_min_start_time = header_time; + locked.state.in_mem_mut().next_epoch_min_start_time = { + #[allow(clippy::disallowed_methods)] + DateTimeUtc::now() + }; + let next_epoch_min_start_height = + locked.state.in_mem().next_epoch_min_start_height; if let Some(LastBlock { height, .. }) = locked.state.in_mem_mut().last_block.as_mut() { - *height = next_epoch_height; + *height = next_epoch_min_start_height; } } - // Use the same timestamp as `next_epoch_min_start_time` to ensure a new - // epoch is started on this block - self.finalize_and_commit(Some(header_time)); + self.finalize_and_commit(); for _ in 0..EPOCH_SWITCH_BLOCKS_DELAY { - self.finalize_and_commit(None); + self.finalize_and_commit(); } self.shell .lock() @@ -458,7 +459,7 @@ impl MockNode { /// Simultaneously call the `FinalizeBlock` and /// `Commit` handlers. - pub fn finalize_and_commit(&self, header_time: Option) { + pub fn finalize_and_commit(&self) { let (proposer_address, votes) = self.prepare_request(); let mut locked = self.shell.lock().unwrap(); @@ -489,7 +490,7 @@ impl MockNode { header: BlockHeader { hash: Hash([0; 32]), #[allow(clippy::disallowed_methods)] - time: header_time.unwrap_or_else(DateTimeUtc::now), + time: DateTimeUtc::now(), next_validators_hash: Hash([0; 32]), }, block_hash: Hash([0; 32]), @@ -569,7 +570,7 @@ impl MockNode { /// Send a tx through Process Proposal and Finalize Block /// and register the results. pub fn submit_txs(&self, txs: Vec>) { - self.finalize_and_commit(None); + self.finalize_and_commit(); let (proposer_address, votes) = self.prepare_request(); #[allow(clippy::disallowed_methods)] diff --git a/crates/tests/src/integration/ledger_tests.rs b/crates/tests/src/integration/ledger_tests.rs index 9e0e0a6777..65c0862061 100644 --- a/crates/tests/src/integration/ledger_tests.rs +++ b/crates/tests/src/integration/ledger_tests.rs @@ -389,7 +389,7 @@ fn invalid_transactions() -> Result<()> { assert_matches!(captured.result, Ok(_)); assert!(captured.contains(TX_REJECTED)); - node.finalize_and_commit(None); + node.finalize_and_commit(); // There should be state now { let locked = node.shell.lock().unwrap(); @@ -1719,7 +1719,7 @@ fn enforce_fee_payment() -> Result<()> { } // Finalize the next block to execute the txs node.clear_results(); - node.finalize_and_commit(None); + node.finalize_and_commit(); { let results = node.results.lock().unwrap(); for result in results.iter() { @@ -2028,7 +2028,7 @@ fn scheduled_migration() -> Result<()> { } while node.block_height().0 != 4 { - node.finalize_and_commit(None) + node.finalize_and_commit() } // check that the key doesn't exist before the scheduled block let rt = tokio::runtime::Runtime::new().unwrap(); @@ -2045,7 +2045,7 @@ fn scheduled_migration() -> Result<()> { assert!(bytes.is_empty()); // check that the key now exists and has the expected value - node.finalize_and_commit(None); + node.finalize_and_commit(); let rt = tokio::runtime::Runtime::new().unwrap(); let bytes = rt .block_on(RPC.shell().storage_value( diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 19d092dbb3..e2f6d66848 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -1527,7 +1527,7 @@ fn multiple_unfetched_txs_same_block() -> Result<()> { } // Finalize the next block to actually execute the decrypted txs node.clear_results(); - node.finalize_and_commit(None); + node.finalize_and_commit(); { let results = node.results.lock().unwrap(); for result in results.iter() {