Skip to content

Commit

Permalink
test(mempool): flow test with holes (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeletstarkware authored Jul 16, 2024
1 parent 60a248b commit 9b2069c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,30 @@ fn test_get_txs_with_holes_single_account() {
let mempool_state = MempoolState::new(pool_txs, queue_txs);
mempool_state.assert_eq_mempool_state(&mempool);
}

#[rstest]
fn test_flow_filling_holes(mut mempool: Mempool) {
// Setup.
let input_address_0_nonce_0 =
add_tx_input!(tx_hash: 1, sender_address: "0x0", tx_nonce: 0_u8, account_nonce: 0_u8);
let input_address_0_nonce_1 =
add_tx_input!(tx_hash: 2, sender_address: "0x0", tx_nonce: 1_u8, account_nonce: 0_u8);
let input_address_1_nonce_0 =
add_tx_input!(tx_hash: 3, sender_address: "0x1", tx_nonce: 0_u8, account_nonce: 0_u8);

// Test.
add_tx(&mut mempool, &input_address_0_nonce_1);
add_tx(&mut mempool, &input_address_1_nonce_0);
let txs = mempool.get_txs(2).unwrap();

// Assert: only the eligible transaction is returned.
assert_eq!(txs, &[input_address_1_nonce_0.tx]);

// Test.
add_tx(&mut mempool, &input_address_0_nonce_0);
let txs = mempool.get_txs(2).unwrap();

// TODO(Ayelet): all transactions should be returned after replenishing.
// Assert: all remaining transactions are returned.
assert_eq!(txs, &[input_address_0_nonce_0.tx]);
}

0 comments on commit 9b2069c

Please sign in to comment.