diff --git a/p2p/host/hostv2/hostv2.go b/p2p/host/hostv2/hostv2.go index e8e05b7bf..7b5c3a0f3 100644 --- a/p2p/host/hostv2/hostv2.go +++ b/p2p/host/hostv2/hostv2.go @@ -1,6 +1,6 @@ package hostv2 -//go:generate mockgen -source hostv2.go -destination=mock/hostv2_mock.go +//go:generate mockgen -source=hostv2.go -package=hostv2 -destination=hostv2_mock_for_test.go import ( "context" diff --git a/p2p/host/hostv2/mock/hostv2_mock.go b/p2p/host/hostv2/hostv2_mock_for_test.go similarity index 98% rename from p2p/host/hostv2/mock/hostv2_mock.go rename to p2p/host/hostv2/hostv2_mock_for_test.go index 6a1e05a69..27f4b6173 100644 --- a/p2p/host/hostv2/mock/hostv2_mock.go +++ b/p2p/host/hostv2/hostv2_mock_for_test.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: hostv2.go -// Package mock_hostv2 is a generated GoMock package. -package mock_hostv2 +// Package hostv2 is a generated GoMock package. +package hostv2 import ( context "context" diff --git a/p2p/host/hostv2/hostv2_test.go b/p2p/host/hostv2/hostv2_test.go index 9f63337f0..ad0fbf07d 100644 --- a/p2p/host/hostv2/hostv2_test.go +++ b/p2p/host/hostv2/hostv2_test.go @@ -12,7 +12,6 @@ import ( libp2p_pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" - mock "github.com/harmony-one/harmony/p2p/host/hostv2/mock" ) func TestHostV2_SendMessageToGroups(t *testing.T) { @@ -21,7 +20,7 @@ func TestHostV2_SendMessageToGroups(t *testing.T) { defer mc.Finish() groups := []nodeconfig.GroupID{"ABC", "DEF"} data := []byte{1, 2, 3} - pubsub := mock.NewMockpubsub(mc) + pubsub := NewMockpubsub(mc) gomock.InOrder( pubsub.EXPECT().Publish("ABC", data), pubsub.EXPECT().Publish("DEF", data), @@ -36,7 +35,7 @@ func TestHostV2_SendMessageToGroups(t *testing.T) { defer mc.Finish() groups := []nodeconfig.GroupID{"ABC", "DEF"} data := []byte{1, 2, 3} - pubsub := mock.NewMockpubsub(mc) + pubsub := NewMockpubsub(mc) gomock.InOrder( pubsub.EXPECT().Publish("ABC", data).Return(errors.New("FIAL")), pubsub.EXPECT().Publish("DEF", data), // Should not early-return @@ -51,7 +50,7 @@ func TestHostV2_SendMessageToGroups(t *testing.T) { func TestGroupReceiver_Close(t *testing.T) { mc := gomock.NewController(t) defer mc.Finish() - sub := mock.NewMocksubscription(mc) + sub := NewMocksubscription(mc) sub.EXPECT().Cancel() receiver := GroupReceiverImpl{sub: sub} if err := receiver.Close(); err != nil { @@ -67,7 +66,7 @@ func pubsubMessage(from libp2p_peer.ID, data []byte) *libp2p_pubsub.Message { func TestGroupReceiver_Receive(t *testing.T) { mc := gomock.NewController(t) defer mc.Finish() - sub := mock.NewMocksubscription(mc) + sub := NewMocksubscription(mc) ctx := context.Background() gomock.InOrder( sub.EXPECT().Next(ctx).Return(pubsubMessage("ABC", []byte{1, 2, 3}), nil), @@ -101,7 +100,7 @@ func TestHostV2_GroupReceiver(t *testing.T) { mc := gomock.NewController(t) defer mc.Finish() sub := &libp2p_pubsub.Subscription{} - pubsub := mock.NewMockpubsub(mc) + pubsub := NewMockpubsub(mc) pubsub.EXPECT().Subscribe("ABC").Return(sub, nil) host := &HostV2{pubsub: pubsub} gotReceiver, err := host.GroupReceiver("ABC") @@ -117,7 +116,7 @@ func TestHostV2_GroupReceiver(t *testing.T) { t.Run("Error", func(t *testing.T) { mc := gomock.NewController(t) defer mc.Finish() - pubsub := mock.NewMockpubsub(mc) + pubsub := NewMockpubsub(mc) pubsub.EXPECT().Subscribe("ABC").Return(nil, errors.New("FIAL")) host := &HostV2{pubsub: pubsub} gotReceiver, err := host.GroupReceiver("ABC")