Skip to content

Commit

Permalink
Improve error message when private data is disabled
Browse files Browse the repository at this point in the history
FAB-11712 #done

Change-Id: I0d69f7ff05033d2d2cbb2642725a48ba2c86f328
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Aug 26, 2018
1 parent 8df0555 commit 546360b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions core/scc/lscc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ type CollectionsConfigUpgradesNotAllowed string
func (f CollectionsConfigUpgradesNotAllowed) Error() string {
return "as V1_2 capability is not enabled, collection upgrades are not allowed"
}

// PrivateChannelDataNotAvailable when V1_2 or later capability is not enabled
type PrivateChannelDataNotAvailable string

func (f PrivateChannelDataNotAvailable) Error() string {
return "as V1_2 or later capability is not enabled, private channel collections and data are not available"
}
6 changes: 4 additions & 2 deletions core/scc/lscc/lscc.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,10 @@ func (lscc *LifeCycleSysCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response
}

// the maximum number of arguments depends on the capability of the channel
if (!ac.Capabilities().PrivateChannelData() && len(args) > 6) ||
(ac.Capabilities().PrivateChannelData() && len(args) > 7) {
if !ac.Capabilities().PrivateChannelData() && len(args) > 6 {
return shim.Error(PrivateChannelDataNotAvailable("").Error())
}
if ac.Capabilities().PrivateChannelData() && len(args) > 7 {
return shim.Error(InvalidArgsLenErr(len(args)).Error())
}

Expand Down
2 changes: 1 addition & 1 deletion core/scc/lscc/lscc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestDeploy(t *testing.T) {
// As the PrivateChannelData is disabled, the following error message is expected due to the presence of
// collectionConfigBytes in the stub.args
errMessage := InvalidArgsLenErr(7).Error()
testDeploy(t, "example02", "1.0", path, false, false, true, InvalidArgsLenErr(7).Error(), scc, stub, []byte("collections"))
testDeploy(t, "example02", "1.0", path, false, false, true, PrivateChannelDataNotAvailable("").Error(), scc, stub, []byte("collections"))

// Enable PrivateChannelData
mocksccProvider := (&mscc.MocksccProviderFactory{
Expand Down

0 comments on commit 546360b

Please sign in to comment.