github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/mocks/config/orderer.go (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package config 8 9 import ( 10 "time" 11 12 ab "github.com/hyperledger/fabric-protos-go/orderer" 13 "github.com/hyperledger/fabric/common/channelconfig" 14 ) 15 16 // Orderer is a mock implementation of channelconfig.Orderer 17 type Orderer struct { 18 // ConsensusTypeVal is returned as the result of ConsensusType() 19 ConsensusTypeVal string 20 // ConsensusMetadataVal is returned as the result of ConsensusMetadata() 21 ConsensusMetadataVal []byte 22 // ConsensusTypeStateVal is returned as the result of ConsensusState() 23 ConsensusTypeStateVal ab.ConsensusType_State 24 25 // BatchSizeVal is returned as the result of BatchSize() 26 BatchSizeVal *ab.BatchSize 27 // BatchTimeoutVal is returned as the result of BatchTimeout() 28 BatchTimeoutVal time.Duration 29 // KafkaBrokersVal is returned as the result of KafkaBrokers() 30 KafkaBrokersVal []string 31 // MaxChannelsCountVal is returns as the result of MaxChannelsCount() 32 MaxChannelsCountVal uint64 33 // OrganizationsVal is returned as the result of Organizations() 34 OrganizationsVal map[string]channelconfig.OrdererOrg 35 // CapabilitiesVal is returned as the result of Capabilities() 36 CapabilitiesVal channelconfig.OrdererCapabilities 37 } 38 39 // ConsensusType returns the ConsensusTypeVal 40 func (o *Orderer) ConsensusType() string { 41 return o.ConsensusTypeVal 42 } 43 44 // ConsensusMetadata returns the ConsensusMetadataVal 45 func (o *Orderer) ConsensusMetadata() []byte { 46 return o.ConsensusMetadataVal 47 } 48 49 // ConsensusState returns the ConsensusTypeStateVal 50 func (o *Orderer) ConsensusState() ab.ConsensusType_State { 51 return o.ConsensusTypeStateVal 52 } 53 54 // BatchSize returns the BatchSizeVal 55 func (o *Orderer) BatchSize() *ab.BatchSize { 56 return o.BatchSizeVal 57 } 58 59 // BatchTimeout returns the BatchTimeoutVal 60 func (o *Orderer) BatchTimeout() time.Duration { 61 return o.BatchTimeoutVal 62 } 63 64 // KafkaBrokers returns the KafkaBrokersVal 65 func (o *Orderer) KafkaBrokers() []string { 66 return o.KafkaBrokersVal 67 } 68 69 // MaxChannelsCount returns the MaxChannelsCountVal 70 func (o *Orderer) MaxChannelsCount() uint64 { 71 return o.MaxChannelsCountVal 72 } 73 74 // Organizations returns OrganizationsVal 75 func (o *Orderer) Organizations() map[string]channelconfig.OrdererOrg { 76 return o.OrganizationsVal 77 } 78 79 // Capabilities returns CapabilitiesVal 80 func (o *Orderer) Capabilities() channelconfig.OrdererCapabilities { 81 return o.CapabilitiesVal 82 } 83 84 // OrdererCapabilities mocks the channelconfig.OrdererCapabilities interface 85 type OrdererCapabilities struct { 86 // SupportedErr is returned by Supported() 87 SupportedErr error 88 89 // PredictableChannelTemplateVal is returned by PredictableChannelTemplate() 90 PredictableChannelTemplateVal bool 91 92 // ResubmissionVal is returned by Resubmission() 93 ResubmissionVal bool 94 95 // ExpirationVal is returned by ExpirationCheck() 96 ExpirationVal bool 97 98 ConsensusTypeMigrationVal bool 99 100 UseChannelCreationPolicyAsAdminsVal bool 101 } 102 103 // Supported returns SupportedErr 104 func (oc *OrdererCapabilities) Supported() error { 105 return oc.SupportedErr 106 } 107 108 // PredictableChannelTemplate returns PredictableChannelTemplateVal 109 func (oc *OrdererCapabilities) PredictableChannelTemplate() bool { 110 return oc.PredictableChannelTemplateVal 111 } 112 113 // Resubmission returns ResubmissionVal 114 func (oc *OrdererCapabilities) Resubmission() bool { 115 return oc.ResubmissionVal 116 } 117 118 // ExpirationCheck specifies whether the orderer checks for identity expiration checks 119 // when validating messages 120 func (oc *OrdererCapabilities) ExpirationCheck() bool { 121 return oc.ExpirationVal 122 } 123 124 // ConsensusTypeMigration checks whether the orderer permits a consensus-type migration. 125 func (oc *OrdererCapabilities) ConsensusTypeMigration() bool { 126 return oc.ConsensusTypeMigrationVal 127 } 128 129 func (oc *OrdererCapabilities) UseChannelCreationPolicyAsAdmins() bool { 130 return oc.UseChannelCreationPolicyAsAdminsVal 131 }