From a884d2379fb81a30b887d209e326a6252824d6bf Mon Sep 17 00:00:00 2001 From: Mirko von Leipzig Date: Tue, 22 Oct 2024 15:47:00 +0200 Subject: [PATCH] Fix test --- crates/block-producer/src/domain/transaction.rs | 6 ++++++ crates/block-producer/src/mempool/inflight_state/mod.rs | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/block-producer/src/domain/transaction.rs b/crates/block-producer/src/domain/transaction.rs index 5987f4c3..756af859 100644 --- a/crates/block-producer/src/domain/transaction.rs +++ b/crates/block-producer/src/domain/transaction.rs @@ -131,6 +131,12 @@ impl AuthenticatedTransaction { } } + /// Overrides the authentication height with the given value. + pub fn with_authentication_height(mut self, height: u32) -> Self { + self.authentication_height = BlockNumber::new(height); + self + } + /// Overrides the store state with the given value. pub fn with_store_state(mut self, state: Digest) -> Self { self.store_account_state = Some(state); diff --git a/crates/block-producer/src/mempool/inflight_state/mod.rs b/crates/block-producer/src/mempool/inflight_state/mod.rs index 05f30a3c..673a924f 100644 --- a/crates/block-producer/src/mempool/inflight_state/mod.rs +++ b/crates/block-producer/src/mempool/inflight_state/mod.rs @@ -638,9 +638,11 @@ mod tests { } committed.commit_block(&txs[..i]); - let mut inserted = InflightState::new(BlockNumber::default(), 0); + let mut inserted = InflightState::new(BlockNumber::new(1), 0); for (idx, tx) in txs.iter().skip(i).enumerate() { - inserted.add_transaction(tx).unwrap_or_else(|err| { + // We need to adjust the height since we are effectively at block "1" now. + let tx = tx.clone().with_authentication_height(1); + inserted.add_transaction(&tx).unwrap_or_else(|err| { panic!("Inserting tx #{idx} in iteration {i} should succeed: {err}") }); }