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): add commit block test different leader scenario #490

Conversation

MohammadNassar1
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 commented Jul 16, 2024

This change is Reviewable

@MohammadNassar1 MohammadNassar1 requested a review from elintul July 16, 2024 14:19
@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.21%. Comparing base (93de0bd) to head (1e0044a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #490   +/-   ##
=======================================
  Coverage   81.21%   81.21%           
=======================================
  Files          42       42           
  Lines        1826     1826           
  Branches     1826     1826           
=======================================
  Hits         1483     1483           
  Misses        269      269           
  Partials       74       74           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block-test/different_leader_scenario branch 2 times, most recently from 530c747 to dd8816d Compare July 22, 2024 11:21
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)


crates/mempool/src/mempool_test.rs line 448 at r2 (raw file):

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

Suggestion:

#[rstest]
#[ignore]
fn test_commit_block_from_different_leader() {
    // Setup.
    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 = [TransactionReference::new(&tx_address1_nonce2)];
    let pool_txs =
        [tx_address0_nonce3, tx_address0_nonce5, tx_address0_nonce6.clone(), tx_address1_nonce2];
    let mut mempool: Mempool = MempoolState::new(pool_txs, queued_txs).into();

    // Test.
    let state_changes = 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());

    // Assert.
    assert_eq_mempool_queue(&mempool, &[tx_address0_nonce6])
}

@MohammadNassar1 MohammadNassar1 force-pushed the mohammad/commit-block-test/different_leader_scenario branch from dd8816d to 1e0044a Compare July 24, 2024 08:08
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MohammadNassar1)

@elintul elintul closed this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants