github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/capabilities/orderer_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/stretchr/testify/assert" 14 ) 15 16 func TestOrdererV10(t *testing.T) { 17 op := NewOrdererProvider(map[string]*cb.Capability{}) 18 assert.NoError(t, op.Supported()) 19 assert.Equal(t, ordererTypeName, op.Type()) 20 assert.False(t, op.PredictableChannelTemplate()) 21 assert.False(t, op.Resubmission()) 22 assert.False(t, op.ExpirationCheck()) 23 assert.False(t, op.ConsensusTypeMigration()) 24 assert.False(t, op.UseChannelCreationPolicyAsAdmins()) 25 } 26 27 func TestOrdererV11(t *testing.T) { 28 op := NewOrdererProvider(map[string]*cb.Capability{ 29 OrdererV1_1: {}, 30 }) 31 assert.NoError(t, op.Supported()) 32 assert.True(t, op.PredictableChannelTemplate()) 33 assert.True(t, op.Resubmission()) 34 assert.True(t, op.ExpirationCheck()) 35 assert.False(t, op.ConsensusTypeMigration()) 36 assert.False(t, op.UseChannelCreationPolicyAsAdmins()) 37 } 38 39 func TestOrdererV142(t *testing.T) { 40 op := NewOrdererProvider(map[string]*cb.Capability{ 41 OrdererV1_4_2: {}, 42 }) 43 assert.NoError(t, op.Supported()) 44 assert.True(t, op.PredictableChannelTemplate()) 45 assert.True(t, op.Resubmission()) 46 assert.True(t, op.ExpirationCheck()) 47 assert.True(t, op.ConsensusTypeMigration()) 48 assert.False(t, op.UseChannelCreationPolicyAsAdmins()) 49 } 50 51 func TestOrdererV20(t *testing.T) { 52 op := NewOrdererProvider(map[string]*cb.Capability{ 53 OrdererV2_0: {}, 54 }) 55 assert.NoError(t, op.Supported()) 56 assert.True(t, op.PredictableChannelTemplate()) 57 assert.True(t, op.UseChannelCreationPolicyAsAdmins()) 58 assert.True(t, op.Resubmission()) 59 assert.True(t, op.ExpirationCheck()) 60 assert.True(t, op.ConsensusTypeMigration()) 61 } 62 63 func TestNotSuported(t *testing.T) { 64 op := NewOrdererProvider(map[string]*cb.Capability{ 65 OrdererV1_1: {}, OrdererV2_0: {}, "Bogus_Not_suported": {}, 66 }) 67 assert.EqualError(t, op.Supported(), "Orderer capability Bogus_Not_suported is required but not supported") 68 }