From f1f0ef747c62fc1c8c8b951b524973ba12e82864 Mon Sep 17 00:00:00 2001 From: May Rosenbaum Date: Wed, 14 Feb 2024 17:25:48 +0200 Subject: [PATCH] BFT chain unit tests: successful tx propagation Signed-off-by: May Rosenbaum Signed-off-by: Emil Elizarov --- orderer/consensus/smartbft/chain.go | 29 +- orderer/consensus/smartbft/chain_test.go | 76 ++ orderer/consensus/smartbft/consenter.go | 27 +- orderer/consensus/smartbft/interfaces.go | 59 ++ .../smartbft/metrics_provider_converter.go | 8 +- .../consensus/smartbft/mocks/block_puller.go | 179 ++++ .../consensus/smartbft/mocks/communicator.go | 160 +++ .../smartbft/mocks/config_validator.go | 81 ++ .../smartbft/mocks/consenter_support.go | 923 ++++++++++++++++++ .../consensus/smartbft/mocks/egress_comm.go | 151 +++ orderer/consensus/smartbft/mocks/policy.go | 129 +++ .../smartbft/mocks/policy_manager.go | 151 +++ .../smartbft/mocks/signer_serializer.go | 90 +- orderer/consensus/smartbft/signer.go | 2 +- .../consensus/smartbft/util_network_test.go | 479 +++++++++ 15 files changed, 2511 insertions(+), 33 deletions(-) create mode 100644 orderer/consensus/smartbft/chain_test.go create mode 100644 orderer/consensus/smartbft/interfaces.go create mode 100644 orderer/consensus/smartbft/mocks/block_puller.go create mode 100644 orderer/consensus/smartbft/mocks/communicator.go create mode 100644 orderer/consensus/smartbft/mocks/config_validator.go create mode 100644 orderer/consensus/smartbft/mocks/consenter_support.go create mode 100644 orderer/consensus/smartbft/mocks/egress_comm.go create mode 100644 orderer/consensus/smartbft/mocks/policy.go create mode 100644 orderer/consensus/smartbft/mocks/policy_manager.go create mode 100644 orderer/consensus/smartbft/util_network_test.go diff --git a/orderer/consensus/smartbft/chain.go b/orderer/consensus/smartbft/chain.go index b6b34ccc39b..f893c85bc68 100644 --- a/orderer/consensus/smartbft/chain.go +++ b/orderer/consensus/smartbft/chain.go @@ -36,7 +36,7 @@ import ( "go.uber.org/zap" ) -//go:generate counterfeiter -o mocks/mock_blockpuller.go . BlockPuller +//go:generate mockery --dir . --name BlockPuller --case underscore --with-expecter=true --output mocks // BlockPuller is used to pull blocks from other OSN type BlockPuller interface { @@ -53,6 +53,8 @@ type WALConfig struct { } // ConfigValidator interface +// +//go:generate mockery --dir . --name ConfigValidator --case underscore --with-expecter=true --output mocks type ConfigValidator interface { ValidateConfig(env *cb.Envelope) error } @@ -74,13 +76,13 @@ type BFTChain struct { BlockPuller BlockPuller clusterDialer *cluster.PredicateDialer // TODO Required by BFT-synchronizer localConfigCluster localconfig.Cluster // TODO Required by BFT-synchronizer - Comm cluster.Communicator + Comm Communicator SignerSerializer signerSerializer - PolicyManager policies.Manager + PolicyManager PolicyManager Logger *flogging.FabricLogger WALDir string consensus *smartbft.Consensus - support consensus.ConsenterSupport + support ConsenterSupport clusterService *cluster.ClusterService verifier *Verifier assembler *Assembler @@ -105,12 +107,13 @@ func NewChain( localConfigCluster localconfig.Cluster, comm cluster.Communicator, signerSerializer signerSerializer, - policyManager policies.Manager, + policyManager PolicyManager, support consensus.ConsenterSupport, metrics *Metrics, metricsBFT *api.Metrics, metricsWalBFT *wal.Metrics, bccsp bccsp.BCCSP, + egressCommFactory EgressCommFactory, ) (*BFTChain, error) { logger := flogging.MustGetLogger("orderer.consensus.smartbft.chain").With(zap.String("channel", support.ChannelID())) @@ -166,7 +169,7 @@ func NewChain( c.RuntimeConfig.Store(rtc) c.verifier = buildVerifier(cv, c.RuntimeConfig, support, requestInspector, policyManager) - c.consensus = bftSmartConsensusBuild(c, requestInspector) + c.consensus = bftSmartConsensusBuild(c, requestInspector, egressCommFactory) // Setup communication with list of remotes notes for the new channel c.Comm.Configure(c.support.ChannelID(), rtc.RemoteNodes) @@ -183,6 +186,7 @@ func NewChain( func bftSmartConsensusBuild( c *BFTChain, requestInspector *RequestInspector, + egressCommFactory EgressCommFactory, ) *smartbft.Consensus { var err error @@ -275,18 +279,7 @@ func bftSmartConsensusBuild( Assembler: c.assembler, RequestInspector: requestInspector, Synchronizer: sync, - Comm: &Egress{ - RuntimeConfig: c.RuntimeConfig, - Channel: c.support.ChannelID(), - Logger: flogging.MustGetLogger("orderer.consensus.smartbft.egress").With(channelDecorator), - RPC: &cluster.RPC{ - Logger: flogging.MustGetLogger("orderer.consensus.smartbft.rpc").With(channelDecorator), - Channel: c.support.ChannelID(), - StreamsByType: cluster.NewStreamsByType(), - Comm: c.Comm, - Timeout: 5 * time.Minute, // Externalize configuration - }, - }, + Comm: egressCommFactory(c.RuntimeConfig, c.Channel, c.Comm), Scheduler: time.NewTicker(time.Second).C, ViewChangerTicker: time.NewTicker(time.Second).C, } diff --git a/orderer/consensus/smartbft/chain_test.go b/orderer/consensus/smartbft/chain_test.go new file mode 100644 index 00000000000..3f9d730ce0e --- /dev/null +++ b/orderer/consensus/smartbft/chain_test.go @@ -0,0 +1,76 @@ +// Copyright IBM Corp. All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 + +package smartbft_test + +import ( + "bytes" + "encoding/binary" + "testing" + + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric/protoutil" + "github.com/stretchr/testify/require" +) + +var ( + nonce uint64 = 0 +) + +// Scenario: +// 1. Start a network of 4 nodes +// 2. Submit a TX +// 3. Wait for the TX to be received by all nodes +func TestSuccessfulTxPropagation(t *testing.T) { + dir := t.TempDir() + channelId := "testchannel" + + networkSetupInfo := NewNetworkSetupInfo(t, channelId, dir) + nodeMap := networkSetupInfo.CreateNodes(4) + networkSetupInfo.StartAllNodes() + + for _, node := range nodeMap { + node.State.WaitLedgerHeightToBe(1) + } + + env := createEndorserTxEnvelope("TEST_MESSAGE #1", channelId) + err := networkSetupInfo.SendTxToAllAvailableNodes(env) + require.NoError(t, err) + for _, node := range nodeMap { + node.State.WaitLedgerHeightToBe(2) + } +} + +func createEndorserTxEnvelope(message string, channelId string) *cb.Envelope { + return &cb.Envelope{ + Payload: protoutil.MarshalOrPanic(&cb.Payload{ + Header: &cb.Header{ + ChannelHeader: protoutil.MarshalOrPanic(&cb.ChannelHeader{ + Type: int32(cb.HeaderType_ENDORSER_TRANSACTION), + ChannelId: channelId, + }), + SignatureHeader: protoutil.MarshalOrPanic(&cb.SignatureHeader{ + Creator: protoutil.MarshalOrPanic(&msp.SerializedIdentity{ + Mspid: "mockMSP", + IdBytes: []byte("mockClient"), + }), + Nonce: generateNonce(), + }), + }, + Data: []byte(message), + }), + Signature: []byte{1, 2, 3}, + } +} + +func generateNonce() []byte { + nonceBuf := new(bytes.Buffer) + err := binary.Write(nonceBuf, binary.LittleEndian, nonce) + if err != nil { + panic("Cannot generate nonce") + } + nonce++ + return nonceBuf.Bytes() +} diff --git a/orderer/consensus/smartbft/consenter.go b/orderer/consensus/smartbft/consenter.go index 4b111bde357..0fde5858fd2 100644 --- a/orderer/consensus/smartbft/consenter.go +++ b/orderer/consensus/smartbft/consenter.go @@ -14,6 +14,12 @@ import ( "encoding/pem" "path" "reflect" + "sync/atomic" + "time" + + "github.com/hyperledger/fabric/orderer/consensus/smartbft/util" + + "go.uber.org/zap" "github.com/SmartBFT-Go/consensus/pkg/api" "github.com/SmartBFT-Go/consensus/pkg/wal" @@ -32,7 +38,6 @@ import ( "github.com/hyperledger/fabric/orderer/common/localconfig" "github.com/hyperledger/fabric/orderer/common/multichannel" "github.com/hyperledger/fabric/orderer/consensus" - "github.com/hyperledger/fabric/orderer/consensus/smartbft/util" "github.com/hyperledger/fabric/protoutil" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" @@ -96,7 +101,7 @@ func New( logger.Infof("WAL Directory is %s", walConfig.WALDir) mpc := &MetricProviderConverter{ - metricsProvider: metricsProvider, + MetricsProvider: metricsProvider, } consenter := &Consenter{ @@ -202,6 +207,22 @@ func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *cb Logger: c.Logger, } + egressCommFactory := func(runtimeConfig *atomic.Value, channelId string, comm Communicator) EgressComm { + channelDecorator := zap.String("channel", channelId) + return &Egress{ + RuntimeConfig: runtimeConfig, + Channel: channelId, + Logger: flogging.MustGetLogger("orderer.consensus.smartbft.egress").With(channelDecorator), + RPC: &cluster.RPC{ + Logger: flogging.MustGetLogger("orderer.consensus.smartbft.rpc").With(channelDecorator), + Channel: channelId, + StreamsByType: cluster.NewStreamsByType(), + Comm: comm, + Timeout: 5 * time.Minute, // Externalize configuration + }, + } + } + chain, err := NewChain( configValidator, (uint64)(selfID), @@ -218,7 +239,7 @@ func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *cb c.MetricsBFT, c.MetricsWalBFT, c.BCCSP, - ) + egressCommFactory) if err != nil { return nil, errors.Wrap(err, "failed creating a new BFTChain") } diff --git a/orderer/consensus/smartbft/interfaces.go b/orderer/consensus/smartbft/interfaces.go new file mode 100644 index 00000000000..1816de4241c --- /dev/null +++ b/orderer/consensus/smartbft/interfaces.go @@ -0,0 +1,59 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package smartbft + +import ( + "sync/atomic" + + protos "github.com/SmartBFT-Go/consensus/smartbftprotos" + "github.com/hyperledger/fabric/common/policies" + "github.com/hyperledger/fabric/orderer/common/cluster" + "github.com/hyperledger/fabric/orderer/consensus" +) + +//go:generate mockery --dir . --name ConsenterSupport --case underscore --with-expecter=true --output mocks + +// ConsenterSupport provides the resources available to a Consenter implementation. +type ConsenterSupport interface { + consensus.ConsenterSupport +} + +//go:generate mockery --dir . --name Communicator --case underscore --with-expecter=true --output mocks + +// Communicator defines communication for a consenter +type Communicator interface { + cluster.Communicator +} + +//go:generate mockery --dir . --name PolicyManager --case underscore --with-expecter=true --output mocks + +// PolicyManager is a read only subset of the policy ManagerImpl +type PolicyManager interface { + policies.Manager +} + +//go:generate mockery --dir . --name Policy --case underscore --with-expecter=true --output mocks + +// Policy is used to determine if a signature is valid +type Policy interface { + policies.Policy +} + +//go:generate mockery --dir . --name EgressComm --case underscore --with-expecter=true --output mocks + +type EgressCommFactory func(runtimeConfig *atomic.Value, channelId string, comm Communicator) EgressComm + +// Comm enables the communications between the nodes. +type EgressComm interface { + // SendConsensus sends the consensus protocol related message m to the node with id targetID. + SendConsensus(targetID uint64, m *protos.Message) + // SendTransaction sends the given client's request to the node with id targetID. + SendTransaction(targetID uint64, request []byte) + // Nodes returns a set of ids of participating nodes. + // In case you need to change or keep this slice, create a copy. + Nodes() []uint64 +} diff --git a/orderer/consensus/smartbft/metrics_provider_converter.go b/orderer/consensus/smartbft/metrics_provider_converter.go index 54bbdc32e2b..6ff13bcd2a0 100644 --- a/orderer/consensus/smartbft/metrics_provider_converter.go +++ b/orderer/consensus/smartbft/metrics_provider_converter.go @@ -12,7 +12,7 @@ import ( ) type MetricProviderConverter struct { - metricsProvider metrics.Provider + MetricsProvider metrics.Provider } func (m *MetricProviderConverter) NewCounter(opts api.CounterOpts) api.Counter { @@ -26,7 +26,7 @@ func (m *MetricProviderConverter) NewCounter(opts api.CounterOpts) api.Counter { StatsdFormat: opts.StatsdFormat, } return &CounterConverter{ - counter: m.metricsProvider.NewCounter(o), + counter: m.MetricsProvider.NewCounter(o), } } @@ -41,7 +41,7 @@ func (m *MetricProviderConverter) NewGauge(opts api.GaugeOpts) api.Gauge { StatsdFormat: opts.StatsdFormat, } return &GaugeConverter{ - gauge: m.metricsProvider.NewGauge(o), + gauge: m.MetricsProvider.NewGauge(o), } } @@ -57,7 +57,7 @@ func (m *MetricProviderConverter) NewHistogram(opts api.HistogramOpts) api.Histo Buckets: opts.Buckets, } return &HistogramConverter{ - histogram: m.metricsProvider.NewHistogram(o), + histogram: m.MetricsProvider.NewHistogram(o), } } diff --git a/orderer/consensus/smartbft/mocks/block_puller.go b/orderer/consensus/smartbft/mocks/block_puller.go new file mode 100644 index 00000000000..dc38e1e2444 --- /dev/null +++ b/orderer/consensus/smartbft/mocks/block_puller.go @@ -0,0 +1,179 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + common "github.com/hyperledger/fabric-protos-go/common" + mock "github.com/stretchr/testify/mock" +) + +// BlockPuller is an autogenerated mock type for the BlockPuller type +type BlockPuller struct { + mock.Mock +} + +type BlockPuller_Expecter struct { + mock *mock.Mock +} + +func (_m *BlockPuller) EXPECT() *BlockPuller_Expecter { + return &BlockPuller_Expecter{mock: &_m.Mock} +} + +// Close provides a mock function with given fields: +func (_m *BlockPuller) Close() { + _m.Called() +} + +// BlockPuller_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' +type BlockPuller_Close_Call struct { + *mock.Call +} + +// Close is a helper method to define mock.On call +func (_e *BlockPuller_Expecter) Close() *BlockPuller_Close_Call { + return &BlockPuller_Close_Call{Call: _e.mock.On("Close")} +} + +func (_c *BlockPuller_Close_Call) Run(run func()) *BlockPuller_Close_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *BlockPuller_Close_Call) Return() *BlockPuller_Close_Call { + _c.Call.Return() + return _c +} + +func (_c *BlockPuller_Close_Call) RunAndReturn(run func()) *BlockPuller_Close_Call { + _c.Call.Return(run) + return _c +} + +// HeightsByEndpoints provides a mock function with given fields: +func (_m *BlockPuller) HeightsByEndpoints() (map[string]uint64, string, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HeightsByEndpoints") + } + + var r0 map[string]uint64 + var r1 string + var r2 error + if rf, ok := ret.Get(0).(func() (map[string]uint64, string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() map[string]uint64); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]uint64) + } + } + + if rf, ok := ret.Get(1).(func() string); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(string) + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// BlockPuller_HeightsByEndpoints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeightsByEndpoints' +type BlockPuller_HeightsByEndpoints_Call struct { + *mock.Call +} + +// HeightsByEndpoints is a helper method to define mock.On call +func (_e *BlockPuller_Expecter) HeightsByEndpoints() *BlockPuller_HeightsByEndpoints_Call { + return &BlockPuller_HeightsByEndpoints_Call{Call: _e.mock.On("HeightsByEndpoints")} +} + +func (_c *BlockPuller_HeightsByEndpoints_Call) Run(run func()) *BlockPuller_HeightsByEndpoints_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *BlockPuller_HeightsByEndpoints_Call) Return(_a0 map[string]uint64, _a1 string, _a2 error) *BlockPuller_HeightsByEndpoints_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *BlockPuller_HeightsByEndpoints_Call) RunAndReturn(run func() (map[string]uint64, string, error)) *BlockPuller_HeightsByEndpoints_Call { + _c.Call.Return(run) + return _c +} + +// PullBlock provides a mock function with given fields: seq +func (_m *BlockPuller) PullBlock(seq uint64) *common.Block { + ret := _m.Called(seq) + + if len(ret) == 0 { + panic("no return value specified for PullBlock") + } + + var r0 *common.Block + if rf, ok := ret.Get(0).(func(uint64) *common.Block); ok { + r0 = rf(seq) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.Block) + } + } + + return r0 +} + +// BlockPuller_PullBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PullBlock' +type BlockPuller_PullBlock_Call struct { + *mock.Call +} + +// PullBlock is a helper method to define mock.On call +// - seq uint64 +func (_e *BlockPuller_Expecter) PullBlock(seq interface{}) *BlockPuller_PullBlock_Call { + return &BlockPuller_PullBlock_Call{Call: _e.mock.On("PullBlock", seq)} +} + +func (_c *BlockPuller_PullBlock_Call) Run(run func(seq uint64)) *BlockPuller_PullBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *BlockPuller_PullBlock_Call) Return(_a0 *common.Block) *BlockPuller_PullBlock_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BlockPuller_PullBlock_Call) RunAndReturn(run func(uint64) *common.Block) *BlockPuller_PullBlock_Call { + _c.Call.Return(run) + return _c +} + +// NewBlockPuller creates a new instance of BlockPuller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewBlockPuller(t interface { + mock.TestingT + Cleanup(func()) +}) *BlockPuller { + mock := &BlockPuller{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/communicator.go b/orderer/consensus/smartbft/mocks/communicator.go new file mode 100644 index 00000000000..ff24ca846bc --- /dev/null +++ b/orderer/consensus/smartbft/mocks/communicator.go @@ -0,0 +1,160 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + cluster "github.com/hyperledger/fabric/orderer/common/cluster" + mock "github.com/stretchr/testify/mock" +) + +// Communicator is an autogenerated mock type for the Communicator type +type Communicator struct { + mock.Mock +} + +type Communicator_Expecter struct { + mock *mock.Mock +} + +func (_m *Communicator) EXPECT() *Communicator_Expecter { + return &Communicator_Expecter{mock: &_m.Mock} +} + +// Configure provides a mock function with given fields: channel, members +func (_m *Communicator) Configure(channel string, members []cluster.RemoteNode) { + _m.Called(channel, members) +} + +// Communicator_Configure_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Configure' +type Communicator_Configure_Call struct { + *mock.Call +} + +// Configure is a helper method to define mock.On call +// - channel string +// - members []cluster.RemoteNode +func (_e *Communicator_Expecter) Configure(channel interface{}, members interface{}) *Communicator_Configure_Call { + return &Communicator_Configure_Call{Call: _e.mock.On("Configure", channel, members)} +} + +func (_c *Communicator_Configure_Call) Run(run func(channel string, members []cluster.RemoteNode)) *Communicator_Configure_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].([]cluster.RemoteNode)) + }) + return _c +} + +func (_c *Communicator_Configure_Call) Return() *Communicator_Configure_Call { + _c.Call.Return() + return _c +} + +func (_c *Communicator_Configure_Call) RunAndReturn(run func(string, []cluster.RemoteNode)) *Communicator_Configure_Call { + _c.Call.Return(run) + return _c +} + +// Remote provides a mock function with given fields: channel, id +func (_m *Communicator) Remote(channel string, id uint64) (*cluster.RemoteContext, error) { + ret := _m.Called(channel, id) + + if len(ret) == 0 { + panic("no return value specified for Remote") + } + + var r0 *cluster.RemoteContext + var r1 error + if rf, ok := ret.Get(0).(func(string, uint64) (*cluster.RemoteContext, error)); ok { + return rf(channel, id) + } + if rf, ok := ret.Get(0).(func(string, uint64) *cluster.RemoteContext); ok { + r0 = rf(channel, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*cluster.RemoteContext) + } + } + + if rf, ok := ret.Get(1).(func(string, uint64) error); ok { + r1 = rf(channel, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Communicator_Remote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remote' +type Communicator_Remote_Call struct { + *mock.Call +} + +// Remote is a helper method to define mock.On call +// - channel string +// - id uint64 +func (_e *Communicator_Expecter) Remote(channel interface{}, id interface{}) *Communicator_Remote_Call { + return &Communicator_Remote_Call{Call: _e.mock.On("Remote", channel, id)} +} + +func (_c *Communicator_Remote_Call) Run(run func(channel string, id uint64)) *Communicator_Remote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(uint64)) + }) + return _c +} + +func (_c *Communicator_Remote_Call) Return(_a0 *cluster.RemoteContext, _a1 error) *Communicator_Remote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Communicator_Remote_Call) RunAndReturn(run func(string, uint64) (*cluster.RemoteContext, error)) *Communicator_Remote_Call { + _c.Call.Return(run) + return _c +} + +// Shutdown provides a mock function with given fields: +func (_m *Communicator) Shutdown() { + _m.Called() +} + +// Communicator_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown' +type Communicator_Shutdown_Call struct { + *mock.Call +} + +// Shutdown is a helper method to define mock.On call +func (_e *Communicator_Expecter) Shutdown() *Communicator_Shutdown_Call { + return &Communicator_Shutdown_Call{Call: _e.mock.On("Shutdown")} +} + +func (_c *Communicator_Shutdown_Call) Run(run func()) *Communicator_Shutdown_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Communicator_Shutdown_Call) Return() *Communicator_Shutdown_Call { + _c.Call.Return() + return _c +} + +func (_c *Communicator_Shutdown_Call) RunAndReturn(run func()) *Communicator_Shutdown_Call { + _c.Call.Return(run) + return _c +} + +// NewCommunicator creates a new instance of Communicator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCommunicator(t interface { + mock.TestingT + Cleanup(func()) +}) *Communicator { + mock := &Communicator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/config_validator.go b/orderer/consensus/smartbft/mocks/config_validator.go new file mode 100644 index 00000000000..9498539a8e6 --- /dev/null +++ b/orderer/consensus/smartbft/mocks/config_validator.go @@ -0,0 +1,81 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + common "github.com/hyperledger/fabric-protos-go/common" + mock "github.com/stretchr/testify/mock" +) + +// ConfigValidator is an autogenerated mock type for the ConfigValidator type +type ConfigValidator struct { + mock.Mock +} + +type ConfigValidator_Expecter struct { + mock *mock.Mock +} + +func (_m *ConfigValidator) EXPECT() *ConfigValidator_Expecter { + return &ConfigValidator_Expecter{mock: &_m.Mock} +} + +// ValidateConfig provides a mock function with given fields: env +func (_m *ConfigValidator) ValidateConfig(env *common.Envelope) error { + ret := _m.Called(env) + + if len(ret) == 0 { + panic("no return value specified for ValidateConfig") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*common.Envelope) error); ok { + r0 = rf(env) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ConfigValidator_ValidateConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateConfig' +type ConfigValidator_ValidateConfig_Call struct { + *mock.Call +} + +// ValidateConfig is a helper method to define mock.On call +// - env *common.Envelope +func (_e *ConfigValidator_Expecter) ValidateConfig(env interface{}) *ConfigValidator_ValidateConfig_Call { + return &ConfigValidator_ValidateConfig_Call{Call: _e.mock.On("ValidateConfig", env)} +} + +func (_c *ConfigValidator_ValidateConfig_Call) Run(run func(env *common.Envelope)) *ConfigValidator_ValidateConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Envelope)) + }) + return _c +} + +func (_c *ConfigValidator_ValidateConfig_Call) Return(_a0 error) *ConfigValidator_ValidateConfig_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConfigValidator_ValidateConfig_Call) RunAndReturn(run func(*common.Envelope) error) *ConfigValidator_ValidateConfig_Call { + _c.Call.Return(run) + return _c +} + +// NewConfigValidator creates a new instance of ConfigValidator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConfigValidator(t interface { + mock.TestingT + Cleanup(func()) +}) *ConfigValidator { + mock := &ConfigValidator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/consenter_support.go b/orderer/consensus/smartbft/mocks/consenter_support.go new file mode 100644 index 00000000000..c4b75bad0b6 --- /dev/null +++ b/orderer/consensus/smartbft/mocks/consenter_support.go @@ -0,0 +1,923 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + channelconfig "github.com/hyperledger/fabric/common/channelconfig" + blockcutter "github.com/hyperledger/fabric/orderer/common/blockcutter" + + common "github.com/hyperledger/fabric-protos-go/common" + + mock "github.com/stretchr/testify/mock" + + msgprocessor "github.com/hyperledger/fabric/orderer/common/msgprocessor" + + protoutil "github.com/hyperledger/fabric/protoutil" +) + +// ConsenterSupport is an autogenerated mock type for the ConsenterSupport type +type ConsenterSupport struct { + mock.Mock +} + +type ConsenterSupport_Expecter struct { + mock *mock.Mock +} + +func (_m *ConsenterSupport) EXPECT() *ConsenterSupport_Expecter { + return &ConsenterSupport_Expecter{mock: &_m.Mock} +} + +// Append provides a mock function with given fields: block +func (_m *ConsenterSupport) Append(block *common.Block) error { + ret := _m.Called(block) + + if len(ret) == 0 { + panic("no return value specified for Append") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*common.Block) error); ok { + r0 = rf(block) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ConsenterSupport_Append_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Append' +type ConsenterSupport_Append_Call struct { + *mock.Call +} + +// Append is a helper method to define mock.On call +// - block *common.Block +func (_e *ConsenterSupport_Expecter) Append(block interface{}) *ConsenterSupport_Append_Call { + return &ConsenterSupport_Append_Call{Call: _e.mock.On("Append", block)} +} + +func (_c *ConsenterSupport_Append_Call) Run(run func(block *common.Block)) *ConsenterSupport_Append_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Block)) + }) + return _c +} + +func (_c *ConsenterSupport_Append_Call) Return(_a0 error) *ConsenterSupport_Append_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_Append_Call) RunAndReturn(run func(*common.Block) error) *ConsenterSupport_Append_Call { + _c.Call.Return(run) + return _c +} + +// Block provides a mock function with given fields: number +func (_m *ConsenterSupport) Block(number uint64) *common.Block { + ret := _m.Called(number) + + if len(ret) == 0 { + panic("no return value specified for Block") + } + + var r0 *common.Block + if rf, ok := ret.Get(0).(func(uint64) *common.Block); ok { + r0 = rf(number) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.Block) + } + } + + return r0 +} + +// ConsenterSupport_Block_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Block' +type ConsenterSupport_Block_Call struct { + *mock.Call +} + +// Block is a helper method to define mock.On call +// - number uint64 +func (_e *ConsenterSupport_Expecter) Block(number interface{}) *ConsenterSupport_Block_Call { + return &ConsenterSupport_Block_Call{Call: _e.mock.On("Block", number)} +} + +func (_c *ConsenterSupport_Block_Call) Run(run func(number uint64)) *ConsenterSupport_Block_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *ConsenterSupport_Block_Call) Return(_a0 *common.Block) *ConsenterSupport_Block_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_Block_Call) RunAndReturn(run func(uint64) *common.Block) *ConsenterSupport_Block_Call { + _c.Call.Return(run) + return _c +} + +// BlockCutter provides a mock function with given fields: +func (_m *ConsenterSupport) BlockCutter() blockcutter.Receiver { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for BlockCutter") + } + + var r0 blockcutter.Receiver + if rf, ok := ret.Get(0).(func() blockcutter.Receiver); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(blockcutter.Receiver) + } + } + + return r0 +} + +// ConsenterSupport_BlockCutter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BlockCutter' +type ConsenterSupport_BlockCutter_Call struct { + *mock.Call +} + +// BlockCutter is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) BlockCutter() *ConsenterSupport_BlockCutter_Call { + return &ConsenterSupport_BlockCutter_Call{Call: _e.mock.On("BlockCutter")} +} + +func (_c *ConsenterSupport_BlockCutter_Call) Run(run func()) *ConsenterSupport_BlockCutter_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_BlockCutter_Call) Return(_a0 blockcutter.Receiver) *ConsenterSupport_BlockCutter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_BlockCutter_Call) RunAndReturn(run func() blockcutter.Receiver) *ConsenterSupport_BlockCutter_Call { + _c.Call.Return(run) + return _c +} + +// ChannelConfig provides a mock function with given fields: +func (_m *ConsenterSupport) ChannelConfig() channelconfig.Channel { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ChannelConfig") + } + + var r0 channelconfig.Channel + if rf, ok := ret.Get(0).(func() channelconfig.Channel); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(channelconfig.Channel) + } + } + + return r0 +} + +// ConsenterSupport_ChannelConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChannelConfig' +type ConsenterSupport_ChannelConfig_Call struct { + *mock.Call +} + +// ChannelConfig is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) ChannelConfig() *ConsenterSupport_ChannelConfig_Call { + return &ConsenterSupport_ChannelConfig_Call{Call: _e.mock.On("ChannelConfig")} +} + +func (_c *ConsenterSupport_ChannelConfig_Call) Run(run func()) *ConsenterSupport_ChannelConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_ChannelConfig_Call) Return(_a0 channelconfig.Channel) *ConsenterSupport_ChannelConfig_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_ChannelConfig_Call) RunAndReturn(run func() channelconfig.Channel) *ConsenterSupport_ChannelConfig_Call { + _c.Call.Return(run) + return _c +} + +// ChannelID provides a mock function with given fields: +func (_m *ConsenterSupport) ChannelID() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ChannelID") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// ConsenterSupport_ChannelID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChannelID' +type ConsenterSupport_ChannelID_Call struct { + *mock.Call +} + +// ChannelID is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) ChannelID() *ConsenterSupport_ChannelID_Call { + return &ConsenterSupport_ChannelID_Call{Call: _e.mock.On("ChannelID")} +} + +func (_c *ConsenterSupport_ChannelID_Call) Run(run func()) *ConsenterSupport_ChannelID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_ChannelID_Call) Return(_a0 string) *ConsenterSupport_ChannelID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_ChannelID_Call) RunAndReturn(run func() string) *ConsenterSupport_ChannelID_Call { + _c.Call.Return(run) + return _c +} + +// ClassifyMsg provides a mock function with given fields: chdr +func (_m *ConsenterSupport) ClassifyMsg(chdr *common.ChannelHeader) msgprocessor.Classification { + ret := _m.Called(chdr) + + if len(ret) == 0 { + panic("no return value specified for ClassifyMsg") + } + + var r0 msgprocessor.Classification + if rf, ok := ret.Get(0).(func(*common.ChannelHeader) msgprocessor.Classification); ok { + r0 = rf(chdr) + } else { + r0 = ret.Get(0).(msgprocessor.Classification) + } + + return r0 +} + +// ConsenterSupport_ClassifyMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClassifyMsg' +type ConsenterSupport_ClassifyMsg_Call struct { + *mock.Call +} + +// ClassifyMsg is a helper method to define mock.On call +// - chdr *common.ChannelHeader +func (_e *ConsenterSupport_Expecter) ClassifyMsg(chdr interface{}) *ConsenterSupport_ClassifyMsg_Call { + return &ConsenterSupport_ClassifyMsg_Call{Call: _e.mock.On("ClassifyMsg", chdr)} +} + +func (_c *ConsenterSupport_ClassifyMsg_Call) Run(run func(chdr *common.ChannelHeader)) *ConsenterSupport_ClassifyMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.ChannelHeader)) + }) + return _c +} + +func (_c *ConsenterSupport_ClassifyMsg_Call) Return(_a0 msgprocessor.Classification) *ConsenterSupport_ClassifyMsg_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_ClassifyMsg_Call) RunAndReturn(run func(*common.ChannelHeader) msgprocessor.Classification) *ConsenterSupport_ClassifyMsg_Call { + _c.Call.Return(run) + return _c +} + +// CreateNextBlock provides a mock function with given fields: messages +func (_m *ConsenterSupport) CreateNextBlock(messages []*common.Envelope) *common.Block { + ret := _m.Called(messages) + + if len(ret) == 0 { + panic("no return value specified for CreateNextBlock") + } + + var r0 *common.Block + if rf, ok := ret.Get(0).(func([]*common.Envelope) *common.Block); ok { + r0 = rf(messages) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.Block) + } + } + + return r0 +} + +// ConsenterSupport_CreateNextBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateNextBlock' +type ConsenterSupport_CreateNextBlock_Call struct { + *mock.Call +} + +// CreateNextBlock is a helper method to define mock.On call +// - messages []*common.Envelope +func (_e *ConsenterSupport_Expecter) CreateNextBlock(messages interface{}) *ConsenterSupport_CreateNextBlock_Call { + return &ConsenterSupport_CreateNextBlock_Call{Call: _e.mock.On("CreateNextBlock", messages)} +} + +func (_c *ConsenterSupport_CreateNextBlock_Call) Run(run func(messages []*common.Envelope)) *ConsenterSupport_CreateNextBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]*common.Envelope)) + }) + return _c +} + +func (_c *ConsenterSupport_CreateNextBlock_Call) Return(_a0 *common.Block) *ConsenterSupport_CreateNextBlock_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_CreateNextBlock_Call) RunAndReturn(run func([]*common.Envelope) *common.Block) *ConsenterSupport_CreateNextBlock_Call { + _c.Call.Return(run) + return _c +} + +// Height provides a mock function with given fields: +func (_m *ConsenterSupport) Height() uint64 { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Height") + } + + var r0 uint64 + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + return r0 +} + +// ConsenterSupport_Height_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Height' +type ConsenterSupport_Height_Call struct { + *mock.Call +} + +// Height is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) Height() *ConsenterSupport_Height_Call { + return &ConsenterSupport_Height_Call{Call: _e.mock.On("Height")} +} + +func (_c *ConsenterSupport_Height_Call) Run(run func()) *ConsenterSupport_Height_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_Height_Call) Return(_a0 uint64) *ConsenterSupport_Height_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_Height_Call) RunAndReturn(run func() uint64) *ConsenterSupport_Height_Call { + _c.Call.Return(run) + return _c +} + +// ProcessConfigMsg provides a mock function with given fields: env +func (_m *ConsenterSupport) ProcessConfigMsg(env *common.Envelope) (*common.Envelope, uint64, error) { + ret := _m.Called(env) + + if len(ret) == 0 { + panic("no return value specified for ProcessConfigMsg") + } + + var r0 *common.Envelope + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func(*common.Envelope) (*common.Envelope, uint64, error)); ok { + return rf(env) + } + if rf, ok := ret.Get(0).(func(*common.Envelope) *common.Envelope); ok { + r0 = rf(env) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.Envelope) + } + } + + if rf, ok := ret.Get(1).(func(*common.Envelope) uint64); ok { + r1 = rf(env) + } else { + r1 = ret.Get(1).(uint64) + } + + if rf, ok := ret.Get(2).(func(*common.Envelope) error); ok { + r2 = rf(env) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ConsenterSupport_ProcessConfigMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessConfigMsg' +type ConsenterSupport_ProcessConfigMsg_Call struct { + *mock.Call +} + +// ProcessConfigMsg is a helper method to define mock.On call +// - env *common.Envelope +func (_e *ConsenterSupport_Expecter) ProcessConfigMsg(env interface{}) *ConsenterSupport_ProcessConfigMsg_Call { + return &ConsenterSupport_ProcessConfigMsg_Call{Call: _e.mock.On("ProcessConfigMsg", env)} +} + +func (_c *ConsenterSupport_ProcessConfigMsg_Call) Run(run func(env *common.Envelope)) *ConsenterSupport_ProcessConfigMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Envelope)) + }) + return _c +} + +func (_c *ConsenterSupport_ProcessConfigMsg_Call) Return(_a0 *common.Envelope, _a1 uint64, _a2 error) *ConsenterSupport_ProcessConfigMsg_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *ConsenterSupport_ProcessConfigMsg_Call) RunAndReturn(run func(*common.Envelope) (*common.Envelope, uint64, error)) *ConsenterSupport_ProcessConfigMsg_Call { + _c.Call.Return(run) + return _c +} + +// ProcessConfigUpdateMsg provides a mock function with given fields: env +func (_m *ConsenterSupport) ProcessConfigUpdateMsg(env *common.Envelope) (*common.Envelope, uint64, error) { + ret := _m.Called(env) + + if len(ret) == 0 { + panic("no return value specified for ProcessConfigUpdateMsg") + } + + var r0 *common.Envelope + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func(*common.Envelope) (*common.Envelope, uint64, error)); ok { + return rf(env) + } + if rf, ok := ret.Get(0).(func(*common.Envelope) *common.Envelope); ok { + r0 = rf(env) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.Envelope) + } + } + + if rf, ok := ret.Get(1).(func(*common.Envelope) uint64); ok { + r1 = rf(env) + } else { + r1 = ret.Get(1).(uint64) + } + + if rf, ok := ret.Get(2).(func(*common.Envelope) error); ok { + r2 = rf(env) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ConsenterSupport_ProcessConfigUpdateMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessConfigUpdateMsg' +type ConsenterSupport_ProcessConfigUpdateMsg_Call struct { + *mock.Call +} + +// ProcessConfigUpdateMsg is a helper method to define mock.On call +// - env *common.Envelope +func (_e *ConsenterSupport_Expecter) ProcessConfigUpdateMsg(env interface{}) *ConsenterSupport_ProcessConfigUpdateMsg_Call { + return &ConsenterSupport_ProcessConfigUpdateMsg_Call{Call: _e.mock.On("ProcessConfigUpdateMsg", env)} +} + +func (_c *ConsenterSupport_ProcessConfigUpdateMsg_Call) Run(run func(env *common.Envelope)) *ConsenterSupport_ProcessConfigUpdateMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Envelope)) + }) + return _c +} + +func (_c *ConsenterSupport_ProcessConfigUpdateMsg_Call) Return(config *common.Envelope, configSeq uint64, err error) *ConsenterSupport_ProcessConfigUpdateMsg_Call { + _c.Call.Return(config, configSeq, err) + return _c +} + +func (_c *ConsenterSupport_ProcessConfigUpdateMsg_Call) RunAndReturn(run func(*common.Envelope) (*common.Envelope, uint64, error)) *ConsenterSupport_ProcessConfigUpdateMsg_Call { + _c.Call.Return(run) + return _c +} + +// ProcessNormalMsg provides a mock function with given fields: env +func (_m *ConsenterSupport) ProcessNormalMsg(env *common.Envelope) (uint64, error) { + ret := _m.Called(env) + + if len(ret) == 0 { + panic("no return value specified for ProcessNormalMsg") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(*common.Envelope) (uint64, error)); ok { + return rf(env) + } + if rf, ok := ret.Get(0).(func(*common.Envelope) uint64); ok { + r0 = rf(env) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(*common.Envelope) error); ok { + r1 = rf(env) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ConsenterSupport_ProcessNormalMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessNormalMsg' +type ConsenterSupport_ProcessNormalMsg_Call struct { + *mock.Call +} + +// ProcessNormalMsg is a helper method to define mock.On call +// - env *common.Envelope +func (_e *ConsenterSupport_Expecter) ProcessNormalMsg(env interface{}) *ConsenterSupport_ProcessNormalMsg_Call { + return &ConsenterSupport_ProcessNormalMsg_Call{Call: _e.mock.On("ProcessNormalMsg", env)} +} + +func (_c *ConsenterSupport_ProcessNormalMsg_Call) Run(run func(env *common.Envelope)) *ConsenterSupport_ProcessNormalMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Envelope)) + }) + return _c +} + +func (_c *ConsenterSupport_ProcessNormalMsg_Call) Return(configSeq uint64, err error) *ConsenterSupport_ProcessNormalMsg_Call { + _c.Call.Return(configSeq, err) + return _c +} + +func (_c *ConsenterSupport_ProcessNormalMsg_Call) RunAndReturn(run func(*common.Envelope) (uint64, error)) *ConsenterSupport_ProcessNormalMsg_Call { + _c.Call.Return(run) + return _c +} + +// Sequence provides a mock function with given fields: +func (_m *ConsenterSupport) Sequence() uint64 { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Sequence") + } + + var r0 uint64 + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + return r0 +} + +// ConsenterSupport_Sequence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sequence' +type ConsenterSupport_Sequence_Call struct { + *mock.Call +} + +// Sequence is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) Sequence() *ConsenterSupport_Sequence_Call { + return &ConsenterSupport_Sequence_Call{Call: _e.mock.On("Sequence")} +} + +func (_c *ConsenterSupport_Sequence_Call) Run(run func()) *ConsenterSupport_Sequence_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_Sequence_Call) Return(_a0 uint64) *ConsenterSupport_Sequence_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_Sequence_Call) RunAndReturn(run func() uint64) *ConsenterSupport_Sequence_Call { + _c.Call.Return(run) + return _c +} + +// Serialize provides a mock function with given fields: +func (_m *ConsenterSupport) Serialize() ([]byte, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []byte); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ConsenterSupport_Serialize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Serialize' +type ConsenterSupport_Serialize_Call struct { + *mock.Call +} + +// Serialize is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) Serialize() *ConsenterSupport_Serialize_Call { + return &ConsenterSupport_Serialize_Call{Call: _e.mock.On("Serialize")} +} + +func (_c *ConsenterSupport_Serialize_Call) Run(run func()) *ConsenterSupport_Serialize_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_Serialize_Call) Return(_a0 []byte, _a1 error) *ConsenterSupport_Serialize_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ConsenterSupport_Serialize_Call) RunAndReturn(run func() ([]byte, error)) *ConsenterSupport_Serialize_Call { + _c.Call.Return(run) + return _c +} + +// SharedConfig provides a mock function with given fields: +func (_m *ConsenterSupport) SharedConfig() channelconfig.Orderer { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SharedConfig") + } + + var r0 channelconfig.Orderer + if rf, ok := ret.Get(0).(func() channelconfig.Orderer); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(channelconfig.Orderer) + } + } + + return r0 +} + +// ConsenterSupport_SharedConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SharedConfig' +type ConsenterSupport_SharedConfig_Call struct { + *mock.Call +} + +// SharedConfig is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) SharedConfig() *ConsenterSupport_SharedConfig_Call { + return &ConsenterSupport_SharedConfig_Call{Call: _e.mock.On("SharedConfig")} +} + +func (_c *ConsenterSupport_SharedConfig_Call) Run(run func()) *ConsenterSupport_SharedConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_SharedConfig_Call) Return(_a0 channelconfig.Orderer) *ConsenterSupport_SharedConfig_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_SharedConfig_Call) RunAndReturn(run func() channelconfig.Orderer) *ConsenterSupport_SharedConfig_Call { + _c.Call.Return(run) + return _c +} + +// Sign provides a mock function with given fields: message +func (_m *ConsenterSupport) Sign(message []byte) ([]byte, error) { + ret := _m.Called(message) + + if len(ret) == 0 { + panic("no return value specified for Sign") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func([]byte) ([]byte, error)); ok { + return rf(message) + } + if rf, ok := ret.Get(0).(func([]byte) []byte); ok { + r0 = rf(message) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(message) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ConsenterSupport_Sign_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sign' +type ConsenterSupport_Sign_Call struct { + *mock.Call +} + +// Sign is a helper method to define mock.On call +// - message []byte +func (_e *ConsenterSupport_Expecter) Sign(message interface{}) *ConsenterSupport_Sign_Call { + return &ConsenterSupport_Sign_Call{Call: _e.mock.On("Sign", message)} +} + +func (_c *ConsenterSupport_Sign_Call) Run(run func(message []byte)) *ConsenterSupport_Sign_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]byte)) + }) + return _c +} + +func (_c *ConsenterSupport_Sign_Call) Return(_a0 []byte, _a1 error) *ConsenterSupport_Sign_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ConsenterSupport_Sign_Call) RunAndReturn(run func([]byte) ([]byte, error)) *ConsenterSupport_Sign_Call { + _c.Call.Return(run) + return _c +} + +// SignatureVerifier provides a mock function with given fields: +func (_m *ConsenterSupport) SignatureVerifier() protoutil.BlockVerifierFunc { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SignatureVerifier") + } + + var r0 protoutil.BlockVerifierFunc + if rf, ok := ret.Get(0).(func() protoutil.BlockVerifierFunc); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(protoutil.BlockVerifierFunc) + } + } + + return r0 +} + +// ConsenterSupport_SignatureVerifier_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SignatureVerifier' +type ConsenterSupport_SignatureVerifier_Call struct { + *mock.Call +} + +// SignatureVerifier is a helper method to define mock.On call +func (_e *ConsenterSupport_Expecter) SignatureVerifier() *ConsenterSupport_SignatureVerifier_Call { + return &ConsenterSupport_SignatureVerifier_Call{Call: _e.mock.On("SignatureVerifier")} +} + +func (_c *ConsenterSupport_SignatureVerifier_Call) Run(run func()) *ConsenterSupport_SignatureVerifier_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ConsenterSupport_SignatureVerifier_Call) Return(_a0 protoutil.BlockVerifierFunc) *ConsenterSupport_SignatureVerifier_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ConsenterSupport_SignatureVerifier_Call) RunAndReturn(run func() protoutil.BlockVerifierFunc) *ConsenterSupport_SignatureVerifier_Call { + _c.Call.Return(run) + return _c +} + +// WriteBlock provides a mock function with given fields: block, encodedMetadataValue +func (_m *ConsenterSupport) WriteBlock(block *common.Block, encodedMetadataValue []byte) { + _m.Called(block, encodedMetadataValue) +} + +// ConsenterSupport_WriteBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteBlock' +type ConsenterSupport_WriteBlock_Call struct { + *mock.Call +} + +// WriteBlock is a helper method to define mock.On call +// - block *common.Block +// - encodedMetadataValue []byte +func (_e *ConsenterSupport_Expecter) WriteBlock(block interface{}, encodedMetadataValue interface{}) *ConsenterSupport_WriteBlock_Call { + return &ConsenterSupport_WriteBlock_Call{Call: _e.mock.On("WriteBlock", block, encodedMetadataValue)} +} + +func (_c *ConsenterSupport_WriteBlock_Call) Run(run func(block *common.Block, encodedMetadataValue []byte)) *ConsenterSupport_WriteBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Block), args[1].([]byte)) + }) + return _c +} + +func (_c *ConsenterSupport_WriteBlock_Call) Return() *ConsenterSupport_WriteBlock_Call { + _c.Call.Return() + return _c +} + +func (_c *ConsenterSupport_WriteBlock_Call) RunAndReturn(run func(*common.Block, []byte)) *ConsenterSupport_WriteBlock_Call { + _c.Call.Return(run) + return _c +} + +// WriteConfigBlock provides a mock function with given fields: block, encodedMetadataValue +func (_m *ConsenterSupport) WriteConfigBlock(block *common.Block, encodedMetadataValue []byte) { + _m.Called(block, encodedMetadataValue) +} + +// ConsenterSupport_WriteConfigBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteConfigBlock' +type ConsenterSupport_WriteConfigBlock_Call struct { + *mock.Call +} + +// WriteConfigBlock is a helper method to define mock.On call +// - block *common.Block +// - encodedMetadataValue []byte +func (_e *ConsenterSupport_Expecter) WriteConfigBlock(block interface{}, encodedMetadataValue interface{}) *ConsenterSupport_WriteConfigBlock_Call { + return &ConsenterSupport_WriteConfigBlock_Call{Call: _e.mock.On("WriteConfigBlock", block, encodedMetadataValue)} +} + +func (_c *ConsenterSupport_WriteConfigBlock_Call) Run(run func(block *common.Block, encodedMetadataValue []byte)) *ConsenterSupport_WriteConfigBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*common.Block), args[1].([]byte)) + }) + return _c +} + +func (_c *ConsenterSupport_WriteConfigBlock_Call) Return() *ConsenterSupport_WriteConfigBlock_Call { + _c.Call.Return() + return _c +} + +func (_c *ConsenterSupport_WriteConfigBlock_Call) RunAndReturn(run func(*common.Block, []byte)) *ConsenterSupport_WriteConfigBlock_Call { + _c.Call.Return(run) + return _c +} + +// NewConsenterSupport creates a new instance of ConsenterSupport. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConsenterSupport(t interface { + mock.TestingT + Cleanup(func()) +}) *ConsenterSupport { + mock := &ConsenterSupport{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/egress_comm.go b/orderer/consensus/smartbft/mocks/egress_comm.go new file mode 100644 index 00000000000..73497cf052e --- /dev/null +++ b/orderer/consensus/smartbft/mocks/egress_comm.go @@ -0,0 +1,151 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + smartbftprotos "github.com/SmartBFT-Go/consensus/smartbftprotos" +) + +// EgressComm is an autogenerated mock type for the EgressComm type +type EgressComm struct { + mock.Mock +} + +type EgressComm_Expecter struct { + mock *mock.Mock +} + +func (_m *EgressComm) EXPECT() *EgressComm_Expecter { + return &EgressComm_Expecter{mock: &_m.Mock} +} + +// Nodes provides a mock function with given fields: +func (_m *EgressComm) Nodes() []uint64 { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Nodes") + } + + var r0 []uint64 + if rf, ok := ret.Get(0).(func() []uint64); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint64) + } + } + + return r0 +} + +// EgressComm_Nodes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Nodes' +type EgressComm_Nodes_Call struct { + *mock.Call +} + +// Nodes is a helper method to define mock.On call +func (_e *EgressComm_Expecter) Nodes() *EgressComm_Nodes_Call { + return &EgressComm_Nodes_Call{Call: _e.mock.On("Nodes")} +} + +func (_c *EgressComm_Nodes_Call) Run(run func()) *EgressComm_Nodes_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgressComm_Nodes_Call) Return(_a0 []uint64) *EgressComm_Nodes_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgressComm_Nodes_Call) RunAndReturn(run func() []uint64) *EgressComm_Nodes_Call { + _c.Call.Return(run) + return _c +} + +// SendConsensus provides a mock function with given fields: targetID, m +func (_m *EgressComm) SendConsensus(targetID uint64, m *smartbftprotos.Message) { + _m.Called(targetID, m) +} + +// EgressComm_SendConsensus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendConsensus' +type EgressComm_SendConsensus_Call struct { + *mock.Call +} + +// SendConsensus is a helper method to define mock.On call +// - targetID uint64 +// - m *smartbftprotos.Message +func (_e *EgressComm_Expecter) SendConsensus(targetID interface{}, m interface{}) *EgressComm_SendConsensus_Call { + return &EgressComm_SendConsensus_Call{Call: _e.mock.On("SendConsensus", targetID, m)} +} + +func (_c *EgressComm_SendConsensus_Call) Run(run func(targetID uint64, m *smartbftprotos.Message)) *EgressComm_SendConsensus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(*smartbftprotos.Message)) + }) + return _c +} + +func (_c *EgressComm_SendConsensus_Call) Return() *EgressComm_SendConsensus_Call { + _c.Call.Return() + return _c +} + +func (_c *EgressComm_SendConsensus_Call) RunAndReturn(run func(uint64, *smartbftprotos.Message)) *EgressComm_SendConsensus_Call { + _c.Call.Return(run) + return _c +} + +// SendTransaction provides a mock function with given fields: targetID, request +func (_m *EgressComm) SendTransaction(targetID uint64, request []byte) { + _m.Called(targetID, request) +} + +// EgressComm_SendTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendTransaction' +type EgressComm_SendTransaction_Call struct { + *mock.Call +} + +// SendTransaction is a helper method to define mock.On call +// - targetID uint64 +// - request []byte +func (_e *EgressComm_Expecter) SendTransaction(targetID interface{}, request interface{}) *EgressComm_SendTransaction_Call { + return &EgressComm_SendTransaction_Call{Call: _e.mock.On("SendTransaction", targetID, request)} +} + +func (_c *EgressComm_SendTransaction_Call) Run(run func(targetID uint64, request []byte)) *EgressComm_SendTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].([]byte)) + }) + return _c +} + +func (_c *EgressComm_SendTransaction_Call) Return() *EgressComm_SendTransaction_Call { + _c.Call.Return() + return _c +} + +func (_c *EgressComm_SendTransaction_Call) RunAndReturn(run func(uint64, []byte)) *EgressComm_SendTransaction_Call { + _c.Call.Return(run) + return _c +} + +// NewEgressComm creates a new instance of EgressComm. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEgressComm(t interface { + mock.TestingT + Cleanup(func()) +}) *EgressComm { + mock := &EgressComm{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/policy.go b/orderer/consensus/smartbft/mocks/policy.go new file mode 100644 index 00000000000..7a0b51b76d3 --- /dev/null +++ b/orderer/consensus/smartbft/mocks/policy.go @@ -0,0 +1,129 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + msp "github.com/hyperledger/fabric/msp" + mock "github.com/stretchr/testify/mock" + + protoutil "github.com/hyperledger/fabric/protoutil" +) + +// Policy is an autogenerated mock type for the Policy type +type Policy struct { + mock.Mock +} + +type Policy_Expecter struct { + mock *mock.Mock +} + +func (_m *Policy) EXPECT() *Policy_Expecter { + return &Policy_Expecter{mock: &_m.Mock} +} + +// EvaluateIdentities provides a mock function with given fields: identities +func (_m *Policy) EvaluateIdentities(identities []msp.Identity) error { + ret := _m.Called(identities) + + if len(ret) == 0 { + panic("no return value specified for EvaluateIdentities") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]msp.Identity) error); ok { + r0 = rf(identities) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Policy_EvaluateIdentities_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EvaluateIdentities' +type Policy_EvaluateIdentities_Call struct { + *mock.Call +} + +// EvaluateIdentities is a helper method to define mock.On call +// - identities []msp.Identity +func (_e *Policy_Expecter) EvaluateIdentities(identities interface{}) *Policy_EvaluateIdentities_Call { + return &Policy_EvaluateIdentities_Call{Call: _e.mock.On("EvaluateIdentities", identities)} +} + +func (_c *Policy_EvaluateIdentities_Call) Run(run func(identities []msp.Identity)) *Policy_EvaluateIdentities_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]msp.Identity)) + }) + return _c +} + +func (_c *Policy_EvaluateIdentities_Call) Return(_a0 error) *Policy_EvaluateIdentities_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Policy_EvaluateIdentities_Call) RunAndReturn(run func([]msp.Identity) error) *Policy_EvaluateIdentities_Call { + _c.Call.Return(run) + return _c +} + +// EvaluateSignedData provides a mock function with given fields: signatureSet +func (_m *Policy) EvaluateSignedData(signatureSet []*protoutil.SignedData) error { + ret := _m.Called(signatureSet) + + if len(ret) == 0 { + panic("no return value specified for EvaluateSignedData") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]*protoutil.SignedData) error); ok { + r0 = rf(signatureSet) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Policy_EvaluateSignedData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EvaluateSignedData' +type Policy_EvaluateSignedData_Call struct { + *mock.Call +} + +// EvaluateSignedData is a helper method to define mock.On call +// - signatureSet []*protoutil.SignedData +func (_e *Policy_Expecter) EvaluateSignedData(signatureSet interface{}) *Policy_EvaluateSignedData_Call { + return &Policy_EvaluateSignedData_Call{Call: _e.mock.On("EvaluateSignedData", signatureSet)} +} + +func (_c *Policy_EvaluateSignedData_Call) Run(run func(signatureSet []*protoutil.SignedData)) *Policy_EvaluateSignedData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]*protoutil.SignedData)) + }) + return _c +} + +func (_c *Policy_EvaluateSignedData_Call) Return(_a0 error) *Policy_EvaluateSignedData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Policy_EvaluateSignedData_Call) RunAndReturn(run func([]*protoutil.SignedData) error) *Policy_EvaluateSignedData_Call { + _c.Call.Return(run) + return _c +} + +// NewPolicy creates a new instance of Policy. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPolicy(t interface { + mock.TestingT + Cleanup(func()) +}) *Policy { + mock := &Policy{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/policy_manager.go b/orderer/consensus/smartbft/mocks/policy_manager.go new file mode 100644 index 00000000000..ce76f579895 --- /dev/null +++ b/orderer/consensus/smartbft/mocks/policy_manager.go @@ -0,0 +1,151 @@ +// Code generated by mockery v2.40.1. DO NOT EDIT. + +package mocks + +import ( + policies "github.com/hyperledger/fabric/common/policies" + mock "github.com/stretchr/testify/mock" +) + +// PolicyManager is an autogenerated mock type for the PolicyManager type +type PolicyManager struct { + mock.Mock +} + +type PolicyManager_Expecter struct { + mock *mock.Mock +} + +func (_m *PolicyManager) EXPECT() *PolicyManager_Expecter { + return &PolicyManager_Expecter{mock: &_m.Mock} +} + +// GetPolicy provides a mock function with given fields: id +func (_m *PolicyManager) GetPolicy(id string) (policies.Policy, bool) { + ret := _m.Called(id) + + if len(ret) == 0 { + panic("no return value specified for GetPolicy") + } + + var r0 policies.Policy + var r1 bool + if rf, ok := ret.Get(0).(func(string) (policies.Policy, bool)); ok { + return rf(id) + } + if rf, ok := ret.Get(0).(func(string) policies.Policy); ok { + r0 = rf(id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(policies.Policy) + } + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(id) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// PolicyManager_GetPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPolicy' +type PolicyManager_GetPolicy_Call struct { + *mock.Call +} + +// GetPolicy is a helper method to define mock.On call +// - id string +func (_e *PolicyManager_Expecter) GetPolicy(id interface{}) *PolicyManager_GetPolicy_Call { + return &PolicyManager_GetPolicy_Call{Call: _e.mock.On("GetPolicy", id)} +} + +func (_c *PolicyManager_GetPolicy_Call) Run(run func(id string)) *PolicyManager_GetPolicy_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *PolicyManager_GetPolicy_Call) Return(_a0 policies.Policy, _a1 bool) *PolicyManager_GetPolicy_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *PolicyManager_GetPolicy_Call) RunAndReturn(run func(string) (policies.Policy, bool)) *PolicyManager_GetPolicy_Call { + _c.Call.Return(run) + return _c +} + +// Manager provides a mock function with given fields: path +func (_m *PolicyManager) Manager(path []string) (policies.Manager, bool) { + ret := _m.Called(path) + + if len(ret) == 0 { + panic("no return value specified for Manager") + } + + var r0 policies.Manager + var r1 bool + if rf, ok := ret.Get(0).(func([]string) (policies.Manager, bool)); ok { + return rf(path) + } + if rf, ok := ret.Get(0).(func([]string) policies.Manager); ok { + r0 = rf(path) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(policies.Manager) + } + } + + if rf, ok := ret.Get(1).(func([]string) bool); ok { + r1 = rf(path) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// PolicyManager_Manager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Manager' +type PolicyManager_Manager_Call struct { + *mock.Call +} + +// Manager is a helper method to define mock.On call +// - path []string +func (_e *PolicyManager_Expecter) Manager(path interface{}) *PolicyManager_Manager_Call { + return &PolicyManager_Manager_Call{Call: _e.mock.On("Manager", path)} +} + +func (_c *PolicyManager_Manager_Call) Run(run func(path []string)) *PolicyManager_Manager_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]string)) + }) + return _c +} + +func (_c *PolicyManager_Manager_Call) Return(_a0 policies.Manager, _a1 bool) *PolicyManager_Manager_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *PolicyManager_Manager_Call) RunAndReturn(run func([]string) (policies.Manager, bool)) *PolicyManager_Manager_Call { + _c.Call.Return(run) + return _c +} + +// NewPolicyManager creates a new instance of PolicyManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPolicyManager(t interface { + mock.TestingT + Cleanup(func()) +}) *PolicyManager { + mock := &PolicyManager{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/orderer/consensus/smartbft/mocks/signer_serializer.go b/orderer/consensus/smartbft/mocks/signer_serializer.go index 439a3a0deb3..01b7a0351cb 100644 --- a/orderer/consensus/smartbft/mocks/signer_serializer.go +++ b/orderer/consensus/smartbft/mocks/signer_serializer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.1. DO NOT EDIT. +// Code generated by mockery v2.40.1. DO NOT EDIT. package mocks @@ -9,11 +9,27 @@ type SignerSerializer struct { mock.Mock } +type SignerSerializer_Expecter struct { + mock *mock.Mock +} + +func (_m *SignerSerializer) EXPECT() *SignerSerializer_Expecter { + return &SignerSerializer_Expecter{mock: &_m.Mock} +} + // Serialize provides a mock function with given fields: func (_m *SignerSerializer) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() } else { @@ -22,7 +38,6 @@ func (_m *SignerSerializer) Serialize() ([]byte, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -32,11 +47,46 @@ func (_m *SignerSerializer) Serialize() ([]byte, error) { return r0, r1 } +// SignerSerializer_Serialize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Serialize' +type SignerSerializer_Serialize_Call struct { + *mock.Call +} + +// Serialize is a helper method to define mock.On call +func (_e *SignerSerializer_Expecter) Serialize() *SignerSerializer_Serialize_Call { + return &SignerSerializer_Serialize_Call{Call: _e.mock.On("Serialize")} +} + +func (_c *SignerSerializer_Serialize_Call) Run(run func()) *SignerSerializer_Serialize_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SignerSerializer_Serialize_Call) Return(_a0 []byte, _a1 error) *SignerSerializer_Serialize_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SignerSerializer_Serialize_Call) RunAndReturn(run func() ([]byte, error)) *SignerSerializer_Serialize_Call { + _c.Call.Return(run) + return _c +} + // Sign provides a mock function with given fields: message func (_m *SignerSerializer) Sign(message []byte) ([]byte, error) { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Sign") + } + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func([]byte) ([]byte, error)); ok { + return rf(message) + } if rf, ok := ret.Get(0).(func([]byte) []byte); ok { r0 = rf(message) } else { @@ -45,7 +95,6 @@ func (_m *SignerSerializer) Sign(message []byte) ([]byte, error) { } } - var r1 error if rf, ok := ret.Get(1).(func([]byte) error); ok { r1 = rf(message) } else { @@ -55,13 +104,40 @@ func (_m *SignerSerializer) Sign(message []byte) ([]byte, error) { return r0, r1 } -type mockConstructorTestingTNewSignerSerializer interface { - mock.TestingT - Cleanup(func()) +// SignerSerializer_Sign_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sign' +type SignerSerializer_Sign_Call struct { + *mock.Call +} + +// Sign is a helper method to define mock.On call +// - message []byte +func (_e *SignerSerializer_Expecter) Sign(message interface{}) *SignerSerializer_Sign_Call { + return &SignerSerializer_Sign_Call{Call: _e.mock.On("Sign", message)} +} + +func (_c *SignerSerializer_Sign_Call) Run(run func(message []byte)) *SignerSerializer_Sign_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]byte)) + }) + return _c +} + +func (_c *SignerSerializer_Sign_Call) Return(_a0 []byte, _a1 error) *SignerSerializer_Sign_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SignerSerializer_Sign_Call) RunAndReturn(run func([]byte) ([]byte, error)) *SignerSerializer_Sign_Call { + _c.Call.Return(run) + return _c } // NewSignerSerializer creates a new instance of SignerSerializer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewSignerSerializer(t mockConstructorTestingTNewSignerSerializer) *SignerSerializer { +// The first argument is typically a *testing.T value. +func NewSignerSerializer(t interface { + mock.TestingT + Cleanup(func()) +}) *SignerSerializer { mock := &SignerSerializer{} mock.Mock.Test(t) diff --git a/orderer/consensus/smartbft/signer.go b/orderer/consensus/smartbft/signer.go index 7a360752b9a..f13470314d2 100644 --- a/orderer/consensus/smartbft/signer.go +++ b/orderer/consensus/smartbft/signer.go @@ -14,7 +14,7 @@ import ( "github.com/hyperledger/fabric/protoutil" ) -//go:generate mockery -dir . -name SignerSerializer -case underscore -output ./mocks/ +//go:generate mockery --dir . --name SignerSerializer --case underscore --with-expecter=true --output mocks // SignerSerializer signs messages and serializes identities type SignerSerializer interface { diff --git a/orderer/consensus/smartbft/util_network_test.go b/orderer/consensus/smartbft/util_network_test.go new file mode 100644 index 00000000000..89d188dfbc3 --- /dev/null +++ b/orderer/consensus/smartbft/util_network_test.go @@ -0,0 +1,479 @@ +// Copyright IBM Corp. All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 + +package smartbft_test + +import ( + "errors" + "fmt" + "os" + "path" + "path/filepath" + "reflect" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/hyperledger/fabric/orderer/common/localconfig" + + "github.com/SmartBFT-Go/consensus/smartbftprotos" + "github.com/hyperledger/fabric/common/policies" + + "github.com/SmartBFT-Go/consensus/pkg/api" + "github.com/SmartBFT-Go/consensus/pkg/types" + "github.com/SmartBFT-Go/consensus/pkg/wal" + "github.com/hyperledger/fabric-lib-go/bccsp/sw" + "github.com/hyperledger/fabric-lib-go/common/metrics/disabled" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric/common/crypto/tlsgen" + "github.com/hyperledger/fabric/core/config/configtest" + "github.com/hyperledger/fabric/internal/configtxgen/encoder" + "github.com/hyperledger/fabric/internal/configtxgen/genesisconfig" + "github.com/hyperledger/fabric/orderer/consensus/smartbft" + smartBFTMocks "github.com/hyperledger/fabric/orderer/consensus/smartbft/mocks" + "github.com/hyperledger/fabric/protoutil" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +type NetworkSetupInfo struct { + t *testing.T + nodeIdToNode map[uint64]*Node + dir string + channelId string +} + +func NewNetworkSetupInfo(t *testing.T, channelId string, rootDir string) *NetworkSetupInfo { + return &NetworkSetupInfo{ + t: t, + nodeIdToNode: map[uint64]*Node{}, + dir: rootDir, + channelId: channelId, + } +} + +func (ns *NetworkSetupInfo) CreateNodes(numberOfNodes int) map[uint64]*Node { + var nodeIds []uint64 + for nodeId := uint64(1); nodeId <= uint64(numberOfNodes); nodeId++ { + nodeIds = append(nodeIds, nodeId) + } + nodeIdToNode := map[uint64]*Node{} + genesisBlock := createConfigBlock(ns.t, ns.channelId) + for _, nodeId := range nodeIds { + nodeIdToNode[nodeId] = NewNode(ns.t, nodeId, ns.dir, ns.channelId, genesisBlock) + } + ns.nodeIdToNode = nodeIdToNode + + // update all nodes about the nodes map + for _, nodeId := range nodeIds { + nodeIdToNode[nodeId].nodesMap = nodeIdToNode + } + return nodeIdToNode +} + +func (ns *NetworkSetupInfo) StartAllNodes() { + ns.t.Logf("Starting nodes in the network") + for _, node := range ns.nodeIdToNode { + node.Start() + } +} + +func (ns *NetworkSetupInfo) SendTxToAllAvailableNodes(tx *cb.Envelope) error { + var errorsArr []error + for idx, node := range ns.nodeIdToNode { + if !node.IsAvailable() { + continue + } + ns.t.Logf("Sending tx to node %v", idx) + err := node.SendTx(tx) + if err != nil { + ns.t.Logf("Error occured during sending tx to node %v: %v", idx, err) + } + errorsArr = append(errorsArr, err) + } + return errors.Join(errorsArr...) +} + +type Node struct { + t *testing.T + NodeId uint64 + ChannelId string + WorkingDir string + Chain *smartbft.BFTChain + State *NodeState + IsStarted bool + IsConnectedToNetwork bool + nodesMap map[uint64]*Node + Endpoint string + lock sync.RWMutex +} + +func NewNode(t *testing.T, nodeId uint64, rootDir string, channelId string, genesisBlock *cb.Block) *Node { + t.Logf("Creating node %d", nodeId) + nodeWorkingDir := filepath.Join(rootDir, fmt.Sprintf("node-%d", nodeId)) + + t.Logf("Creating working directory for node %d: %s", nodeId, nodeWorkingDir) + err := os.Mkdir(nodeWorkingDir, os.ModePerm) + require.NoError(t, err) + + t.Log("Creating chain") + node := &Node{ + t: t, + NodeId: nodeId, + ChannelId: channelId, + WorkingDir: nodeWorkingDir, + State: NewNodeState(t, nodeId, channelId, genesisBlock), + IsStarted: false, + IsConnectedToNetwork: false, + Endpoint: fmt.Sprintf("%s:%d", "localhost", 9000+nodeId), + } + + node.Chain, err = createBFTChainUsingMocks(t, node) + require.NoError(t, err) + return node +} + +func (n *Node) Start() { + n.lock.Lock() + defer n.lock.Unlock() + n.Chain.Start() + n.IsConnectedToNetwork = true + n.IsStarted = true +} + +func (n *Node) IsAvailable() bool { + n.lock.RLock() + defer n.lock.RUnlock() + return n.IsStarted && n.IsConnectedToNetwork +} + +func (n *Node) SendTx(tx *cb.Envelope) error { + n.lock.RLock() + defer n.lock.RUnlock() + return n.Chain.Order(tx, n.State.Sequence) +} + +func (n *Node) sendMessage(sender uint64, target uint64, message *smartbftprotos.Message) error { + n.lock.RLock() + targetNode, exists := n.nodesMap[target] + n.lock.RUnlock() + if !exists { + return fmt.Errorf("target node %d does not exist", target) + } + targetNode.receiveMessage(sender, message) + return nil +} + +func (n *Node) sendRequest(sender uint64, target uint64, request []byte) error { + n.lock.RLock() + targetNode, exists := n.nodesMap[target] + n.lock.RUnlock() + if !exists { + return fmt.Errorf("target node %d does not exist", target) + } + targetNode.receiveRequest(sender, request) + return nil +} + +func (n *Node) receiveMessage(sender uint64, message *smartbftprotos.Message) { + n.lock.Lock() + defer n.lock.Unlock() + n.Chain.HandleMessage(sender, message) +} + +func (n *Node) receiveRequest(sender uint64, request []byte) { + n.lock.Lock() + defer n.lock.Unlock() + n.Chain.HandleRequest(sender, request) +} + +func (n *Node) HeightsByEndpoints() map[string]uint64 { + n.lock.RLock() + defer n.lock.RUnlock() + nodeEndpointToHeight := map[string]uint64{} + for _, node := range n.nodesMap { + if !node.IsAvailable() { + continue + } + nodeEndpointToHeight[node.Endpoint] = uint64(node.State.GetLedgerHeight()) + } + return nodeEndpointToHeight +} + +type NodeState struct { + NodeId uint64 + ledgerArray []*cb.Block + Sequence uint64 + lock sync.RWMutex + t *testing.T +} + +func NewNodeState(t *testing.T, nodeId uint64, channelId string, genesisBlock *cb.Block) *NodeState { + return &NodeState{ + NodeId: nodeId, + ledgerArray: []*cb.Block{genesisBlock}, + Sequence: 0, + t: t, + } +} + +func (ns *NodeState) AddBlock(block *cb.Block) { + ns.lock.Lock() + defer ns.lock.Unlock() + ns.ledgerArray = append(ns.ledgerArray, block) +} + +func (ns *NodeState) GetBlock(idx uint64) *cb.Block { + ns.lock.RLock() + defer ns.lock.RUnlock() + return ns.ledgerArray[idx] +} + +func (ns *NodeState) GetLastBlock() *cb.Block { + ns.lock.RLock() + defer ns.lock.RUnlock() + return ns.ledgerArray[len(ns.ledgerArray)-1] +} + +func (ns *NodeState) GetLedgerHeight() int { + ns.lock.Lock() + defer ns.lock.Unlock() + return len(ns.ledgerArray) +} + +func (ns *NodeState) WaitLedgerHeightToBe(height int) { + require.Eventually(ns.t, func() bool { return ns.GetLedgerHeight() == height }, 30*time.Second, 100*time.Millisecond) +} + +// createBFTChainUsingMocks creates a new bft chain which is exposed to all nodes in the network. +// the chain is created using mocks and is useful for testing +func createBFTChainUsingMocks(t *testing.T, node *Node) (*smartbft.BFTChain, error) { + nodeId := node.NodeId + channelId := node.ChannelId + + config := createBFTConfiguration(node) + + blockPuller := smartBFTMocks.NewBlockPuller(t) + blockPuller.EXPECT().Close().Maybe() + blockPuller.EXPECT().HeightsByEndpoints().RunAndReturn( + func() (map[string]uint64, string, error) { + return node.HeightsByEndpoints(), node.Endpoint, nil + }).Maybe() + blockPuller.EXPECT().PullBlock(mock.Anything).RunAndReturn( + func(seq uint64) *cb.Block { + t.Logf("Node %d reqested PullBlock %d, returning nil", node.NodeId, seq) + return nil + }).Maybe() + + configValidatorMock := smartBFTMocks.NewConfigValidator(t) + + comm := smartBFTMocks.NewCommunicator(t) + comm.EXPECT().Configure(mock.Anything, mock.Anything) + + signerSerializerMock := smartBFTMocks.NewSignerSerializer(t) + signerSerializerMock.EXPECT().Sign(mock.Anything).RunAndReturn( + func(message []byte) ([]byte, error) { + return message, nil + }).Maybe() + + policyManagerMock := smartBFTMocks.NewPolicyManager(t) + noErrorPolicyMock := smartBFTMocks.NewPolicy(t) + noErrorPolicyMock.EXPECT().EvaluateSignedData(mock.Anything).Return(nil).Maybe() + noErrorPolicyMock.EXPECT().EvaluateSignedData(mock.Anything).Return(nil).Maybe() + policyManagerMock.EXPECT().GetPolicy(mock.AnythingOfType("string")).RunAndReturn( + func(s string) (policies.Policy, bool) { + return noErrorPolicyMock, true + }).Maybe() + + // the number of blocks is determined by the number of blocks in the node's ledger + supportMock := smartBFTMocks.NewConsenterSupport(t) + supportMock.EXPECT().ChannelID().Return(channelId) + supportMock.EXPECT().Height().Return(uint64(node.State.GetLedgerHeight())) + supportMock.EXPECT().Block(mock.AnythingOfType("uint64")).RunAndReturn( + func(blockIdx uint64) *cb.Block { + return node.State.GetBlock(blockIdx) + }) + supportMock.EXPECT().Sequence().RunAndReturn( + func() uint64 { + return node.State.Sequence + }) + supportMock.EXPECT().WriteBlock(mock.Anything, mock.Anything).Run( + func(block *cb.Block, encodedMetadataValue []byte) { + node.State.AddBlock(block) + }).Maybe() + + supportMock.EXPECT().WriteConfigBlock(mock.Anything, mock.Anything).Run( + func(block *cb.Block, encodedMetadataValue []byte) { + node.State.AddBlock(block) + }).Maybe() + + mpc := &smartbft.MetricProviderConverter{MetricsProvider: &disabled.Provider{}} + metricsBFT := api.NewMetrics(mpc, channelId) + metricsWalBFT := wal.NewMetrics(mpc, channelId) + + cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore()) + require.NoError(t, err) + + egressCommMock := smartBFTMocks.NewEgressComm(t) + egressCommMock.EXPECT().Nodes().RunAndReturn( + func() []uint64 { + var nodeIds []uint64 + for nodeId := range node.nodesMap { + nodeIds = append(nodeIds, nodeId) + } + return nodeIds + }).Maybe() + egressCommMock.EXPECT().SendTransaction(mock.Anything, mock.Anything).Run( + func(targetNodeId uint64, message []byte) { + t.Logf("Node %d requested SendTransaction to node %d", node.NodeId, targetNodeId) + err := node.sendRequest(node.NodeId, targetNodeId, message) + require.NoError(t, err) + }).Maybe() + egressCommMock.EXPECT().SendConsensus(mock.Anything, mock.Anything).Run( + func(targetNodeId uint64, message *smartbftprotos.Message) { + t.Logf("Node %d requested SendConsensus to node %d of type <%s>", node.NodeId, targetNodeId, reflect.TypeOf(message.GetContent())) + err = node.sendMessage(node.NodeId, targetNodeId, message) + require.NoError(t, err) + }).Maybe() + + egressCommFactory := func(runtimeConfig *atomic.Value, channelId string, comm smartbft.Communicator) smartbft.EgressComm { + return egressCommMock + } + + localConfigCluster := localconfig.Cluster{ReplicationPolicy: "simple"} + + bftChain, err := smartbft.NewChain( + configValidatorMock, + nodeId, + config, + node.WorkingDir, + blockPuller, + nil, + localConfigCluster, + comm, + signerSerializerMock, + policyManagerMock, + supportMock, + smartbft.NewMetrics(&disabled.Provider{}), + metricsBFT, + metricsWalBFT, + cryptoProvider, + egressCommFactory) + + require.NoError(t, err) + require.NotNil(t, bftChain) + + return bftChain, nil +} + +// createConfigBlock creates the genesis block. This is the first block in the ledger of all nodes. +func createConfigBlock(t *testing.T, channelId string) *cb.Block { + certDir := t.TempDir() + tlsCA, err := tlsgen.NewCA() + require.NoError(t, err) + configProfile := genesisconfig.Load(genesisconfig.SampleAppChannelSmartBftProfile, configtest.GetDevConfigDir()) + tlsCertPath := filepath.Join(configtest.GetDevConfigDir(), "msp", "tlscacerts", "tlsroot.pem") + + // make all BFT nodes belong to the same MSP ID + for _, consenter := range configProfile.Orderer.ConsenterMapping { + consenter.MSPID = "SampleOrg" + consenter.Identity = tlsCertPath + consenter.ClientTLSCert = tlsCertPath + consenter.ServerTLSCert = tlsCertPath + } + + generateCertificatesSmartBFT(t, configProfile, tlsCA, certDir) + + channelGroup, err := encoder.NewChannelGroup(configProfile) + require.NoError(t, err) + require.NotNil(t, channelGroup) + + _, err = sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore()) + require.NoError(t, err) + + block := blockWithGroups(channelGroup, channelId, 0) + return block +} + +func generateCertificatesSmartBFT(t *testing.T, confAppSmartBFT *genesisconfig.Profile, tlsCA tlsgen.CA, certDir string) { + for i, c := range confAppSmartBFT.Orderer.ConsenterMapping { + t.Logf("BFT Consenter: %+v", c) + srvC, err := tlsCA.NewServerCertKeyPair(c.Host) + require.NoError(t, err) + srvP := path.Join(certDir, fmt.Sprintf("server%d.crt", i)) + err = os.WriteFile(srvP, srvC.Cert, 0o644) + require.NoError(t, err) + + clnC, err := tlsCA.NewClientCertKeyPair() + require.NoError(t, err) + clnP := path.Join(certDir, fmt.Sprintf("client%d.crt", i)) + err = os.WriteFile(clnP, clnC.Cert, 0o644) + require.NoError(t, err) + + c.Identity = srvP + c.ServerTLSCert = srvP + c.ClientTLSCert = clnP + } +} + +func blockWithGroups(groups *cb.ConfigGroup, channelID string, blockNumber uint64) *cb.Block { + block := protoutil.NewBlock(blockNumber, nil) + block.Data = &cb.BlockData{ + Data: [][]byte{ + protoutil.MarshalOrPanic(&cb.Envelope{ + Payload: protoutil.MarshalOrPanic(&cb.Payload{ + Data: protoutil.MarshalOrPanic(&cb.ConfigEnvelope{ + Config: &cb.Config{ + Sequence: uint64(0), + ChannelGroup: groups, + }, + }), + Header: &cb.Header{ + ChannelHeader: protoutil.MarshalOrPanic(&cb.ChannelHeader{ + Type: int32(cb.HeaderType_CONFIG), + ChannelId: channelID, + }), + }, + }), + }), + }, + } + block.Header.DataHash = protoutil.ComputeBlockDataHash(block.Data) + block.Metadata.Metadata[cb.BlockMetadataIndex_SIGNATURES] = protoutil.MarshalOrPanic(&cb.Metadata{ + Value: protoutil.MarshalOrPanic(&cb.OrdererBlockMetadata{ + LastConfig: &cb.LastConfig{ + Index: uint64(blockNumber), + }, + }), + }) + + return block +} + +func createBFTConfiguration(node *Node) types.Configuration { + return types.Configuration{ + SelfID: node.NodeId, + RequestBatchMaxCount: 100, + RequestBatchMaxBytes: 10485760, + RequestBatchMaxInterval: 50 * time.Millisecond, + IncomingMessageBufferSize: 200, + RequestPoolSize: 400, + RequestForwardTimeout: 2 * time.Second, + RequestComplainTimeout: 20 * time.Second, + RequestAutoRemoveTimeout: 3 * time.Minute, + ViewChangeResendInterval: 5 * time.Second, + ViewChangeTimeout: 20 * time.Second, + LeaderHeartbeatTimeout: 1 * time.Minute, + LeaderHeartbeatCount: 10, + NumOfTicksBehindBeforeSyncing: types.DefaultConfig.NumOfTicksBehindBeforeSyncing, + CollectTimeout: 1 * time.Second, + SyncOnStart: types.DefaultConfig.SyncOnStart, + SpeedUpViewChange: types.DefaultConfig.SpeedUpViewChange, + LeaderRotation: types.DefaultConfig.LeaderRotation, + DecisionsPerLeader: types.DefaultConfig.DecisionsPerLeader, + RequestMaxBytes: types.DefaultConfig.RequestMaxBytes, + RequestPoolSubmitTimeout: types.DefaultConfig.RequestPoolSubmitTimeout, + } +}