mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 10:27:26 +08:00
* experiment: reject bad peer info messages * v2.1.0.18 preview * add tagged sync * Add missing hypergraph changes * small tweaks to sync * allow local sync, use it for provers with workers * missing file * resolve build error * resolve sync issue, remove raw sync * resolve deletion promotion bug * resolve sync abstraction leak from tree deletion changes * rearrange prover sync * remove pruning from sync * restore removed sync flag * fix: sync, event stream deadlock, heuristic scoring of better shards * resolve hanging shutdown + pubsub proxy issue * further bugfixes: sync (restore old leaf sync), pubsub shutdown, merge events * fix: clean up rust ffi, background coverage events, and sync tweaks * fix: linking issue for channel, connectivity test aggression, sync regression, join tests * fix: disjoint sync, improper application of filter * resolve sync/reel/validation deadlock * adjust sync to handle no leaf edge cases, multi-path segment traversal * use simpler sync * faster, simpler sync with some debug extras * migration to recalculate * don't use batch * square up the roots * fix nil pointer * fix: seniority calculation, sync race condition, migration * make sync dumber * fix: tree deletion issue * fix: missing seniority merge request canonical serialization * address issues from previous commit test * stale workers should be cleared * remove missing gap check * rearrange collect, reduce sync logging noise * fix: the disjoint leaf/branch sync case * nuclear option on sync failures * v2.1.0.18, finalized
181 lines
4.1 KiB
Go
181 lines
4.1 KiB
Go
package mocks
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
"github.com/multiformats/go-multiaddr"
|
|
"github.com/stretchr/testify/mock"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/protobuf/types/known/wrapperspb"
|
|
"source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb"
|
|
"source.quilibrium.com/quilibrium/monorepo/protobufs"
|
|
"source.quilibrium.com/quilibrium/monorepo/types/p2p"
|
|
)
|
|
|
|
// MockPubSub mocks the PubSub interface for testing
|
|
type MockPubSub struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Close implements p2p.PubSub.
|
|
func (m *MockPubSub) Close() error {
|
|
return nil
|
|
}
|
|
|
|
// SetShutdownContext implements p2p.PubSub.
|
|
func (m *MockPubSub) SetShutdownContext(ctx context.Context) {}
|
|
|
|
// GetOwnMultiaddrs implements p2p.PubSub.
|
|
func (m *MockPubSub) GetOwnMultiaddrs() []multiaddr.Multiaddr {
|
|
args := m.Called()
|
|
return args.Get(0).([]multiaddr.Multiaddr)
|
|
}
|
|
|
|
func (m *MockPubSub) PublishToBitmask(bitmask []byte, data []byte) error {
|
|
args := m.Called(bitmask, data)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) Publish(address []byte, data []byte) error {
|
|
args := m.Called(address, data)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) Subscribe(
|
|
bitmask []byte,
|
|
handler func(message *pb.Message) error,
|
|
) error {
|
|
args := m.Called(bitmask, handler)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) Unsubscribe(bitmask []byte, raw bool) {
|
|
m.Called(bitmask, raw)
|
|
}
|
|
|
|
func (m *MockPubSub) RegisterValidator(
|
|
bitmask []byte,
|
|
validator func(peerID peer.ID, message *pb.Message) p2p.ValidationResult,
|
|
sync bool,
|
|
) error {
|
|
args := m.Called(bitmask, validator, sync)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) UnregisterValidator(bitmask []byte) error {
|
|
args := m.Called(bitmask)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) GetPeerID() []byte {
|
|
args := m.Called()
|
|
return args.Get(0).([]byte)
|
|
}
|
|
|
|
func (m *MockPubSub) GetPeerstoreCount() int {
|
|
args := m.Called()
|
|
return args.Int(0)
|
|
}
|
|
|
|
func (m *MockPubSub) GetNetworkPeersCount() int {
|
|
args := m.Called()
|
|
return args.Int(0)
|
|
}
|
|
|
|
func (m *MockPubSub) GetRandomPeer(bitmask []byte) ([]byte, error) {
|
|
args := m.Called(bitmask)
|
|
return args.Get(0).([]byte), args.Error(1)
|
|
}
|
|
|
|
func (m *MockPubSub) GetMultiaddrOfPeerStream(
|
|
ctx context.Context,
|
|
peerId []byte,
|
|
) <-chan multiaddr.Multiaddr {
|
|
args := m.Called(ctx, peerId)
|
|
return args.Get(0).(<-chan multiaddr.Multiaddr)
|
|
}
|
|
|
|
func (m *MockPubSub) GetMultiaddrOfPeer(peerId []byte) string {
|
|
args := m.Called(peerId)
|
|
return args.String(0)
|
|
}
|
|
|
|
func (m *MockPubSub) StartDirectChannelListener(
|
|
key []byte,
|
|
purpose string,
|
|
server *grpc.Server,
|
|
) error {
|
|
args := m.Called(key, purpose, server)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) GetDirectChannel(
|
|
ctx context.Context,
|
|
peerId []byte,
|
|
purpose string,
|
|
) (*grpc.ClientConn, error) {
|
|
args := m.Called(ctx, peerId, purpose)
|
|
return args.Get(0).(*grpc.ClientConn), args.Error(1)
|
|
}
|
|
|
|
func (m *MockPubSub) GetNetworkInfo() *protobufs.NetworkInfoResponse {
|
|
args := m.Called()
|
|
return args.Get(0).(*protobufs.NetworkInfoResponse)
|
|
}
|
|
|
|
func (m *MockPubSub) SignMessage(msg []byte) ([]byte, error) {
|
|
args := m.Called(msg)
|
|
return args.Get(0).([]byte), args.Error(1)
|
|
}
|
|
|
|
func (m *MockPubSub) GetPublicKey() []byte {
|
|
args := m.Called()
|
|
return args.Get(0).([]byte)
|
|
}
|
|
|
|
func (m *MockPubSub) GetPeerScore(peerId []byte) int64 {
|
|
args := m.Called(peerId)
|
|
return args.Get(0).(int64)
|
|
}
|
|
|
|
func (m *MockPubSub) SetPeerScore(peerId []byte, score int64) {
|
|
m.Called(peerId, score)
|
|
}
|
|
|
|
func (m *MockPubSub) AddPeerScore(peerId []byte, scoreDelta int64) {
|
|
m.Called(peerId, scoreDelta)
|
|
}
|
|
|
|
func (m *MockPubSub) Reconnect(peerId []byte) error {
|
|
args := m.Called(peerId)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) Bootstrap(ctx context.Context) error {
|
|
args := m.Called(ctx)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) DiscoverPeers(ctx context.Context) error {
|
|
args := m.Called(ctx)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockPubSub) GetNetwork() uint {
|
|
args := m.Called()
|
|
return args.Get(0).(uint)
|
|
}
|
|
|
|
func (m *MockPubSub) IsPeerConnected(peerId []byte) bool {
|
|
args := m.Called(peerId)
|
|
return args.Bool(0)
|
|
}
|
|
|
|
func (m *MockPubSub) Reachability() *wrapperspb.BoolValue {
|
|
args := m.Called()
|
|
return args.Get(0).(*wrapperspb.BoolValue)
|
|
}
|
|
|
|
var _ p2p.PubSub = (*MockPubSub)(nil)
|