Skip to content

Commit

Permalink
test(mempool): add commit block test different leader scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed Jul 22, 2024
1 parent c9f77e7 commit 530c747
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,36 @@ 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_another_leader_with_unknown_transactions() {
let tx_address0_nonce3 = add_tx_input!(tip: 1, tx_hash: 1, sender_address: "0x0", tx_nonce: 3_u8, account_nonce: 2_u8).tx;
let tx_address0_nonce5 = add_tx_input!(tip: 1, tx_hash: 2, sender_address: "0x0", tx_nonce: 5_u8, account_nonce: 2_u8).tx;
let tx_address0_nonce6 = add_tx_input!(tip: 1, tx_hash: 3, sender_address: "0x0", tx_nonce: 6_u8, account_nonce: 2_u8).tx;
let tx_address1_nonce2 = add_tx_input!(tip: 1, tx_hash: 4, sender_address: "0x1", tx_nonce: 2_u8, account_nonce: 1_u8).tx;

let queued_txs = vec![tx_address1_nonce2.clone()];
let pool_txs = vec![
tx_address0_nonce3,
tx_address0_nonce5,
tx_address0_nonce6.clone(),
tx_address1_nonce2,
];

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 commit_state = HashMap::from([
(contract_address!("0x0"), AccountState { nonce: Nonce(felt!(5_u16)) }),
// A hole, missing nonce 1.
(contract_address!("0x1"), AccountState { nonce: Nonce(felt!(0_u16)) }),
(contract_address!("0x2"), AccountState { nonce: Nonce(felt!(1_u16)) }),
]);
assert!(mempool.commit_block(commit_state).is_ok());

// Check that in the transaction queue there is a single transaction, tx 4, of address "0x0".
assert_eq_mempool_queue(&mempool, &[tx_address0_nonce6])
}

0 comments on commit 530c747

Please sign in to comment.