mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
28 lines
711 B
Go
28 lines
711 B
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// MockBroadcaster implements p2p.Broadcaster for testing.
|
|
type MockBroadcaster struct {
|
|
BroadcastCalled bool
|
|
BroadcastMessages []proto.Message
|
|
}
|
|
|
|
// 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, _ *ethpb.Attestation) error {
|
|
m.BroadcastCalled = true
|
|
return nil
|
|
}
|