Skip to content

Commit 8deac59

Browse files
committed
[FAB-9765] Introduce CollectionUpgrade Capability
Instead of using V1_2Validation capability at lscc to check whether collection upgrades are allowed, this CR introduces CollectionUpgrade capability which will be used with lscc Change-Id: I4559c31beeb9e1a0676bcb19a882d7bb972e6b33 Signed-off-by: senthil <cendhu@gmail.com>
1 parent 3f782c9 commit 8deac59

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

common/capabilities/application.go

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func (ap *ApplicationProvider) PrivateChannelData() bool {
7575
return ap.v11PvtDataExperimental
7676
}
7777

78+
// CollectionUpgrade returns true if this channel is configured to allow updates to
79+
// existing collection or add new collections through chaincode upgrade (as introduced in v1.2)
80+
func (ap ApplicationProvider) CollectionUpgrade() bool {
81+
return ap.v12
82+
}
83+
7884
// V1_1Validation returns true is this channel is configured to perform stricter validation
7985
// of transactions (as introduced in v1.1).
8086
func (ap *ApplicationProvider) V1_1Validation() bool {

common/capabilities/application_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ func TestApplicationPvtDataExperimental(t *testing.T) {
4646
assert.True(t, op.PrivateChannelData())
4747
}
4848

49+
func TestApplicationCollectionUpgrade(t *testing.T) {
50+
op := NewApplicationProvider(map[string]*cb.Capability{
51+
ApplicationV1_2: {},
52+
})
53+
assert.True(t, op.CollectionUpgrade())
54+
}
55+
4956
func TestChaincodeLifecycleExperimental(t *testing.T) {
5057
op := NewApplicationProvider(map[string]*cb.Capability{
5158
ApplicationChaincodeLifecycleExperimental: {},

common/channelconfig/api.go

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ type ApplicationCapabilities interface {
129129
// PrivateChannelData returns true if support for private channel data (a.k.a. collections) is enabled.
130130
PrivateChannelData() bool
131131

132+
// CollectionUpgrade returns true if this channel is configured to allow updates to
133+
// existing collection or add new collections through chaincode upgrade (as introduced in v1.2)
134+
CollectionUpgrade() bool
135+
132136
// V1_1Validation returns true is this channel is configured to perform stricter validation
133137
// of transactions (as introduced in v1.1).
134138
V1_1Validation() bool

common/mocks/config/application.go

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type MockApplicationCapabilities struct {
4040
ForbidDuplicateTXIdInBlockRv bool
4141
ResourcesTreeRv bool
4242
PrivateChannelDataRv bool
43+
CollectionUpgradeRv bool
4344
V1_1ValidationRv bool
4445
V1_2ValidationRv bool
4546
MetadataLifecycleRv bool
@@ -62,6 +63,10 @@ func (mac *MockApplicationCapabilities) PrivateChannelData() bool {
6263
return mac.PrivateChannelDataRv
6364
}
6465

66+
func (mac *MockApplicationCapabilities) CollectionUpgrade() bool {
67+
return mac.CollectionUpgradeRv
68+
}
69+
6570
func (mac *MockApplicationCapabilities) V1_1Validation() bool {
6671
return mac.V1_1ValidationRv
6772
}

0 commit comments

Comments
 (0)