From ed705ba39b11cbfc9c5dd15b620566b88310351c Mon Sep 17 00:00:00 2001 From: "elprogramadorgt8@gmail.com" Date: Thu, 31 Oct 2024 12:14:54 -0500 Subject: [PATCH] test(mock): switch mocking library from golang/mock to go.uber.org/mock --- Makefile | 2 +- go.mod | 7 ++++--- go.sum | 10 ++++++---- x/logic/fs/composite/fs_test.go | 2 +- x/logic/fs/filtered/fs_test.go | 2 +- x/logic/fs/wasm/fs_test.go | 2 +- x/logic/keeper/features_test.go | 2 +- x/logic/keeper/grpc_query_ask_test.go | 2 +- x/logic/keeper/grpc_query_params_test.go | 2 +- x/logic/keeper/migrations_test.go | 2 +- x/logic/keeper/msg_server_test.go | 2 +- x/logic/meter/weighted_test.go | 2 +- x/logic/predicate/bank_test.go | 2 +- x/logic/predicate/builtin_test.go | 2 +- x/logic/predicate/util_test.go | 2 +- x/logic/testutil/expected_keepers_mocks.go | 2 +- x/logic/testutil/fs_mocks.go | 2 +- x/logic/testutil/gas_mocks.go | 2 +- x/logic/testutil/interface_registry_mocks.go | 2 +- x/logic/testutil/keeper_mocks.go | 2 +- x/logic/testutil/read_file_fs_mocks.go | 2 +- x/mint/keeper/genesis_test.go | 2 +- x/mint/keeper/grpc_query_test.go | 2 +- x/mint/keeper/keeper_test.go | 2 +- x/mint/testutil/expected_keepers_mocks.go | 2 +- x/vesting/msg_server_test.go | 2 +- x/vesting/testutil/expected_keepers_mocks.go | 2 +- 27 files changed, 35 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 8fc043f4..88d4f345 100644 --- a/Makefile +++ b/Makefile @@ -362,7 +362,7 @@ doc-predicate: ## Generate markdown documentation for all the predicates (module .PHONY: mock mock: ## Generate all the mocks (for tests) @echo "${COLOR_CYAN} 🧱 Generating all the mocks${COLOR_RESET}" - @go install github.com/golang/mock/mockgen@v1.6.0 + @go install go.uber.org/mock/mockgen@v0.5.0 @mockgen -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go @mockgen -source=x/vesting/types/expected_keepers.go -package testutil -destination x/vesting/testutil/expected_keepers_mocks.go @mockgen -source=x/logic/types/expected_keepers.go -package testutil -destination x/logic/testutil/expected_keepers_mocks.go diff --git a/go.mod b/go.mod index 0c1afecf..687158ef 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( github.com/cucumber/godog v0.14.1 github.com/cucumber/messages/go/v21 v21.0.1 github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 - github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 @@ -56,6 +55,7 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/wk8/go-ordered-map/v2 v2.1.8 + go.uber.org/mock v0.5.0 golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 golang.org/x/net v0.30.0 google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 @@ -161,6 +161,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v1.12.1 // indirect @@ -289,14 +290,14 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.28.0 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/mod v0.18.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools v0.22.0 // indirect google.golang.org/api v0.171.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect diff --git a/go.sum b/go.sum index ba468c6f..7a251068 100644 --- a/go.sum +++ b/go.sum @@ -1313,6 +1313,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1386,8 +1388,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1701,8 +1703,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/x/logic/fs/composite/fs_test.go b/x/logic/fs/composite/fs_test.go index a8e245cb..49a92ee6 100644 --- a/x/logic/fs/composite/fs_test.go +++ b/x/logic/fs/composite/fs_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/fs/filtered/fs_test.go b/x/logic/fs/filtered/fs_test.go index 0fcc370b..2c09350a 100644 --- a/x/logic/fs/filtered/fs_test.go +++ b/x/logic/fs/filtered/fs_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/samber/lo" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/fs/wasm/fs_test.go b/x/logic/fs/wasm/fs_test.go index aefd2405..7367b879 100644 --- a/x/logic/fs/wasm/fs_test.go +++ b/x/logic/fs/wasm/fs_test.go @@ -9,7 +9,7 @@ import ( "testing" dbm "github.com/cosmos/cosmos-db" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/keeper/features_test.go b/x/logic/keeper/features_test.go index 35cfb012..725779c2 100644 --- a/x/logic/keeper/features_test.go +++ b/x/logic/keeper/features_test.go @@ -14,9 +14,9 @@ import ( "dario.cat/mergo" "github.com/cucumber/godog" - "github.com/golang/mock/gomock" "github.com/sergi/go-diff/diffmatchpatch" "github.com/smartystreets/goconvey/convey/reporting" + "go.uber.org/mock/gomock" "gopkg.in/yaml.v3" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/keeper/grpc_query_ask_test.go b/x/logic/keeper/grpc_query_ask_test.go index b7c63658..66aba512 100644 --- a/x/logic/keeper/grpc_query_ask_test.go +++ b/x/logic/keeper/grpc_query_ask_test.go @@ -6,7 +6,7 @@ import ( "io/fs" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/keeper/grpc_query_params_test.go b/x/logic/keeper/grpc_query_params_test.go index 2cafb9f8..38331f28 100644 --- a/x/logic/keeper/grpc_query_params_test.go +++ b/x/logic/keeper/grpc_query_params_test.go @@ -6,7 +6,7 @@ import ( "io/fs" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/keeper/migrations_test.go b/x/logic/keeper/migrations_test.go index d6f69f40..973512d7 100644 --- a/x/logic/keeper/migrations_test.go +++ b/x/logic/keeper/migrations_test.go @@ -6,8 +6,8 @@ import ( "io/fs" "testing" - "github.com/golang/mock/gomock" "github.com/samber/lo" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/keeper/msg_server_test.go b/x/logic/keeper/msg_server_test.go index 651e9c6f..d7443cb8 100644 --- a/x/logic/keeper/msg_server_test.go +++ b/x/logic/keeper/msg_server_test.go @@ -6,7 +6,7 @@ import ( "io/fs" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/meter/weighted_test.go b/x/logic/meter/weighted_test.go index 3fd9ac42..e9350fb5 100644 --- a/x/logic/meter/weighted_test.go +++ b/x/logic/meter/weighted_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/predicate/bank_test.go b/x/logic/predicate/bank_test.go index fef6c84a..6a3a8e33 100644 --- a/x/logic/predicate/bank_test.go +++ b/x/logic/predicate/bank_test.go @@ -9,8 +9,8 @@ import ( "github.com/axone-protocol/prolog/engine" dbm "github.com/cosmos/cosmos-db" - "github.com/golang/mock/gomock" "github.com/samber/lo" + "go.uber.org/mock/gomock" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/logic/predicate/builtin_test.go b/x/logic/predicate/builtin_test.go index 8e733d76..adef21cf 100644 --- a/x/logic/predicate/builtin_test.go +++ b/x/logic/predicate/builtin_test.go @@ -6,7 +6,7 @@ import ( "github.com/axone-protocol/prolog/engine" dbm "github.com/cosmos/cosmos-db" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/predicate/util_test.go b/x/logic/predicate/util_test.go index 8105a6b5..d4935b41 100644 --- a/x/logic/predicate/util_test.go +++ b/x/logic/predicate/util_test.go @@ -6,7 +6,7 @@ import ( "testing" dbm "github.com/cosmos/cosmos-db" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/smartystreets/goconvey/convey" diff --git a/x/logic/testutil/expected_keepers_mocks.go b/x/logic/testutil/expected_keepers_mocks.go index 74767509..0f014c3e 100644 --- a/x/logic/testutil/expected_keepers_mocks.go +++ b/x/logic/testutil/expected_keepers_mocks.go @@ -10,7 +10,7 @@ import ( types "github.com/cosmos/cosmos-sdk/types" types0 "github.com/cosmos/cosmos-sdk/x/auth/types" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockAccountKeeper is a mock of AccountKeeper interface. diff --git a/x/logic/testutil/fs_mocks.go b/x/logic/testutil/fs_mocks.go index 5fb390d0..b9f854b0 100644 --- a/x/logic/testutil/fs_mocks.go +++ b/x/logic/testutil/fs_mocks.go @@ -8,7 +8,7 @@ import ( fs "io/fs" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockFS is a mock of FS interface. diff --git a/x/logic/testutil/gas_mocks.go b/x/logic/testutil/gas_mocks.go index 8e65926b..4c14364a 100644 --- a/x/logic/testutil/gas_mocks.go +++ b/x/logic/testutil/gas_mocks.go @@ -7,7 +7,7 @@ package testutil import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockGasMeter is a mock of GasMeter interface. diff --git a/x/logic/testutil/interface_registry_mocks.go b/x/logic/testutil/interface_registry_mocks.go index 9df40a55..e8f28bf9 100644 --- a/x/logic/testutil/interface_registry_mocks.go +++ b/x/logic/testutil/interface_registry_mocks.go @@ -10,7 +10,7 @@ import ( signing "cosmossdk.io/x/tx/signing" types "github.com/cosmos/cosmos-sdk/codec/types" proto "github.com/cosmos/gogoproto/proto" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) diff --git a/x/logic/testutil/keeper_mocks.go b/x/logic/testutil/keeper_mocks.go index 4f105758..88ddec0a 100644 --- a/x/logic/testutil/keeper_mocks.go +++ b/x/logic/testutil/keeper_mocks.go @@ -5,8 +5,8 @@ import ( "fmt" "strconv" - "github.com/golang/mock/gomock" "github.com/samber/lo" + "go.uber.org/mock/gomock" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/logic/testutil/read_file_fs_mocks.go b/x/logic/testutil/read_file_fs_mocks.go index 3ba3269d..6fbccf56 100644 --- a/x/logic/testutil/read_file_fs_mocks.go +++ b/x/logic/testutil/read_file_fs_mocks.go @@ -8,7 +8,7 @@ import ( fs "io/fs" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockReadFileFS is a mock of ReadFileFS interface. diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index c5510ca9..587f2715 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" "cosmossdk.io/collections" "cosmossdk.io/math" diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 3a321c3c..afb43a69 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -4,8 +4,8 @@ import ( gocontext "context" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" storetypes "cosmossdk.io/store/types" diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index e4673853..5ae5a8db 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" diff --git a/x/mint/testutil/expected_keepers_mocks.go b/x/mint/testutil/expected_keepers_mocks.go index 3d05852c..86543681 100644 --- a/x/mint/testutil/expected_keepers_mocks.go +++ b/x/mint/testutil/expected_keepers_mocks.go @@ -10,7 +10,7 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockStakingKeeper is a mock of StakingKeeper interface. diff --git a/x/vesting/msg_server_test.go b/x/vesting/msg_server_test.go index df28eaad..646d28d9 100644 --- a/x/vesting/msg_server_test.go +++ b/x/vesting/msg_server_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttime "github.com/cometbft/cometbft/types/time" diff --git a/x/vesting/testutil/expected_keepers_mocks.go b/x/vesting/testutil/expected_keepers_mocks.go index f27d3b35..cdd5f4fb 100644 --- a/x/vesting/testutil/expected_keepers_mocks.go +++ b/x/vesting/testutil/expected_keepers_mocks.go @@ -9,7 +9,7 @@ import ( reflect "reflect" types "github.com/cosmos/cosmos-sdk/types" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockBankKeeper is a mock of BankKeeper interface.