Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(mempool): test_add_tx_fills_nonce_gap #511

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading