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