Skip to content

add consenter sig verifier tests#994

Open
HagarMeir wants to merge 1 commit into
hyperledger:mainfrom
HagarMeir:sig-verifier-tests
Open

add consenter sig verifier tests#994
HagarMeir wants to merge 1 commit into
hyperledger:mainfrom
HagarMeir:sig-verifier-tests

Conversation

@HagarMeir

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Hagar Meir <hagar.meir@ibm.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:generate directive to generate a counterfeiter mock for the internal policy interface.
  • Add extensive BlockSigVerifier.Verify tests using a mocked policy to cover malformed signatures and policy error propagation.
  • Add the generated mocks/policy.go fake 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},
}
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.

2 participants