From d08bcd9c0fc0fb3dc415fb05b174f448c6da12c3 Mon Sep 17 00:00:00 2001 From: Sukun Date: Thu, 14 Sep 2023 10:05:48 +0530 Subject: [PATCH] mock: use go.uber.org/mock (#2540) --- core/network/mocks/mock_conn_management_scope.go | 2 +- core/network/mocks/mock_peer_scope.go | 2 +- core/network/mocks/mock_protocol_scope.go | 2 +- core/network/mocks/mock_resource_manager.go | 2 +- core/network/mocks/mock_resource_scope_span.go | 2 +- core/network/mocks/mock_stream_management_scope.go | 2 +- core/network/mocks/network.go | 12 ++++++------ go.mod | 3 ++- go.sum | 2 ++ p2p/host/basic/mock_nat_test.go | 2 +- p2p/host/basic/mocks.go | 2 +- p2p/host/basic/natmgr_test.go | 2 +- p2p/host/pstoremanager/mock_peerstore_test.go | 2 +- p2p/host/pstoremanager/pstoremanager_test.go | 4 ++-- p2p/net/nat/mock_nat_test.go | 2 +- p2p/net/nat/nat_test.go | 4 ++-- p2p/net/swarm/swarm_test.go | 2 +- p2p/net/upgrader/listener_test.go | 2 +- p2p/net/upgrader/upgrader_test.go | 2 +- p2p/test/transport/gating_test.go | 4 ++-- p2p/test/transport/mock_connection_gater_test.go | 2 +- p2p/test/transport/rcmgr_test.go | 2 +- p2p/transport/quic/conn_test.go | 4 ++-- p2p/transport/quic/mock_connection_gater_test.go | 2 +- p2p/transport/tcp/tcp_test.go | 2 +- .../webtransport/mock_connection_gater_test.go | 2 +- p2p/transport/webtransport/transport_test.go | 4 ++-- test-plans/go.mod | 1 + test-plans/go.sum | 2 ++ tools.go | 2 +- 30 files changed, 43 insertions(+), 37 deletions(-) diff --git a/core/network/mocks/mock_conn_management_scope.go b/core/network/mocks/mock_conn_management_scope.go index 5d847f91f..1c0187613 100644 --- a/core/network/mocks/mock_conn_management_scope.go +++ b/core/network/mocks/mock_conn_management_scope.go @@ -7,9 +7,9 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" + gomock "go.uber.org/mock/gomock" ) // MockConnManagementScope is a mock of ConnManagementScope interface. diff --git a/core/network/mocks/mock_peer_scope.go b/core/network/mocks/mock_peer_scope.go index 163383999..ce3f0e0df 100644 --- a/core/network/mocks/mock_peer_scope.go +++ b/core/network/mocks/mock_peer_scope.go @@ -7,9 +7,9 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" + gomock "go.uber.org/mock/gomock" ) // MockPeerScope is a mock of PeerScope interface. diff --git a/core/network/mocks/mock_protocol_scope.go b/core/network/mocks/mock_protocol_scope.go index 646eede62..b1c4ee31a 100644 --- a/core/network/mocks/mock_protocol_scope.go +++ b/core/network/mocks/mock_protocol_scope.go @@ -7,9 +7,9 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" protocol "github.com/libp2p/go-libp2p/core/protocol" + gomock "go.uber.org/mock/gomock" ) // MockProtocolScope is a mock of ProtocolScope interface. diff --git a/core/network/mocks/mock_resource_manager.go b/core/network/mocks/mock_resource_manager.go index dbf6219c3..ab6c2a2f9 100644 --- a/core/network/mocks/mock_resource_manager.go +++ b/core/network/mocks/mock_resource_manager.go @@ -7,11 +7,11 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" protocol "github.com/libp2p/go-libp2p/core/protocol" multiaddr "github.com/multiformats/go-multiaddr" + gomock "go.uber.org/mock/gomock" ) // MockResourceManager is a mock of ResourceManager interface. diff --git a/core/network/mocks/mock_resource_scope_span.go b/core/network/mocks/mock_resource_scope_span.go index ba9a4245d..1f0ccae43 100644 --- a/core/network/mocks/mock_resource_scope_span.go +++ b/core/network/mocks/mock_resource_scope_span.go @@ -7,8 +7,8 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" + gomock "go.uber.org/mock/gomock" ) // MockResourceScopeSpan is a mock of ResourceScopeSpan interface. diff --git a/core/network/mocks/mock_stream_management_scope.go b/core/network/mocks/mock_stream_management_scope.go index 7dace9095..016c24e50 100644 --- a/core/network/mocks/mock_stream_management_scope.go +++ b/core/network/mocks/mock_stream_management_scope.go @@ -7,9 +7,9 @@ package mocknetwork import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" network "github.com/libp2p/go-libp2p/core/network" protocol "github.com/libp2p/go-libp2p/core/protocol" + gomock "go.uber.org/mock/gomock" ) // MockStreamManagementScope is a mock of StreamManagementScope interface. diff --git a/core/network/mocks/network.go b/core/network/mocks/network.go index 6fe8e9173..73025bd28 100644 --- a/core/network/mocks/network.go +++ b/core/network/mocks/network.go @@ -1,8 +1,8 @@ package mocknetwork -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager" -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_conn_management_scope.go github.com/libp2p/go-libp2p/core/network ConnManagementScope" -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_stream_management_scope.go github.com/libp2p/go-libp2p/core/network StreamManagementScope" -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_peer_scope.go github.com/libp2p/go-libp2p/core/network PeerScope" -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_protocol_scope.go github.com/libp2p/go-libp2p/core/network ProtocolScope" -//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_resource_scope_span.go github.com/libp2p/go-libp2p/core/network ResourceScopeSpan" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_conn_management_scope.go github.com/libp2p/go-libp2p/core/network ConnManagementScope" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_stream_management_scope.go github.com/libp2p/go-libp2p/core/network StreamManagementScope" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_peer_scope.go github.com/libp2p/go-libp2p/core/network PeerScope" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_protocol_scope.go github.com/libp2p/go-libp2p/core/network ProtocolScope" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package mocknetwork -destination mock_resource_scope_span.go github.com/libp2p/go-libp2p/core/network ResourceScopeSpan" diff --git a/go.mod b/go.mod index 6f11173f3..591a29907 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/flynn/noise v1.0.0 - github.com/golang/mock v1.6.0 github.com/google/gopacket v1.1.19 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/golang-lru/arc/v2 v2.0.5 @@ -58,6 +57,7 @@ require ( github.com/stretchr/testify v1.8.4 go.uber.org/fx v1.20.0 go.uber.org/goleak v1.2.0 + go.uber.org/mock v0.2.0 go.uber.org/zap v1.25.0 golang.org/x/crypto v0.12.0 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 @@ -85,6 +85,7 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect diff --git a/go.sum b/go.sum index b3c1bacd9..950eb1f0a 100644 --- a/go.sum +++ b/go.sum @@ -573,6 +573,8 @@ go.uber.org/fx v1.20.0/go.mod h1:qCUj0btiR3/JnanEr1TYEePfSw6o/4qYJscgvzQ5Ub0= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= diff --git a/p2p/host/basic/mock_nat_test.go b/p2p/host/basic/mock_nat_test.go index 4e686fac1..065f43e4c 100644 --- a/p2p/host/basic/mock_nat_test.go +++ b/p2p/host/basic/mock_nat_test.go @@ -9,7 +9,7 @@ import ( netip "net/netip" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockNAT is a mock of NAT interface. diff --git a/p2p/host/basic/mocks.go b/p2p/host/basic/mocks.go index 3ad4d4e90..a29a0c5ef 100644 --- a/p2p/host/basic/mocks.go +++ b/p2p/host/basic/mocks.go @@ -2,5 +2,5 @@ package basichost -//go:generate sh -c "go run github.com/golang/mock/mockgen -build_flags=\"-tags=gomock\" -package basichost -destination mock_nat_test.go github.com/libp2p/go-libp2p/p2p/host/basic NAT" +//go:generate sh -c "go run go.uber.org/mock/mockgen -build_flags=\"-tags=gomock\" -package basichost -destination mock_nat_test.go github.com/libp2p/go-libp2p/p2p/host/basic NAT" type NAT nat diff --git a/p2p/host/basic/natmgr_test.go b/p2p/host/basic/natmgr_test.go index d22092d18..8cbe8618e 100644 --- a/p2p/host/basic/natmgr_test.go +++ b/p2p/host/basic/natmgr_test.go @@ -12,7 +12,7 @@ import ( swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) func setupMockNAT(t *testing.T) (mockNAT *MockNAT, reset func()) { diff --git a/p2p/host/pstoremanager/mock_peerstore_test.go b/p2p/host/pstoremanager/mock_peerstore_test.go index fb9a28250..33dc760b4 100644 --- a/p2p/host/pstoremanager/mock_peerstore_test.go +++ b/p2p/host/pstoremanager/mock_peerstore_test.go @@ -9,11 +9,11 @@ import ( reflect "reflect" time "time" - gomock "github.com/golang/mock/gomock" crypto "github.com/libp2p/go-libp2p/core/crypto" peer "github.com/libp2p/go-libp2p/core/peer" protocol "github.com/libp2p/go-libp2p/core/protocol" multiaddr "github.com/multiformats/go-multiaddr" + gomock "go.uber.org/mock/gomock" ) // MockPeerstore is a mock of Peerstore interface. diff --git a/p2p/host/pstoremanager/pstoremanager_test.go b/p2p/host/pstoremanager/pstoremanager_test.go index 8726740c3..bcfd87490 100644 --- a/p2p/host/pstoremanager/pstoremanager_test.go +++ b/p2p/host/pstoremanager/pstoremanager_test.go @@ -10,11 +10,11 @@ import ( "github.com/libp2p/go-libp2p/p2p/host/eventbus" "github.com/libp2p/go-libp2p/p2p/host/pstoremanager" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) -//go:generate sh -c "go run github.com/golang/mock/mockgen -package pstoremanager_test -destination mock_peerstore_test.go github.com/libp2p/go-libp2p/core/peerstore Peerstore" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package pstoremanager_test -destination mock_peerstore_test.go github.com/libp2p/go-libp2p/core/peerstore Peerstore" func TestGracePeriod(t *testing.T) { t.Parallel() diff --git a/p2p/net/nat/mock_nat_test.go b/p2p/net/nat/mock_nat_test.go index c7a151fd1..f01164bfe 100644 --- a/p2p/net/nat/mock_nat_test.go +++ b/p2p/net/nat/mock_nat_test.go @@ -10,7 +10,7 @@ import ( reflect "reflect" time "time" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockNAT is a mock of NAT interface. diff --git a/p2p/net/nat/nat_test.go b/p2p/net/nat/nat_test.go index ea47edc0b..50e1eb3a2 100644 --- a/p2p/net/nat/nat_test.go +++ b/p2p/net/nat/nat_test.go @@ -9,11 +9,11 @@ import ( "github.com/libp2p/go-nat" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) -//go:generate sh -c "go run github.com/golang/mock/mockgen -package nat -destination mock_nat_test.go github.com/libp2p/go-nat NAT" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package nat -destination mock_nat_test.go github.com/libp2p/go-nat NAT" func setupMockNAT(t *testing.T) (mockNAT *MockNAT, reset func()) { t.Helper() diff --git a/p2p/net/swarm/swarm_test.go b/p2p/net/swarm/swarm_test.go index c795b68af..136e23bc2 100644 --- a/p2p/net/swarm/swarm_test.go +++ b/p2p/net/swarm/swarm_test.go @@ -21,11 +21,11 @@ import ( "github.com/libp2p/go-libp2p/p2p/net/swarm" . "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" - "github.com/golang/mock/gomock" logging "github.com/ipfs/go-log/v2" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) var log = logging.Logger("swarm_test") diff --git a/p2p/net/upgrader/listener_test.go b/p2p/net/upgrader/listener_test.go index 331e973ed..26d3a1523 100644 --- a/p2p/net/upgrader/listener_test.go +++ b/p2p/net/upgrader/listener_test.go @@ -18,10 +18,10 @@ import ( "github.com/libp2p/go-libp2p/core/transport" "github.com/libp2p/go-libp2p/p2p/net/upgrader" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) func createListener(t *testing.T, u transport.Upgrader) transport.Listener { diff --git a/p2p/net/upgrader/upgrader_test.go b/p2p/net/upgrader/upgrader_test.go index b61ba8a61..920ccaab9 100644 --- a/p2p/net/upgrader/upgrader_test.go +++ b/p2p/net/upgrader/upgrader_test.go @@ -18,10 +18,10 @@ import ( "github.com/libp2p/go-libp2p/p2p/muxer/yamux" "github.com/libp2p/go-libp2p/p2p/net/upgrader" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) func createUpgrader(t *testing.T) (peer.ID, transport.Upgrader) { diff --git a/p2p/test/transport/gating_test.go b/p2p/test/transport/gating_test.go index 65d732ba8..df53da6ee 100644 --- a/p2p/test/transport/gating_test.go +++ b/p2p/test/transport/gating_test.go @@ -13,12 +13,12 @@ import ( "github.com/libp2p/go-libp2p-testing/race" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) -//go:generate go run github.com/golang/mock/mockgen -package transport_integration -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater +//go:generate go run go.uber.org/mock/mockgen -package transport_integration -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater func stripCertHash(addr ma.Multiaddr) ma.Multiaddr { for { diff --git a/p2p/test/transport/mock_connection_gater_test.go b/p2p/test/transport/mock_connection_gater_test.go index d6efc8b02..f7f4c1a75 100644 --- a/p2p/test/transport/mock_connection_gater_test.go +++ b/p2p/test/transport/mock_connection_gater_test.go @@ -7,11 +7,11 @@ package transport_integration import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" control "github.com/libp2p/go-libp2p/core/control" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" multiaddr "github.com/multiformats/go-multiaddr" + gomock "go.uber.org/mock/gomock" ) // MockConnectionGater is a mock of ConnectionGater interface. diff --git a/p2p/test/transport/rcmgr_test.go b/p2p/test/transport/rcmgr_test.go index 239e474db..20f34de79 100644 --- a/p2p/test/transport/rcmgr_test.go +++ b/p2p/test/transport/rcmgr_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" mocknetwork "github.com/libp2p/go-libp2p/core/network/mocks" @@ -17,6 +16,7 @@ import ( "github.com/libp2p/go-libp2p/p2p/protocol/identify" "github.com/libp2p/go-libp2p/p2p/protocol/ping" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) func TestResourceManagerIsUsed(t *testing.T) { diff --git a/p2p/transport/quic/conn_test.go b/p2p/transport/quic/conn_test.go index 65f733a87..8284b3038 100644 --- a/p2p/transport/quic/conn_test.go +++ b/p2p/transport/quic/conn_test.go @@ -20,14 +20,14 @@ import ( tpt "github.com/libp2p/go-libp2p/core/transport" "github.com/libp2p/go-libp2p/p2p/transport/quicreuse" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" "github.com/quic-go/quic-go" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) -//go:generate sh -c "go run github.com/golang/mock/mockgen -package libp2pquic -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package libp2pquic -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go" type connTestCase struct { Name string diff --git a/p2p/transport/quic/mock_connection_gater_test.go b/p2p/transport/quic/mock_connection_gater_test.go index 4ee400853..cbea666dd 100644 --- a/p2p/transport/quic/mock_connection_gater_test.go +++ b/p2p/transport/quic/mock_connection_gater_test.go @@ -7,11 +7,11 @@ package libp2pquic import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" control "github.com/libp2p/go-libp2p/core/control" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" multiaddr "github.com/multiformats/go-multiaddr" + gomock "go.uber.org/mock/gomock" ) // MockConnectionGater is a mock of ConnectionGater interface. diff --git a/p2p/transport/tcp/tcp_test.go b/p2p/transport/tcp/tcp_test.go index 05b6cb935..26385faa9 100644 --- a/p2p/transport/tcp/tcp_test.go +++ b/p2p/transport/tcp/tcp_test.go @@ -16,9 +16,9 @@ import ( tptu "github.com/libp2p/go-libp2p/p2p/net/upgrader" ttransport "github.com/libp2p/go-libp2p/p2p/transport/testsuite" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) var muxers = []tptu.StreamMuxer{{ID: "/yamux", Muxer: yamux.DefaultTransport}} diff --git a/p2p/transport/webtransport/mock_connection_gater_test.go b/p2p/transport/webtransport/mock_connection_gater_test.go index c6e7dbaad..1b74bfe52 100644 --- a/p2p/transport/webtransport/mock_connection_gater_test.go +++ b/p2p/transport/webtransport/mock_connection_gater_test.go @@ -7,11 +7,11 @@ package libp2pwebtransport_test import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" control "github.com/libp2p/go-libp2p/core/control" network "github.com/libp2p/go-libp2p/core/network" peer "github.com/libp2p/go-libp2p/core/peer" multiaddr "github.com/multiformats/go-multiaddr" + gomock "go.uber.org/mock/gomock" ) // MockConnectionGater is a mock of ConnectionGater interface. diff --git a/p2p/transport/webtransport/transport_test.go b/p2p/transport/webtransport/transport_test.go index 6c666dc24..7f5b3cf84 100644 --- a/p2p/transport/webtransport/transport_test.go +++ b/p2p/transport/webtransport/transport_test.go @@ -28,7 +28,6 @@ import ( libp2pwebtransport "github.com/libp2p/go-libp2p/p2p/transport/webtransport" "github.com/benbjohnson/clock" - "github.com/golang/mock/gomock" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/multiformats/go-multibase" @@ -37,6 +36,7 @@ import ( "github.com/quic-go/quic-go/http3" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ) const clockSkewAllowance = time.Hour @@ -360,7 +360,7 @@ func TestResourceManagerListening(t *testing.T) { } // TODO: unify somehow. We do the same in libp2pquic. -//go:generate sh -c "go run github.com/golang/mock/mockgen -package libp2pwebtransport_test -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go" +//go:generate sh -c "go run go.uber.org/mock/mockgen -package libp2pwebtransport_test -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go" func TestConnectionGaterDialing(t *testing.T) { ctrl := gomock.NewController(t) diff --git a/test-plans/go.mod b/test-plans/go.mod index 2e4df2049..94322936d 100644 --- a/test-plans/go.mod +++ b/test-plans/go.mod @@ -111,6 +111,7 @@ require ( github.com/stretchr/testify v1.8.4 // indirect go.uber.org/dig v1.17.0 // indirect go.uber.org/fx v1.20.0 // indirect + go.uber.org/mock v0.2.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/test-plans/go.sum b/test-plans/go.sum index 75c97035f..86d48e2b6 100644 --- a/test-plans/go.sum +++ b/test-plans/go.sum @@ -374,6 +374,8 @@ go.uber.org/fx v1.20.0 h1:ZMC/pnRvhsthOZh9MZjMq5U8Or3mA9zBSPaLnzs3ihQ= go.uber.org/fx v1.20.0/go.mod h1:qCUj0btiR3/JnanEr1TYEePfSw6o/4qYJscgvzQ5Ub0= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= diff --git a/tools.go b/tools.go index 46a8037df..7a650d9c1 100644 --- a/tools.go +++ b/tools.go @@ -3,7 +3,7 @@ package libp2p import ( - _ "github.com/golang/mock/mockgen" + _ "go.uber.org/mock/mockgen" _ "golang.org/x/tools/cmd/goimports" _ "google.golang.org/protobuf/cmd/protoc-gen-go" )