From fdcb5568a5f4cd288b6f4b331dd3e175ecc3bc90 Mon Sep 17 00:00:00 2001 From: aleem1314 Date: Tue, 2 Aug 2022 14:57:40 +0530 Subject: [PATCH] chore: fix failing tests --- scripts/test_cover.sh | 2 +- x/ecocredit/basket/codec.go | 11 +++++++++++ x/ecocredit/basket/msg_put_test.go | 13 ------------- x/ecocredit/basket/msg_take_test.go | 13 ------------- x/ecocredit/core/codec.go | 11 +++++++++++ x/ecocredit/marketplace/codec.go | 11 +++++++++++ x/ecocredit/server/basket/msg_put_test.go | 5 ----- x/ecocredit/server/basket/msg_take_test.go | 6 ------ x/ecocredit/server/testsuite/suite.go | 5 ----- 9 files changed, 34 insertions(+), 43 deletions(-) diff --git a/scripts/test_cover.sh b/scripts/test_cover.sh index 38199d843c..016ccb5984 100755 --- a/scripts/test_cover.sh +++ b/scripts/test_cover.sh @@ -15,7 +15,7 @@ for m in ${SUBMODULES[@]}; do cd $CURDIR/$m PKGS=$(go list ./...) for pkg in ${PKGS[@]}; do - go test -v -timeout 30m -coverpkg=all -coverprofile=profile.out -covermode=atomic -tags="norace ledger test_ledger_mock rocksdb_build $EXPERIMENTAL_TAG" "$pkg" + go test -v -timeout 30m -coverpkg=all -coverprofile=profile.out -covermode=atomic -tags="norace ledger test_ledger_mock $EXPERIMENTAL_TAG" "$pkg" if [ -f profile.out ]; then tail -n +2 profile.out >> $CURDIR/coverage.txt; rm profile.out diff --git a/x/ecocredit/basket/codec.go b/x/ecocredit/basket/codec.go index 00f3cd4add..765a4c1519 100644 --- a/x/ecocredit/basket/codec.go +++ b/x/ecocredit/basket/codec.go @@ -2,8 +2,12 @@ package basket import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) func RegisterTypes(registry codectypes.InterfaceRegistry) { @@ -21,5 +25,12 @@ var ( ) func init() { + RegisterLegacyAminoCodec(legacy.Cdc) RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/ecocredit/basket/msg_put_test.go b/x/ecocredit/basket/msg_put_test.go index 73c3e663f3..000d404a4d 100644 --- a/x/ecocredit/basket/msg_put_test.go +++ b/x/ecocredit/basket/msg_put_test.go @@ -6,10 +6,6 @@ import ( "github.com/gogo/protobuf/jsonpb" "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/regen-network/regen-ledger/types" ) type msgPutSuite struct { @@ -22,15 +18,6 @@ func TestMsgPut(t *testing.T) { gocuke.NewRunner(t, &msgPutSuite{}).Path("./features/msg_put.feature").Run() } -func (s *msgPutSuite) Before(t gocuke.TestingT) { - s.t = t - - // TODO: remove after updating to cosmos-sdk v0.46 #857 - sdk.SetCoinDenomRegex(func() string { - return types.CoinDenomRegex - }) -} - func (s *msgPutSuite) TheMessage(a gocuke.DocString) { s.msg = &MsgPut{} err := jsonpb.UnmarshalString(a.Content, s.msg) diff --git a/x/ecocredit/basket/msg_take_test.go b/x/ecocredit/basket/msg_take_test.go index c35715b133..88cca6a532 100644 --- a/x/ecocredit/basket/msg_take_test.go +++ b/x/ecocredit/basket/msg_take_test.go @@ -6,10 +6,6 @@ import ( "github.com/gogo/protobuf/jsonpb" "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/regen-network/regen-ledger/types" ) type msgTakeSuite struct { @@ -22,15 +18,6 @@ func TestMsgTake(t *testing.T) { gocuke.NewRunner(t, &msgTakeSuite{}).Path("./features/msg_take.feature").Run() } -func (s *msgTakeSuite) Before(t gocuke.TestingT) { - s.t = t - - // TODO: remove after updating to cosmos-sdk v0.46 #857 - sdk.SetCoinDenomRegex(func() string { - return types.CoinDenomRegex - }) -} - func (s *msgTakeSuite) TheMessage(a gocuke.DocString) { s.msg = &MsgTake{} err := jsonpb.UnmarshalString(a.Content, s.msg) diff --git a/x/ecocredit/core/codec.go b/x/ecocredit/core/codec.go index fc435ac9e4..0e2f56e06a 100644 --- a/x/ecocredit/core/codec.go +++ b/x/ecocredit/core/codec.go @@ -2,8 +2,12 @@ package core import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -35,5 +39,12 @@ var ( ) func init() { + RegisterLegacyAminoCodec(legacy.Cdc) RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/ecocredit/marketplace/codec.go b/x/ecocredit/marketplace/codec.go index 215185b7d9..a93207d69e 100644 --- a/x/ecocredit/marketplace/codec.go +++ b/x/ecocredit/marketplace/codec.go @@ -2,8 +2,12 @@ package marketplace import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -24,5 +28,12 @@ var ( ) func init() { + RegisterLegacyAminoCodec(legacy.Cdc) RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/ecocredit/server/basket/msg_put_test.go b/x/ecocredit/server/basket/msg_put_test.go index e3b93dc8c0..6660d70ca8 100644 --- a/x/ecocredit/server/basket/msg_put_test.go +++ b/x/ecocredit/server/basket/msg_put_test.go @@ -57,11 +57,6 @@ func (s *putSuite) Before(t gocuke.TestingT) { s.batchDenom = "C01-001-20200101-20210101-001" s.basketDenom = "eco.uC.NCT" s.tradableCredits = "100" - - // TODO: remove after updating to cosmos-sdk v0.46 #857 - sdk.SetCoinDenomRegex(func() string { - return types.CoinDenomRegex - }) } func (s *putSuite) ACreditType() { diff --git a/x/ecocredit/server/basket/msg_take_test.go b/x/ecocredit/server/basket/msg_take_test.go index f33a08332c..4cd657e9d8 100644 --- a/x/ecocredit/server/basket/msg_take_test.go +++ b/x/ecocredit/server/basket/msg_take_test.go @@ -6,7 +6,6 @@ import ( "github.com/gogo/protobuf/jsonpb" "github.com/regen-network/gocuke" - "github.com/regen-network/regen-ledger/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -55,11 +54,6 @@ func (s *takeSuite) Before(t gocuke.TestingT) { s.basketDenom = "eco.uC.NCT" s.tokenAmount = "100" s.jurisdiction = "US-WA" - - // TODO: remove after updating to cosmos-sdk v0.46 #857 - sdk.SetCoinDenomRegex(func() string { - return types.CoinDenomRegex - }) } func (s *takeSuite) ACreditType() { diff --git a/x/ecocredit/server/testsuite/suite.go b/x/ecocredit/server/testsuite/suite.go index b193cf47d4..05338ae862 100644 --- a/x/ecocredit/server/testsuite/suite.go +++ b/x/ecocredit/server/testsuite/suite.go @@ -84,11 +84,6 @@ func NewIntegrationTestSuite(fixtureFactory testutil.FixtureFactory, paramSpace } func (s *IntegrationTestSuite) SetupSuite() { - // TODO: remove after updating to cosmos-sdk v0.46 #857 - sdk.SetCoinDenomRegex(func() string { - return types.CoinDenomRegex - }) - s.fixture = s.fixtureFactory.Setup() s.codec = s.fixture.Codec()