From 29daa3868a8e9b9776b291cd6eacee7f4aa49993 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Tue, 21 Nov 2023 18:01:08 +0100 Subject: [PATCH] update tests --- x/incentive/msgs_test.go | 32 +++++++++++--------------------- x/leverage/types/tx_test.go | 23 +++-------------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/x/incentive/msgs_test.go b/x/incentive/msgs_test.go index 5b0db1d38d..692d698b53 100644 --- a/x/incentive/msgs_test.go +++ b/x/incentive/msgs_test.go @@ -6,6 +6,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "gotest.tools/v3/assert" "github.com/umee-network/umee/v6/util/coin" @@ -57,33 +58,22 @@ func TestMsgs(t *testing.T) { } } -// functions required in msgs.go which are not part of sdk.Msg -type sdkmsg interface { - Route() string - Type() string - GetSignBytes() []byte -} - -func TestRoutes(t *testing.T) { +func TestLegacyMsg(t *testing.T) { t.Parallel() - msgs := []sdkmsg{ - *incentive.NewMsgBond(testAddr, uToken), - *incentive.NewMsgBeginUnbonding(testAddr, uToken), - *incentive.NewMsgEmergencyUnbond(testAddr, uToken), - *incentive.NewMsgClaim(testAddr), - *incentive.NewMsgSponsor(testAddr, 3), - *incentive.NewMsgGovCreatePrograms(govAddr, []incentive.IncentiveProgram{program}), - *incentive.NewMsgGovSetParams(govAddr, incentive.DefaultParams()), + msgs := []legacytx.LegacyMsg{ + incentive.NewMsgBond(testAddr, uToken), + incentive.NewMsgBeginUnbonding(testAddr, uToken), + incentive.NewMsgEmergencyUnbond(testAddr, uToken), + incentive.NewMsgClaim(testAddr), + incentive.NewMsgSponsor(testAddr, 3), + incentive.NewMsgGovCreatePrograms(govAddr, []incentive.IncentiveProgram{program}), + incentive.NewMsgGovSetParams(govAddr, incentive.DefaultParams()), } for _, msg := range msgs { - // check for non-empty returns for now assert.Assert(t, len(msg.GetSignBytes()) != 0) - // exact match required assert.Equal(t, - // example: "/umee.incentive.v1.MsgBond" - // with %T returning "incentive.MsgBond" addV1ToType(fmt.Sprintf("/umee.%T", msg)), msg.Type(), ) @@ -92,5 +82,5 @@ func TestRoutes(t *testing.T) { // addV1ToType replaces "incentive." with "incentive.v1." func addV1ToType(s string) string { - return strings.Replace(s, "incentive", "incentive.v1", 1) + return strings.Replace(s, "*incentive", "incentive.v1", 1) } diff --git a/x/leverage/types/tx_test.go b/x/leverage/types/tx_test.go index a46e06ec57..9fd4635420 100644 --- a/x/leverage/types/tx_test.go +++ b/x/leverage/types/tx_test.go @@ -9,6 +9,7 @@ import ( "gotest.tools/v3/assert" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) const ( @@ -47,15 +48,8 @@ func TestTxs(t *testing.T) { } } -// functions required in msgs.go which are not part of sdk.Msg -type sdkmsg interface { - Route() string - Type() string - GetSignBytes() []byte -} - -func TestRoutes(t *testing.T) { - txs := []sdkmsg{ +func TestLegacyMsg(t *testing.T) { + txs := []legacytx.LegacyMsg{ types.NewMsgSupply(testAddr, token), types.NewMsgWithdraw(testAddr, uToken), types.NewMsgMaxWithdraw(testAddr, denom), @@ -70,25 +64,14 @@ func TestRoutes(t *testing.T) { } for _, tx := range txs { - assert.Equal(t, - // example: "/umee.leverage.v1.MsgSupply" - // with %T returning "*types.MsgSupply" - addV1ToType(fmt.Sprintf("/umee.%T", tx)), - tx.Route(), - ) - // check for non-empty returns for now assert.Assert(t, len(tx.GetSignBytes()) != 0) - // exact match required assert.Equal(t, - // example: "/umee.leverage.v1.MsgSupply" - // with %T returning "*types.MsgSupply" addV1ToType(fmt.Sprintf("/umee.%T", tx)), tx.Type(), ) } } -// addV1ToType replaces "*types" with "leverage.v1" func addV1ToType(s string) string { return strings.Replace(s, "*types", "leverage.v1", 1) }