github.com/Hnampk/fabric@v2.1.1+incompatible/gossip/state/mocks/gossip.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package mocks
     8  
     9  import (
    10  	proto "github.com/hyperledger/fabric-protos-go/gossip"
    11  	"github.com/hyperledger/fabric/gossip/api"
    12  	"github.com/hyperledger/fabric/gossip/comm"
    13  	"github.com/hyperledger/fabric/gossip/common"
    14  	"github.com/hyperledger/fabric/gossip/discovery"
    15  	"github.com/hyperledger/fabric/gossip/filter"
    16  	"github.com/hyperledger/fabric/gossip/gossip"
    17  	"github.com/hyperledger/fabric/gossip/protoext"
    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  
    47  // UpdateChaincodes updates the chaincodes the peer publishes
    48  // to other peers in the channel
    49  func (g *GossipMock) UpdateChaincodes(chaincode []*proto.Chaincode, channelID common.ChannelID) {
    50  
    51  }
    52  
    53  func (g *GossipMock) LeaveChan(_ common.ChannelID) {
    54  	panic("implement me")
    55  }
    56  
    57  func (g *GossipMock) Send(msg *proto.GossipMessage, peers ...*comm.RemotePeer) {
    58  	g.Called(msg, peers)
    59  }
    60  
    61  func (g *GossipMock) Peers() []discovery.NetworkMember {
    62  	return g.Called().Get(0).([]discovery.NetworkMember)
    63  }
    64  
    65  func (g *GossipMock) PeersOfChannel(channelID common.ChannelID) []discovery.NetworkMember {
    66  	args := g.Called(channelID)
    67  	return args.Get(0).([]discovery.NetworkMember)
    68  }
    69  
    70  func (g *GossipMock) UpdateMetadata(metadata []byte) {
    71  	g.Called(metadata)
    72  }
    73  
    74  func (g *GossipMock) Gossip(msg *proto.GossipMessage) {
    75  	g.Called(msg)
    76  }
    77  
    78  func (g *GossipMock) Accept(acceptor common.MessageAcceptor, passThrough bool) (<-chan *proto.GossipMessage, <-chan protoext.ReceivedMessage) {
    79  	args := g.Called(acceptor, passThrough)
    80  	if args.Get(0) == nil {
    81  		return nil, args.Get(1).(chan protoext.ReceivedMessage)
    82  	}
    83  	return args.Get(0).(<-chan *proto.GossipMessage), nil
    84  }
    85  
    86  func (g *GossipMock) JoinChan(joinMsg api.JoinChannelMessage, channelID common.ChannelID) {
    87  }
    88  
    89  // IdentityInfo returns information known peer identities
    90  func (g *GossipMock) IdentityInfo() api.PeerIdentitySet {
    91  	panic("not implemented")
    92  }
    93  
    94  func (g *GossipMock) IsInMyOrg(member discovery.NetworkMember) bool {
    95  	panic("not implemented")
    96  }
    97  
    98  func (g *GossipMock) Stop() {
    99  
   100  }
   101  
   102  func (g *GossipMock) SendByCriteria(*protoext.SignedGossipMessage, gossip.SendCriteria) error {
   103  	return nil
   104  }