-
Notifications
You must be signed in to change notification settings - Fork 11
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(gateway): make sure we are using the latest block in the stateful validator #401
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #401 +/- ##
=======================================
Coverage 82.60% 82.61%
=======================================
Files 39 39
Lines 1788 1789 +1
Branches 1788 1789 +1
=======================================
+ Hits 1477 1478 +1
Misses 237 237
Partials 74 74 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 7 files at r1, all commit messages.
Reviewable status: 3 of 7 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @yair-starkware)
crates/gateway/src/state_reader.rs
line 16 at r1 (raw file):
} #[automock]
What does it mean?
Is there an alternative to incorporating testing code into production code?
Code quote:
#[automock]
2369072
to
5e4d0ce
Compare
Previously, elintul (Elin) wrote…
It is a tool to create mocks of traits. Please note that this PR is on top of #369 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 7 files at r1, 2 of 5 files at r3, 3 of 4 files at r4, all commit messages.
Reviewable status: 6 of 7 files reviewed, 3 unresolved discussions (waiting on @elintul and @yair-starkware)
crates/gateway/src/stateful_transaction_validator_test.rs
line 81 at r4 (raw file):
// Using Arc and cloning because mock requires moving the state_reader_factory, but we need it // twice. let state_reader_factory =
IIUC we need this factory only to create a state_reader to be returned from the mock factory.
Can we just create a TestStateReader directly here? somthing like:
let test_state_reader = Box::new(...);
mock_state_reader_factory
.expect_get_state_reader_from_latest_block()
.returning(move || test_state_reader);
crates/gateway/src/stateful_transaction_validator_test.rs
line 97 at r4 (raw file):
assert_eq!(block_number, state_reader_factory.state_reader.block_info.block_number); state_reader_factory.get_state_reader(block_number) });
Suggestion:
mock_state_reader_factory.expect_get_state_reader().with(eq(block_number)).returning(move |block_number| {
state_reader_factory.get_state_reader(block_number)
});
1886f59
to
22c53aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 7 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @elintul)
crates/gateway/src/stateful_transaction_validator_test.rs
line 81 at r4 (raw file):
Previously, dafnamatsry wrote…
IIUC we need this factory only to create a state_reader to be returned from the mock factory.
Can we just create a TestStateReader directly here? somthing like:let test_state_reader = Box::new(...); mock_state_reader_factory .expect_get_state_reader_from_latest_block() .returning(move || test_state_reader);
Done.
crates/gateway/src/stateful_transaction_validator_test.rs
line 97 at r4 (raw file):
assert_eq!(block_number, state_reader_factory.state_reader.block_info.block_number); state_reader_factory.get_state_reader(block_number) });
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @elintul)
There was a problem hiding this 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 @yair-starkware)
crates/gateway/src/state_reader.rs
line 16 at r1 (raw file):
Previously, yair-starkware (Yair) wrote…
It is a tool to create mocks of traits.
Changed the code so it is behind 'test' feature.Please note that this PR is on top of #369
Please add Gilad as a reviewer, would like his opinion here.
There was a problem hiding this 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)
crates/gateway/src/state_reader.rs
line 16 at r1 (raw file):
Previously, elintul (Elin) wrote…
Please add Gilad as a reviewer, would like his opinion here.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 5 files at r3, 1 of 4 files at r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @giladchase)
22c53aa
to
1efb99d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @giladchase)
This change is