-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add unit tests for zksync_consensus_bft
(BFT-360)
#39
Conversation
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.
The direction looks good. I would just ask you to eventually move the utils to the testonly folder.
2f2eff6
to
14be873
Compare
14be873
to
01b9c5d
Compare
The
The first is protected against during top-level processing, but I couldn't find safeguards for the latter. |
Regarding the first test, we indeed do check the protocol version earlier. But its placement is not ideal, it's separate from all the other checks. And it only produces a tracing warning, it never produces an error that we can actually test. So I would move that check to later in the flow, so that we do all the checks for the message in the same place. |
Another point is if failing to create a QC should panic. Technically we could have that method just return an error, but I'm not sure how we could recover from it. By that time, the only thing we could do is discard all the replica prepare messages we got and let our turn timeout. Which I guess is better than panicking but it would still let an attacker stop the chain anyway. |
Does the current implementation support liveness in the event of a leader's timeout? |
3e47bff
to
ecdea8b
Compare
Since all shared util code is now located in |
zksync_consensus_bft
(BFT-360)zksync_consensus_bft
(BFT-360)
Yes, and we should write tests for that.
+1, tests should be as close to the code under test as possible. |
.unwrap() | ||
} | ||
|
||
pub(crate) async fn recv_signed(&mut self) -> Option<Signed<ConsensusMsg>> { |
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.
This method seems to always return Some
; could it be simplified to return Signed<_>
instead of an Option
?
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.
Yes, originally it had None
which turned out to be unnecessary, but the method signature remained.
I changed it now to return Result
which will propagate the error type from self.pipe.recv
instead of just unwrapping it: aa85e36
ca78013
to
9cd6e59
Compare
# Conflicts: # node/actors/bft/src/leader/tests.rs # node/actors/bft/src/replica/tests.rs
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.
Looks good. There's only one change that needs to be committed. Approved!
Adding new unit tests coverage for
zksync_consensus_bft
crate.Notes
leader
/replica
mods level.testonly::ut_harness::UTHarness
struct was added to encapsulate all testing operations, and moreover to minimize redundancy of test code.Coverage
replica prepare
leader prepare
replica commit
leader commit