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 function to assert equality and implement Eq,Parti… #431

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

ayeletstarkware
Copy link
Contributor

@ayeletstarkware ayeletstarkware commented Jul 10, 2024

…alEq for related structs


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@724ac68). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #431   +/-   ##
=======================================
  Coverage        ?   83.40%           
=======================================
  Files           ?       37           
  Lines           ?     1723           
  Branches        ?     1723           
=======================================
  Hits            ?     1437           
  Misses          ?      209           
  Partials        ?       77           

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

Copy link
Collaborator

@giladchase giladchase 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 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @elintul and @MohammadNassar1)

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 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)


crates/mempool/src/mempool_test.rs line 144 at r1 (raw file):

    let txs = mempool.get_txs(requested_txs).unwrap();

    // This ensures we do not exceed the number of transactions available in the mempool.

Suggestion:

// Ensure

crates/mempool/src/mempool_test.rs line 147 at r1 (raw file):

    let max_requested_txs = requested_txs.min(n_txs);

    // checks that the returned transactions are the ones with the highest priority.

x2

Suggestion:

// Check

crates/mempool/src/mempool_test.rs line 152 at r1 (raw file):

    // checks that the transactions that were not returned are still in the mempool.
    MempoolState::new(remaining_txs.to_vec(), remaining_txs.to_vec()).verify_equality(&mempool);

Define a mempool_state variable, so this line is easier to read.

Code quote:

MempoolState::new(remaining_txs.to_vec(), remaining_txs.to_vec())

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-new-struct branch 2 times, most recently from c8548e1 to 371fdd0 Compare July 10, 2024 12:26
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-new-struct branch from 371fdd0 to 1a21314 Compare July 11, 2024 07:55
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-compare-func branch from 04edec5 to ba6056d Compare July 11, 2024 08:01
Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

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

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 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)


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

    // Check that the transactions that were not returned are still in the mempool.
    let remaining_ref_txs = remaining_txs.iter().map(TransactionReference::new);

Suggestion:

remaining_tx_references

crates/mempool/src/transaction_queue.rs line 10 at r2 (raw file):

// Note: PartialEq and Eq for TransactionQueue are derived, ensuring that
// equality checks take into account the sorted nature of the BTreeSet.

Suggesting a behavioral description, with lower chances of getting old.

Suggestion:

// Note: the derived comparison functionality considers the order guaranteed by the data structures used.

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-new-struct branch from 1a21314 to 6b7b20a Compare July 11, 2024 14:33
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-compare-func branch from ba6056d to 7479fd6 Compare July 14, 2024 08:23
@ayeletstarkware ayeletstarkware changed the base branch from ayelet/mempool/mempool-state-new-struct to main July 14, 2024 08:23
Copy link
Contributor Author

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @elintul, @giladchase, and @MohammadNassar1)


crates/mempool/src/mempool_test.rs line 148 at r3 (raw file):

#[case::test_get_less_than_all_eligible_txs(2)]
fn test_get_txs(#[case] requested_txs: usize) {
    let tx1 = add_tx_input!(tip: 50, tx_hash: 1).tx;

renaming here #463

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 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 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @elintul and @giladchase)

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @elintul and @giladchase)

@ayeletstarkware ayeletstarkware merged commit 9852d18 into main Jul 15, 2024
7 checks passed
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.

5 participants