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): refactor test_add_tx_with_duplicate_tx to use mempool … #444

Conversation

ayeletstarkware
Copy link
Contributor

@ayeletstarkware ayeletstarkware commented Jul 11, 2024

…state


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.21%. Comparing base (f1d94c0) to head (4dca6f6).

Additional details and impacted files
@@                          Coverage Diff                           @@
##           ayelet/mempool/mempool-state/refactor     #444   +/-   ##
======================================================================
  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.

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.

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


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

    // Assert that the original tx remains in Mempool after the failed attempt.
    let queue_txs = [TransactionReference::new(&input.tx)];

I don't think asserting the queue is relevant for this test.

If the duplicate tx isn't in the pool then we can assume it's not queued, and whether or not the non-dup tx is in the queue shouldn't matter for a dup-check test.

There should be an easy way of only checking the pool.

Code quote:

    let queue_txs = [TransactionReference::new(&input.tx)];

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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @elintul, @giladchase, and @MohammadNassar1)


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

Previously, giladchase wrote…

I don't think asserting the queue is relevant for this test.

If the duplicate tx isn't in the pool then we can assume it's not queued, and whether or not the non-dup tx is in the queue shouldn't matter for a dup-check test.

There should be an easy way of only checking the pool.

I see your point, and it's easy to implement, but what is the issue with checking the entire mempool state?

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state-compare-func branch from ba6056d to 7479fd6 Compare July 14, 2024 08:23
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from 7a0222a to 9c52d72 Compare July 14, 2024 09:28
@ayeletstarkware ayeletstarkware changed the base branch from ayelet/mempool/mempool-state-compare-func to main July 15, 2024 06:58
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch 2 times, most recently from 2845247 to f33ec6d Compare July 15, 2024 07:19
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.

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


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

Previously, ayeletstarkware (Ayelet Zilber) wrote…

I see your point, and it's easy to implement, but what is the issue with checking the entire mempool state?

Why use a complicated assertion when a simple one suffices?

A more complicated solution to a simple problem can confuse readers, who might think that indeed there is a case in which tx is not in the pool but is in the queue, otherwise, why check both?

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.

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


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

Previously, giladchase wrote…

Why use a complicated assertion when a simple one suffices?

A more complicated solution to a simple problem can confuse readers, who might think that indeed there is a case in which tx is not in the pool but is in the queue, otherwise, why check both?

There is also consistency to consider.
If you do it for a test that doesn't need it, the principle of consistency will encourage future test writers to also assert this.
This might end up costing us with doesn't of extra assertions in our test files that are essentially tautologies.

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from f33ec6d to 3bfec92 Compare July 15, 2024 15:22
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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @elintul, @giladchase, and @MohammadNassar1)


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

Previously, giladchase wrote…

There is also consistency to consider.
If you do it for a test that doesn't need it, the principle of consistency will encourage future test writers to also assert this.
This might end up costing us with doesn't of extra assertions in our test files that are essentially tautologies.

Done.

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

a discussion (no related file):
Please impl. all my comments from other test( PR)s here.


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.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)

a discussion (no related file):
Can you please go over all tests that use MempoolState and check that they are tight? I.e., do not check already covered cases.


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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @elintul and @MohammadNassar1)

a discussion (no related file):

Previously, elintul (Elin) wrote…

Can you please go over all tests that use MempoolState and check that they are tight? I.e., do not check already covered cases.

I wrote myself to do as a next task.


@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from 3bfec92 to 47a7c76 Compare July 18, 2024 12:03
@ayeletstarkware ayeletstarkware changed the base branch from main to ayelet/mempool/mempool_state/test-tip-priority-over-tx-hash July 18, 2024 12:04
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from 47a7c76 to c0cfaa7 Compare July 18, 2024 12:14
@ayeletstarkware ayeletstarkware changed the base branch from ayelet/mempool/mempool_state/test-tip-priority-over-tx-hash to ayelet/mempool/mempool-state/refactor July 18, 2024 12:15
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.

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

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


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

#[rstest]
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
    // Setup

Suggestion:

// Setup.

crates/mempool/src/mempool_test.rs line 305 at r4 (raw file):

    let duplicate_input = input.clone();

    // Test: assert that the duplicate tx is not added to the mempool.

Code is clear enough.

Suggestion:

// Test.

crates/mempool/src/mempool_test.rs line 312 at r4 (raw file):

    );

    // Assert: the original tx remains in Mempool after the failed attempt.

Suggestion:

// Assert: the original tx remains.

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state/refactor branch from 6b70786 to f5a081b Compare July 24, 2024 08:17
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from c0cfaa7 to e453351 Compare July 24, 2024 08:22
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 r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware)


crates/mempool/src/mempool_test.rs line 314 at r5 (raw file):

    );

    // Assert: the original tx remains.

No abbreviations in documentation.

Suggestion:

transaction

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from e453351 to bf25b6c Compare July 24, 2024 10:50
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 r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool-state/refactor branch 2 times, most recently from 4050a0a to f1d94c0 Compare July 25, 2024 07:00
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mempool_state/test-add-tx-with-duplicate-tx branch from bf25b6c to 4dca6f6 Compare July 25, 2024 09:09
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 r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)

@ayeletstarkware ayeletstarkware merged commit a19df01 into ayelet/mempool/mempool-state/refactor Jul 25, 2024
8 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