Skip to content

Commit

Permalink
[FAB-9765] Introduce CollectionUpgrade Capability
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cendhu committed May 3, 2018
1 parent 3f782c9 commit 8deac59
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/capabilities/application.go
Expand Up @@ -75,6 +75,12 @@ func (ap *ApplicationProvider) PrivateChannelData() bool {
return ap.v11PvtDataExperimental
}

// CollectionUpgrade returns true if this channel is configured to allow updates to
// existing collection or add new collections through chaincode upgrade (as introduced in v1.2)
func (ap ApplicationProvider) CollectionUpgrade() bool {
return ap.v12
}

// V1_1Validation returns true is this channel is configured to perform stricter validation
// of transactions (as introduced in v1.1).
func (ap *ApplicationProvider) V1_1Validation() bool {
Expand Down
7 changes: 7 additions & 0 deletions common/capabilities/application_test.go
Expand Up @@ -46,6 +46,13 @@ func TestApplicationPvtDataExperimental(t *testing.T) {
assert.True(t, op.PrivateChannelData())
}

func TestApplicationCollectionUpgrade(t *testing.T) {
op := NewApplicationProvider(map[string]*cb.Capability{
ApplicationV1_2: {},
})
assert.True(t, op.CollectionUpgrade())
}

func TestChaincodeLifecycleExperimental(t *testing.T) {
op := NewApplicationProvider(map[string]*cb.Capability{
ApplicationChaincodeLifecycleExperimental: {},
Expand Down
4 changes: 4 additions & 0 deletions common/channelconfig/api.go
Expand Up @@ -129,6 +129,10 @@ type ApplicationCapabilities interface {
// PrivateChannelData returns true if support for private channel data (a.k.a. collections) is enabled.
PrivateChannelData() bool

// CollectionUpgrade returns true if this channel is configured to allow updates to
// existing collection or add new collections through chaincode upgrade (as introduced in v1.2)
CollectionUpgrade() bool

// V1_1Validation returns true is this channel is configured to perform stricter validation
// of transactions (as introduced in v1.1).
V1_1Validation() bool
Expand Down
5 changes: 5 additions & 0 deletions common/mocks/config/application.go
Expand Up @@ -40,6 +40,7 @@ type MockApplicationCapabilities struct {
ForbidDuplicateTXIdInBlockRv bool
ResourcesTreeRv bool
PrivateChannelDataRv bool
CollectionUpgradeRv bool
V1_1ValidationRv bool
V1_2ValidationRv bool
MetadataLifecycleRv bool
Expand All @@ -62,6 +63,10 @@ func (mac *MockApplicationCapabilities) PrivateChannelData() bool {
return mac.PrivateChannelDataRv
}

func (mac *MockApplicationCapabilities) CollectionUpgrade() bool {
return mac.CollectionUpgradeRv
}

func (mac *MockApplicationCapabilities) V1_1Validation() bool {
return mac.V1_1ValidationRv
}
Expand Down

0 comments on commit 8deac59

Please sign in to comment.