diff --git a/PeerManager_Mock.go b/PeerManager_Mock.go index 093d119..18bc16b 100644 --- a/PeerManager_Mock.go +++ b/PeerManager_Mock.go @@ -7,27 +7,27 @@ import ( "github.com/libsv/go-p2p/chaincfg/chainhash" ) -type mockHandler struct { +type TestLogger struct { } -func (h *mockHandler) Enabled(_ context.Context, _ slog.Level) bool { +func (h *TestLogger) Enabled(_ context.Context, _ slog.Level) bool { return false } -func (h *mockHandler) Handle(_ context.Context, _ slog.Record) error { +func (h *TestLogger) Handle(_ context.Context, _ slog.Record) error { return nil } -func (h *mockHandler) WithAttrs(_ []slog.Attr) slog.Handler { - return &mockHandler{} +func (h *TestLogger) WithAttrs(_ []slog.Attr) slog.Handler { + return &TestLogger{} } -func (h *mockHandler) WithGroup(_ string) slog.Handler { - return &mockHandler{} +func (h *TestLogger) WithGroup(_ string) slog.Handler { + return &TestLogger{} } -func (h *mockHandler) Handler() slog.Handler { - return &mockHandler{} +func (h *TestLogger) Handler() slog.Handler { + return &TestLogger{} } type PeerManagerMock struct { diff --git a/PeerManager_test.go b/PeerManager_test.go index 9ea5ad1..d935a38 100644 --- a/PeerManager_test.go +++ b/PeerManager_test.go @@ -19,7 +19,7 @@ var ( func TestNewPeerManager(t *testing.T) { - logger := slog.New(&mockHandler{}) + logger := slog.New(&TestLogger{}) t.Run("nil peers no error", func(t *testing.T) { pm := NewPeerManager(logger, wire.TestNet) @@ -64,7 +64,7 @@ func TestNewPeerManager(t *testing.T) { func TestAnnounceNewTransaction(t *testing.T) { t.Run("announce tx", func(t *testing.T) { - logger := slog.New(&mockHandler{}) + logger := slog.New(&TestLogger{}) pm := NewPeerManager(logger, wire.TestNet, WithBatchDuration(1*time.Millisecond)) require.NotNil(t, pm) @@ -85,7 +85,7 @@ func TestAnnounceNewTransaction(t *testing.T) { }) t.Run("announce tx - multiple peers", func(t *testing.T) { - logger := slog.New(&mockHandler{}) + logger := slog.New(&TestLogger{}) pm := NewPeerManager(logger, wire.TestNet, WithBatchDuration(1*time.Millisecond)) require.NotNil(t, pm) diff --git a/Peer_test.go b/Peer_test.go index a5243fc..51e0d54 100644 --- a/Peer_test.go +++ b/Peer_test.go @@ -251,7 +251,7 @@ func newTestPeer(t *testing.T) (net.Conn, *Peer, *MockPeerHandler) { peerConn, myConn := connutil.AsyncPipe() peerHandler := NewMockPeerHandler() - logger := slog.New(&mockHandler{}) + logger := slog.New(&TestLogger{}) p, err := NewPeer( logger, "MockPeerHandler:0000", @@ -284,7 +284,7 @@ func newTestPeer(t *testing.T) (net.Conn, *Peer, *MockPeerHandler) { func newIncomingTestPeer(t *testing.T) (net.Conn, *Peer, *MockPeerHandler) { peerConn, myConn := connutil.AsyncPipe() peerHandler := NewMockPeerHandler() - logger := slog.New(&mockHandler{}) + logger := slog.New(&TestLogger{}) p, err := NewPeer( logger, "MockPeerHandler:0000",