Skip to content

Commit 90119df

Browse files
committed
Replace Transaction with its hash in hashmap.
`Transaction` is a mutable key type.
1 parent 81fcdab commit 90119df

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/src/tests/timeboost/transaction_order.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::iter::once;
33
use std::num::NonZeroUsize;
44
use std::time::Duration;
55

6+
use alloy::primitives::B256;
67
use metrics::NoMetrics;
78
use sailfish_types::RoundNumber;
89
use timeboost_sequencer::{Output, Sequencer};
9-
use timeboost_types::Transaction;
1010
use timeboost_utils::types::logging::init_logging;
1111
use tokio::select;
1212
use tokio::sync::broadcast::error::RecvError;
@@ -64,6 +64,7 @@ async fn transaction_order() {
6464
let Output::Transactions { round, transactions, .. } = out.unwrap() else {
6565
continue
6666
};
67+
let transactions = transactions.into_iter().map(|t| *t.hash()).collect();
6768
tx.send((round, transactions)).unwrap()
6869
}
6970
_ = finish.cancelled() => {
@@ -82,7 +83,7 @@ async fn transaction_order() {
8283

8384
tasks.spawn(gen_bundles(enc_keys[0].clone(), bcast.clone()));
8485

85-
let mut map: HashMap<(RoundNumber, Vec<Transaction>), usize> = HashMap::new();
86+
let mut map: HashMap<(RoundNumber, Vec<B256>), usize> = HashMap::new();
8687
let mut transactions = 0;
8788

8889
while transactions < NUM_OF_TRANSACTIONS {
@@ -97,12 +98,10 @@ async fn transaction_order() {
9798
transactions += trxs;
9899
continue;
99100
}
100-
for ((round, trxs), k) in map {
101+
for ((r, trxs), k) in map {
101102
eprintln!(
102-
"{round}: {:?} = {k}",
103-
trxs.into_iter()
104-
.map(|t| t.hash().to_string())
105-
.collect::<Vec<_>>()
103+
"{r}: {:?} = {k}",
104+
trxs.into_iter().map(|t| t.to_string()).collect::<Vec<_>>()
106105
)
107106
}
108107
panic!("outputs do not match")

0 commit comments

Comments
 (0)