Skip to content

Commit 546360b

Browse files
committed
Improve error message when private data is disabled
FAB-11712 #done Change-Id: I0d69f7ff05033d2d2cbb2642725a48ba2c86f328 Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
1 parent 8df0555 commit 546360b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

core/scc/lscc/errors.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,10 @@ type CollectionsConfigUpgradesNotAllowed string
133133
func (f CollectionsConfigUpgradesNotAllowed) Error() string {
134134
return "as V1_2 capability is not enabled, collection upgrades are not allowed"
135135
}
136+
137+
// PrivateChannelDataNotAvailable when V1_2 or later capability is not enabled
138+
type PrivateChannelDataNotAvailable string
139+
140+
func (f PrivateChannelDataNotAvailable) Error() string {
141+
return "as V1_2 or later capability is not enabled, private channel collections and data are not available"
142+
}

core/scc/lscc/lscc.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,10 @@ func (lscc *LifeCycleSysCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response
855855
}
856856

857857
// the maximum number of arguments depends on the capability of the channel
858-
if (!ac.Capabilities().PrivateChannelData() && len(args) > 6) ||
859-
(ac.Capabilities().PrivateChannelData() && len(args) > 7) {
858+
if !ac.Capabilities().PrivateChannelData() && len(args) > 6 {
859+
return shim.Error(PrivateChannelDataNotAvailable("").Error())
860+
}
861+
if ac.Capabilities().PrivateChannelData() && len(args) > 7 {
860862
return shim.Error(InvalidArgsLenErr(len(args)).Error())
861863
}
862864

core/scc/lscc/lscc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func TestDeploy(t *testing.T) {
244244
// As the PrivateChannelData is disabled, the following error message is expected due to the presence of
245245
// collectionConfigBytes in the stub.args
246246
errMessage := InvalidArgsLenErr(7).Error()
247-
testDeploy(t, "example02", "1.0", path, false, false, true, InvalidArgsLenErr(7).Error(), scc, stub, []byte("collections"))
247+
testDeploy(t, "example02", "1.0", path, false, false, true, PrivateChannelDataNotAvailable("").Error(), scc, stub, []byte("collections"))
248248

249249
// Enable PrivateChannelData
250250
mocksccProvider := (&mscc.MocksccProviderFactory{

0 commit comments

Comments
 (0)