github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/capabilities/channel_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package capabilities 8 9 import ( 10 "testing" 11 12 cb "github.com/hyperledger/fabric-protos-go/common" 13 "github.com/hyperledger/fabric/msp" 14 "github.com/stretchr/testify/assert" 15 ) 16 17 func TestChannelV10(t *testing.T) { 18 cp := NewChannelProvider(map[string]*cb.Capability{}) 19 assert.NoError(t, cp.Supported()) 20 assert.True(t, cp.MSPVersion() == msp.MSPv1_0) 21 assert.False(t, cp.ConsensusTypeMigration()) 22 assert.False(t, cp.OrgSpecificOrdererEndpoints()) 23 } 24 25 func TestChannelV11(t *testing.T) { 26 cp := NewChannelProvider(map[string]*cb.Capability{ 27 ChannelV1_1: {}, 28 }) 29 assert.NoError(t, cp.Supported()) 30 assert.True(t, cp.MSPVersion() == msp.MSPv1_1) 31 assert.False(t, cp.ConsensusTypeMigration()) 32 assert.False(t, cp.OrgSpecificOrdererEndpoints()) 33 } 34 35 func TestChannelV13(t *testing.T) { 36 cp := NewChannelProvider(map[string]*cb.Capability{ 37 ChannelV1_1: {}, 38 ChannelV1_3: {}, 39 }) 40 assert.NoError(t, cp.Supported()) 41 assert.True(t, cp.MSPVersion() == msp.MSPv1_3) 42 assert.False(t, cp.ConsensusTypeMigration()) 43 assert.False(t, cp.OrgSpecificOrdererEndpoints()) 44 45 cp = NewChannelProvider(map[string]*cb.Capability{ 46 ChannelV1_3: {}, 47 }) 48 assert.NoError(t, cp.Supported()) 49 assert.True(t, cp.MSPVersion() == msp.MSPv1_3) 50 assert.False(t, cp.ConsensusTypeMigration()) 51 assert.False(t, cp.OrgSpecificOrdererEndpoints()) 52 } 53 54 func TestChannelV142(t *testing.T) { 55 cp := NewChannelProvider(map[string]*cb.Capability{ 56 ChannelV1_3: {}, 57 ChannelV1_4_2: {}, 58 }) 59 assert.NoError(t, cp.Supported()) 60 assert.True(t, cp.MSPVersion() == msp.MSPv1_3) 61 assert.True(t, cp.ConsensusTypeMigration()) 62 assert.True(t, cp.OrgSpecificOrdererEndpoints()) 63 64 cp = NewChannelProvider(map[string]*cb.Capability{ 65 ChannelV1_4_2: {}, 66 }) 67 assert.NoError(t, cp.Supported()) 68 assert.True(t, cp.MSPVersion() == msp.MSPv1_3) 69 assert.True(t, cp.ConsensusTypeMigration()) 70 assert.True(t, cp.OrgSpecificOrdererEndpoints()) 71 } 72 73 func TestChannelV143(t *testing.T) { 74 cp := NewChannelProvider(map[string]*cb.Capability{ 75 ChannelV1_3: {}, 76 ChannelV1_4_2: {}, 77 ChannelV1_4_3: {}, 78 }) 79 assert.NoError(t, cp.Supported()) 80 assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3) 81 assert.True(t, cp.ConsensusTypeMigration()) 82 assert.True(t, cp.OrgSpecificOrdererEndpoints()) 83 84 cp = NewChannelProvider(map[string]*cb.Capability{ 85 ChannelV1_4_3: {}, 86 }) 87 assert.NoError(t, cp.Supported()) 88 assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3) 89 assert.True(t, cp.ConsensusTypeMigration()) 90 assert.True(t, cp.OrgSpecificOrdererEndpoints()) 91 } 92 93 func TestChannelV20(t *testing.T) { 94 cp := NewChannelProvider(map[string]*cb.Capability{ 95 ChannelV2_0: {}, 96 }) 97 assert.NoError(t, cp.Supported()) 98 assert.True(t, cp.MSPVersion() == msp.MSPv1_4_3) 99 assert.True(t, cp.ConsensusTypeMigration()) 100 assert.True(t, cp.OrgSpecificOrdererEndpoints()) 101 } 102 103 func TestChannelNotSuported(t *testing.T) { 104 cp := NewChannelProvider(map[string]*cb.Capability{ 105 ChannelV1_1: {}, 106 ChannelV1_3: {}, 107 "Bogus_Not_suported": {}, 108 }) 109 assert.EqualError(t, cp.Supported(), "Channel capability Bogus_Not_suported is required but not supported") 110 }