add consenter sig verifier tests#994
Open
HagarMeir wants to merge 1 commit into
Open
Conversation
Signed-off-by: Hagar Meir <hagar.meir@ibm.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds unit tests around consenter block signature verification by introducing a mockable policy interface and exercising BlockSigVerifier.Verify behavior for malformed signature inputs and policy evaluation outcomes.
Changes:
- Add
//go:generatedirective to generate a counterfeiter mock for the internalpolicyinterface. - Add extensive
BlockSigVerifier.Verifytests using a mocked policy to cover malformed signatures and policy error propagation. - Add the generated
mocks/policy.gofake implementation.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| node/consensus/synchronizer/sig_verifier.go | Adds counterfeiter generation directive for the policy interface to enable mocking in tests. |
| node/consensus/synchronizer/sig_verifier_test.go | Adds mocked-policy tests covering invalid signature encodings/contents and policy success/failure behavior. |
| node/consensus/synchronizer/mocks/policy.go | Adds generated counterfeiter fake for the policy interface used by the new tests. |
Files not reviewed (1)
- node/consensus/synchronizer/mocks/policy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } | ||
|
|
||
| func TestBlockSigVerifier_VerifyWithMockedPolicy_ErrorCases(t *testing.T) { |
Comment on lines
+517
to
+522
| // Create a message with wrong block header | ||
| msgToSign := &protoutil.MessageToSign{ | ||
| IdentifierHeader: idHeaderBytes, | ||
| BlockHeader: []byte{99, 99, 99}, // Wrong block header | ||
| OrdererBlockMetadata: []byte{7, 8, 9}, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.