Skip to content

Commit

Permalink
test(mempool): test_add_tx_fills_nonce_gap
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed Jul 24, 2024
1 parent 10015be commit 8c5412f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,26 @@ fn test_tip_priority_over_tx_hash(mut mempool: Mempool) {
assert_eq_mempool_queue(&mempool, &[input_big_tip_small_hash.tx, input_small_tip_big_hash.tx])
}

#[rstest]
fn test_add_tx_fills_hole(mut mempool: Mempool) {
// Setup.
let tx_input_nonce_1 = add_tx_input!(tx_hash: 1, tx_nonce: 1_u8, account_nonce: 0_u8);
// Input that increments the account state.
let tx_input_nonce_2 = add_tx_input!(tx_hash: 2, tx_nonce: 2_u8, account_nonce: 1_u8);
let tx_input_nonce_3 = add_tx_input!(tx_hash: 3, tx_nonce: 3_u8, account_nonce: 0_u8);

// Test and assert.

// First, with gap.
add_tx(&mut mempool, &tx_input_nonce_1);
add_tx(&mut mempool, &tx_input_nonce_3);
assert_eq_mempool_queue(&mempool, &[]);

// Then, fill it.
add_tx(&mut mempool, &tx_input_nonce_2);
assert_eq_mempool_queue(&mempool, &[tx_input_nonce_1.tx]);
}

#[rstest]
fn test_get_txs_with_holes_multiple_accounts() {
// Setup.
Expand Down

0 comments on commit 8c5412f

Please sign in to comment.