github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/gossip/state/mocks/gossip.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package mocks 8 9 import ( 10 "github.com/hechain20/hechain/gossip/api" 11 "github.com/hechain20/hechain/gossip/comm" 12 "github.com/hechain20/hechain/gossip/common" 13 "github.com/hechain20/hechain/gossip/discovery" 14 "github.com/hechain20/hechain/gossip/filter" 15 "github.com/hechain20/hechain/gossip/gossip" 16 "github.com/hechain20/hechain/gossip/protoext" 17 proto "github.com/hyperledger/fabric-protos-go/gossip" 18 "github.com/stretchr/testify/mock" 19 ) 20 21 type GossipMock struct { 22 mock.Mock 23 } 24 25 func (g *GossipMock) SelfMembershipInfo() discovery.NetworkMember { 26 panic("implement me") 27 } 28 29 func (g *GossipMock) SelfChannelInfo(common.ChannelID) *protoext.SignedGossipMessage { 30 panic("implement me") 31 } 32 33 func (*GossipMock) PeerFilter(channel common.ChannelID, messagePredicate api.SubChannelSelectionCriteria) (filter.RoutingFilter, error) { 34 panic("implement me") 35 } 36 37 func (g *GossipMock) SuspectPeers(s api.PeerSuspector) { 38 g.Called(s) 39 } 40 41 // UpdateLedgerHeight updates the ledger height the peer 42 // publishes to other peers in the channel 43 func (g *GossipMock) UpdateLedgerHeight(height uint64, channelID common.ChannelID) { 44 } 45 46 // UpdateChaincodes updates the chaincodes the peer publishes 47 // to other peers in the channel 48 func (g *GossipMock) UpdateChaincodes(chaincode []*proto.Chaincode, channelID common.ChannelID) { 49 } 50 51 func (g *GossipMock) LeaveChan(_ common.ChannelID) { 52 panic("implement me") 53 } 54 55 func (g *GossipMock) Send(msg *proto.GossipMessage, peers ...*comm.RemotePeer) { 56 g.Called(msg, peers) 57 } 58 59 func (g *GossipMock) Peers() []discovery.NetworkMember { 60 return g.Called().Get(0).([]discovery.NetworkMember) 61 } 62 63 func (g *GossipMock) PeersOfChannel(channelID common.ChannelID) []discovery.NetworkMember { 64 args := g.Called(channelID) 65 return args.Get(0).([]discovery.NetworkMember) 66 } 67 68 func (g *GossipMock) UpdateMetadata(metadata []byte) { 69 g.Called(metadata) 70 } 71 72 func (g *GossipMock) Gossip(msg *proto.GossipMessage) { 73 g.Called(msg) 74 } 75 76 func (g *GossipMock) Accept(acceptor common.MessageAcceptor, passThrough bool) (<-chan *proto.GossipMessage, <-chan protoext.ReceivedMessage) { 77 args := g.Called(acceptor, passThrough) 78 if args.Get(0) == nil { 79 return nil, args.Get(1).(chan protoext.ReceivedMessage) 80 } 81 return args.Get(0).(<-chan *proto.GossipMessage), nil 82 } 83 84 func (g *GossipMock) JoinChan(joinMsg api.JoinChannelMessage, channelID common.ChannelID) { 85 } 86 87 // IdentityInfo returns information known peer identities 88 func (g *GossipMock) IdentityInfo() api.PeerIdentitySet { 89 panic("not implemented") 90 } 91 92 func (g *GossipMock) IsInMyOrg(member discovery.NetworkMember) bool { 93 panic("not implemented") 94 } 95 96 func (g *GossipMock) Stop() { 97 } 98 99 func (g *GossipMock) SendByCriteria(*protoext.SignedGossipMessage, gossip.SendCriteria) error { 100 return nil 101 }