Skip to content

Commit

Permalink
[FAB-17307] InitRequired param check for ApproveForMyorg (#462)
Browse files Browse the repository at this point in the history
This patch adds a check mechanism for the `InitRequired` parameter
for the chaincode definition of the current sequence number to
`ApproveForMyOrg`.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
  • Loading branch information
satota2 authored and Jason Yellick committed Jan 8, 2020
1 parent 04c1f85 commit 69ecb07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/chaincode/lifecycle/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func (cp *ChaincodeParameters) Equal(ocp *ChaincodeParameters) error {
return errors.Errorf("Version '%s' != '%s'", cp.EndorsementInfo.Version, ocp.EndorsementInfo.Version)
case cp.EndorsementInfo.EndorsementPlugin != ocp.EndorsementInfo.EndorsementPlugin:
return errors.Errorf("EndorsementPlugin '%s' != '%s'", cp.EndorsementInfo.EndorsementPlugin, ocp.EndorsementInfo.EndorsementPlugin)
case cp.EndorsementInfo.InitRequired != ocp.EndorsementInfo.InitRequired:
return errors.Errorf("InitRequired '%t' != '%t'", cp.EndorsementInfo.InitRequired, ocp.EndorsementInfo.InitRequired)
case cp.ValidationInfo.ValidationPlugin != ocp.ValidationInfo.ValidationPlugin:
return errors.Errorf("ValidationPlugin '%s' != '%s'", cp.ValidationInfo.ValidationPlugin, ocp.ValidationInfo.ValidationPlugin)
case !bytes.Equal(cp.ValidationInfo.ValidationParameter, ocp.ValidationInfo.ValidationParameter):
Expand Down
10 changes: 10 additions & 0 deletions core/chaincode/lifecycle/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ var _ = Describe("ChaincodeParameters", func() {
})
})

Context("when the InitRequired differs from the current definition", func() {
BeforeEach(func() {
rhs.EndorsementInfo.InitRequired = true
})

It("returns an error", func() {
Expect(lhs.Equal(rhs)).To(MatchError("InitRequired 'false' != 'true'"))
})
})

Context("when the ValidationPlugin differs from the current definition", func() {
BeforeEach(func() {
rhs.ValidationInfo.ValidationPlugin = "different"
Expand Down

0 comments on commit 69ecb07

Please sign in to comment.