Skip to content

Commit

Permalink
test(mempool): test_add_tx_fills_nonce_gap (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 authored Jul 24, 2024
1 parent a7accbd commit 88c9d2e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,25 @@ 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_account_state_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);

// Test and assert.

// First, with gap.
add_tx(&mut mempool, &tx_input_nonce_1);
// TODO(Mohammad): use Mempool partial state.
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 88c9d2e

Please sign in to comment.