mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// MockBroadcaster implements p2p.Broadcaster for testing.
|
|
type MockBroadcaster struct {
|
|
BroadcastCalled bool
|
|
BroadcastMessages []proto.Message
|
|
BroadcastAttestations []*ethpb.Attestation
|
|
}
|
|
|
|
// Broadcast records a broadcast occurred.
|
|
func (m *MockBroadcaster) Broadcast(_ context.Context, msg proto.Message) error {
|
|
m.BroadcastCalled = true
|
|
m.BroadcastMessages = append(m.BroadcastMessages, msg)
|
|
return nil
|
|
}
|
|
|
|
// BroadcastAttestation records a broadcast occurred.
|
|
func (m *MockBroadcaster) BroadcastAttestation(_ context.Context, _ uint64, a *ethpb.Attestation) error {
|
|
m.BroadcastCalled = true
|
|
m.BroadcastAttestations = append(m.BroadcastAttestations, a)
|
|
return nil
|
|
}
|
|
|
|
// BroadcastSyncCommitteeMessage records a broadcast occurred.
|
|
func (m *MockBroadcaster) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error {
|
|
m.BroadcastCalled = true
|
|
return nil
|
|
}
|