Skip to content

Commit

Permalink
feat: improve mempool_test debug print
Browse files Browse the repository at this point in the history
Previous assertion wasn't informative enough on fail.

commit-id:4b2c49c7
  • Loading branch information
Gilad Chase committed Jul 10, 2024
1 parent 53de2b0 commit 7ace004
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use assert_matches::assert_matches;
use itertools::zip_eq;
use itertools::{enumerate, zip_eq};
use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use starknet_api::core::{ContractAddress, Nonce, PatriciaKey};
Expand Down Expand Up @@ -81,11 +81,9 @@ fn assert_eq_mempool_queue(mempool: &Mempool, expected_queue: &[ThinTransaction]
let mempool_txs = mempool.iter();
let expected_queue = expected_queue.iter().map(TransactionReference::new);

assert!(
zip_eq(expected_queue, mempool_txs)
// Deref the inner mempool tx type.
.all(|(expected_tx, mempool_tx)| expected_tx == *mempool_tx)
);
for (i, (expected_tx, mempool_tx)) in enumerate(zip_eq(expected_queue, mempool_txs)) {
assert_eq!(expected_tx, *mempool_tx, "Transaction {i} in the queue is not as expected");
}
}

#[rstest]
Expand Down

0 comments on commit 7ace004

Please sign in to comment.