From c3cb8a51ec7418cd12e79ff4d549f64a4b32a9ca Mon Sep 17 00:00:00 2001 From: Mohammad Nassar Date: Mon, 22 Jul 2024 08:24:10 +0300 Subject: [PATCH] test(mempool): test_add_tx_fills_nonce_gap --- crates/mempool/src/mempool_test.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index 8ee7256f8..398b8450a 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -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.