Skip to content

Commit

Permalink
BPAAS-1054: Rename mock logger
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Oct 16, 2023
1 parent 416b26f commit d8eeee7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions PeerManager_Mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions PeerManager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit d8eeee7

Please sign in to comment.