Skip to content

Commit

Permalink
test(mempool): add commit block test invalid argument
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed Jul 24, 2024
1 parent 93de0bd commit 32dfad7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ fn test_flow_filling_holes(mut mempool: Mempool) {

#[rstest]
#[ignore]

fn test_commit_block_rewinds_nonce() {
// Setup.
let tx_address0_nonce5 = add_tx_input!(tip: 1, tx_hash: 2, sender_address: "0x0", tx_nonce: 5_u8, account_nonce: 4_u8).tx;
Expand All @@ -443,3 +442,30 @@ fn test_commit_block_rewinds_nonce() {
// Assert.
assert_eq_mempool_queue(&mempool, &[])
}

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

let queue_txs = [TransactionReference::new(&tx_address0_nonce4)];
let pool_txs = [tx_address0_nonce4, tx_address1_nonce3.clone()];
let mut mempool: Mempool = MempoolState::new(pool_txs, queue_txs).into();

// Test.
let commit_state = HashMap::from([
(contract_address!("0x0"), AccountState { nonce: Nonce(felt!(4_u16)) }),
(contract_address!("0x1"), AccountState { nonce: Nonce(felt!(2_u16)) }),
]);
assert!(mempool.commit_block(commit_state).is_ok());
assert_eq_mempool_queue(&mempool, &[tx_address1_nonce3.clone()]);

let invalid_commit_state =
HashMap::from([(contract_address!("0x0"), AccountState { nonce: Nonce(felt!(3_u16)) })]);

// Assert.
assert!(mempool.commit_block(invalid_commit_state).is_ok());
assert_eq_mempool_queue(&mempool, &[tx_address1_nonce3]);
}

0 comments on commit 32dfad7

Please sign in to comment.