From 4956e742270ebf7fbc00cdd7dce3a873d007af6e Mon Sep 17 00:00:00 2001 From: "elprogramadorgt8@gmail.com" Date: Fri, 25 Oct 2024 17:54:45 -0500 Subject: [PATCH 1/2] refactor(mock): Switch mocking library to go.uber.org/mock --- Makefile | 2 +- x/logic/fs/composite/fs_test.go | 3 +-- 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/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/testutil/expected_keepers_mocks.go | 2 +- 23 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 4eed50ff0..a8b3b299b 100644 --- a/Makefile +++ b/Makefile @@ -372,7 +372,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@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/x/logic/fs/composite/fs_test.go b/x/logic/fs/composite/fs_test.go index a8e245cb4..337035e42 100644 --- a/x/logic/fs/composite/fs_test.go +++ b/x/logic/fs/composite/fs_test.go @@ -8,9 +8,8 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" - . "github.com/smartystreets/goconvey/convey" + "go.uber.org/mock/gomock" "github.com/axone-protocol/axoned/v10/x/logic/fs/wasm" "github.com/axone-protocol/axoned/v10/x/logic/testutil" diff --git a/x/logic/fs/filtered/fs_test.go b/x/logic/fs/filtered/fs_test.go index b4232ef54..9f0aefc1d 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 aefd24054..7367b8798 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 aec6aa647..120413c05 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 d90edfb78..03669fd93 100644 --- a/x/logic/keeper/grpc_query_ask_test.go +++ b/x/logic/keeper/grpc_query_ask_test.go @@ -7,7 +7,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 7161b9025..846c58649 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/msg_server_test.go b/x/logic/keeper/msg_server_test.go index 651e9c6fa..d7443cb85 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 3fd9ac42d..e9350fb5c 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 39622b1fa..d8d2dd317 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 8e733d768..adef21cf6 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 8105a6b53..d4935b411 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 74767509f..0f014c3e4 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 5fb390d05..b9f854b01 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 8e65926bf..4c14364a5 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 9df40a550..e8f28bf9e 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 4f105758a..88ddec0af 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 3ba3269d5..6fbccf560 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 c5510ca93..587f2715c 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 3a321c3ca..afb43a691 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 e46738539..5ae5a8dbb 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 3d05852c2..86543681a 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/testutil/expected_keepers_mocks.go b/x/vesting/testutil/expected_keepers_mocks.go index f27d3b35b..cdd5f4fb1 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. From 6e085d9891a50008dd9bebf8ca62d2a29a06c634 Mon Sep 17 00:00:00 2001 From: "elprogramadorgt8@gmail.com" Date: Tue, 29 Oct 2024 09:47:08 -0500 Subject: [PATCH 2/2] fix(mock): missing testing file and installation version --- go.mod | 5 +++-- x/vesting/msg_server_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 943b2601e..1af4f1563 100644 --- a/go.mod +++ b/go.mod @@ -55,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 @@ -288,14 +289,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/x/vesting/msg_server_test.go b/x/vesting/msg_server_test.go index df28eaadf..646d28d97 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"