github.com/kaituanwang/hyperledger@v2.0.1+incompatible/orderer/consensus/etcdraft/initialization_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package etcdraft_test 8 9 import ( 10 "testing" 11 12 "github.com/hyperledger/fabric/bccsp/sw" 13 "github.com/hyperledger/fabric/common/metrics/disabled" 14 "github.com/hyperledger/fabric/core/comm" 15 "github.com/hyperledger/fabric/orderer/common/cluster" 16 "github.com/hyperledger/fabric/orderer/common/localconfig" 17 "github.com/hyperledger/fabric/orderer/common/multichannel" 18 "github.com/hyperledger/fabric/orderer/consensus/etcdraft" 19 "github.com/hyperledger/fabric/orderer/consensus/etcdraft/mocks" 20 "github.com/stretchr/testify/assert" 21 ) 22 23 func TestNewEtcdRaftConsenter(t *testing.T) { 24 srv, err := comm.NewGRPCServer("127.0.0.1:0", comm.ServerConfig{}) 25 assert.NoError(t, err) 26 defer srv.Stop() 27 dialer := &cluster.PredicateDialer{} 28 cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore()) 29 assert.NoError(t, err) 30 consenter := etcdraft.New(dialer, 31 &localconfig.TopLevel{}, 32 comm.ServerConfig{ 33 SecOpts: comm.SecureOptions{ 34 Certificate: []byte{1, 2, 3}, 35 }, 36 }, srv, &multichannel.Registrar{}, 37 &mocks.InactiveChainRegistry{}, 38 &disabled.Provider{}, 39 cryptoProvider, 40 ) 41 42 // Assert that the certificate from the gRPC server was passed to the consenter 43 assert.Equal(t, []byte{1, 2, 3}, consenter.Cert) 44 // Assert that all dependencies for the consenter were populated 45 assert.NotNil(t, consenter.Communication) 46 assert.NotNil(t, consenter.Chains) 47 assert.NotNil(t, consenter.ChainSelector) 48 assert.NotNil(t, consenter.Dispatcher) 49 assert.NotNil(t, consenter.Logger) 50 }