Skip to content

Commit

Permalink
test(mempool): add tests for commit block method
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed Jul 24, 2024
1 parent c9f77e7 commit 61f0980
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,29 @@ fn test_flow_filling_holes(mut mempool: Mempool) {
// Assert: all remaining transactions are returned.
assert_eq!(txs, &[input_address_0_nonce_0.tx]);
}

#[rstest]
#[ignore]
fn test_commit_block_includes_all_transactions() {
// Setup.
let tx_address0_nonce4 = add_tx_input!(tip: 4, tx_hash: 1, sender_address: "0x0", tx_nonce: 4_u8, account_nonce: 4_u8).tx;
let tx_address0_nonce5 = add_tx_input!(tip: 3, tx_hash: 2, sender_address: "0x0", tx_nonce: 5_u8, account_nonce: 4_u8).tx;
let tx_address1_nonce3 = add_tx_input!(tip: 2, tx_hash: 3, sender_address: "0x1", tx_nonce: 3_u8, account_nonce: 3_u8).tx;
let tx_address2_nonce1 = add_tx_input!(tip: 1, tx_hash: 4, sender_address: "0x2", tx_nonce: 1_u8, account_nonce: 1_u8).tx;

let queued_txs =
vec![tx_address0_nonce4.clone(), tx_address1_nonce3.clone(), tx_address2_nonce1.clone()];
let pool_txs =
vec![tx_address0_nonce4, tx_address0_nonce5, tx_address1_nonce3, tx_address2_nonce1];
let tx_references_iterator = queued_txs.iter().map(TransactionReference::new);
let txs_iterator = pool_txs.iter().cloned();
let mut mempool: Mempool = MempoolState::new(txs_iterator, tx_references_iterator).into();

let state_changes = HashMap::from([
(contract_address!("0x0"), AccountState { nonce: Nonce(felt!(3_u16)) }),
(contract_address!("0x1"), AccountState { nonce: Nonce(felt!(2_u16)) }),
]);
assert!(mempool.commit_block(state_changes).is_ok());

assert_eq_mempool_queue(&mempool, &queued_txs)
}

0 comments on commit 61f0980

Please sign in to comment.