diff --git a/x/crosschain/client/cli/cli_out_tx_tracker_test.go b/x/crosschain/client/cli/cli_out_tx_tracker_test.go index 01976193dc..7346e573c5 100644 --- a/x/crosschain/client/cli/cli_out_tx_tracker_test.go +++ b/x/crosschain/client/cli/cli_out_tx_tracker_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/app" "github.com/zeta-chain/zetacore/testutil/network" "github.com/zeta-chain/zetacore/testutil/nullify" @@ -15,7 +15,7 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty t.Helper() cfg := network.DefaultConfig() state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + assert.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) for i := 0; i < n; i++ { outTxTracker := types.OutTxTracker{ @@ -25,7 +25,7 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty state.OutTxTrackerList = append(state.OutTxTrackerList, outTxTracker) } buf, err := cfg.Codec.MarshalJSON(&state) - require.NoError(t, err) + assert.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf //cfg.GenesisState = network.SetupZetaGenesisState(t, cfg.GenesisState, cfg.Codec) net, err := network.New(t, app.NodeDir, cfg) @@ -72,14 +72,14 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowOutTxTracker(), args) // if tc.err != nil { // stat, ok := status.FromError(tc.err) -// require.True(t, ok) -// require.ErrorIs(t, stat.Err(), tc.err) +// assert.True(t, ok) +// assert.ErrorIs(t, stat.Err(), tc.err) // } else { -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryGetOutTxTrackerResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.NotNil(t, resp.OutTxTracker) -// require.Equal(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.NotNil(t, resp.OutTxTracker) +// assert.Equal(t, // nullify.Fill(&tc.obj), // nullify.Fill(&resp.OutTxTracker), // ) @@ -112,11 +112,11 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty // for i := 0; i < len(objs); i += step { // args := request(nil, uint64(i), uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListOutTxTracker(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllOutTxTrackerResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.LessOrEqual(t, len(resp.OutTxTracker), step) -// require.Subset(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.LessOrEqual(t, len(resp.OutTxTracker), step) +// assert.Subset(t, // nullify.Fill(objs), // nullify.Fill(resp.OutTxTracker), // ) @@ -128,11 +128,11 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty // for i := 0; i < len(objs); i += step { // args := request(next, 0, uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListOutTxTracker(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllOutTxTrackerResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.LessOrEqual(t, len(resp.OutTxTracker), step) -// require.Subset(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.LessOrEqual(t, len(resp.OutTxTracker), step) +// assert.Subset(t, // nullify.Fill(objs), // nullify.Fill(resp.OutTxTracker), // ) @@ -142,12 +142,12 @@ func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []ty // t.Run("Total", func(t *testing.T) { // args := request(nil, 0, uint64(len(objs)), true) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListOutTxTracker(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllOutTxTrackerResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.NoError(t, err) -// require.Equal(t, len(objs), int(resp.Pagination.Total)) -// require.ElementsMatch(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.NoError(t, err) +// assert.Equal(t, len(objs), int(resp.Pagination.Total)) +// assert.ElementsMatch(t, // nullify.Fill(objs), // nullify.Fill(resp.OutTxTracker), // ) diff --git a/x/crosschain/client/integrationtests/cli_helpers.go b/x/crosschain/client/integrationtests/cli_helpers.go index 3195782031..ec9465d48e 100644 --- a/x/crosschain/client/integrationtests/cli_helpers.go +++ b/x/crosschain/client/integrationtests/cli_helpers.go @@ -15,7 +15,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/network" @@ -44,7 +44,7 @@ func WriteToNewTempFile(t testing.TB, s string) *os.File { fp := TempFile(t) _, err := fp.WriteString(s) - require.Nil(t, err) + assert.Nil(t, err) return fp } @@ -54,7 +54,7 @@ func TempFile(t testing.TB) *os.File { t.Helper() fp, err := os.CreateTemp(GetTempDir(t), "") - require.NoError(t, err) + assert.NoError(t, err) return fp } @@ -67,10 +67,10 @@ func GetTempDir(t testing.TB) string { // https://github.com/cosmos/cosmos-sdk/pull/10341 for // this change's rationale. tempdir, err := os.MkdirTemp("", "") - require.NoError(t, err) + assert.NoError(t, err) t.Cleanup(func() { err := os.RemoveAll(tempdir) - require.NoError(t, err) + assert.NoError(t, err) }) return tempdir } @@ -86,11 +86,11 @@ func BuildSignedDeploySystemContract(t testing.TB, val *network.Validator, denom fmt.Sprintf("--%s=%d", flags.FlagGas, 4000000), } out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, txArgs) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -112,11 +112,11 @@ func BuildSignedUpdateSystemContract( } args := append([]string{systemContractAddress}, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -145,11 +145,11 @@ func BuildSignedDeployETHZRC20( "1000000", }, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -171,11 +171,11 @@ func BuildSignedGasPriceVote(t testing.TB, val *network.Validator, denom string, } args := append(inboundVoterArgs, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -196,11 +196,11 @@ func BuildSignedTssVote(t testing.TB, val *network.Validator, denom string, acco } args := append(inboundVoterArgs, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -239,12 +239,12 @@ func BuildSignedOutboundVote( } args := append(outboundVoterArgs, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } @@ -274,11 +274,11 @@ func BuildSignedInboundVote(t testing.TB, val *network.Validator, denom string, } args := append(inboundVoterArgs, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - require.NoError(t, err) + assert.NoError(t, err) unsignerdTx := WriteToNewTempFile(t, out.String()) res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) - require.NoError(t, err) + assert.NoError(t, err) return WriteToNewTempFile(t, res.String()) } diff --git a/x/crosschain/genesis_test.go b/x/crosschain/genesis_test.go index 3ce6a94875..052e075108 100644 --- a/x/crosschain/genesis_test.go +++ b/x/crosschain/genesis_test.go @@ -3,7 +3,7 @@ package crosschain_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/testutil/sample" @@ -46,10 +46,10 @@ func TestGenesis(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) crosschain.InitGenesis(ctx, *k, genesisState) got := crosschain.ExportGenesis(ctx, *k) - require.NotNil(t, got) + assert.NotNil(t, got) // Compare genesis after init and export nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState, *got) + assert.Equal(t, genesisState, *got) } diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index 12263a3587..4b1a0bbe39 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -6,7 +6,7 @@ import ( "time" "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -268,8 +268,8 @@ func TestKeeper_CheckAndUpdateCctxGasPrice(t *testing.T) { // ensure median gas price is set medianGasPrice, isFound := k.GetMedianGasPriceInUint(ctx, chainID) - require.True(t, isFound) - require.True(t, medianGasPrice.Equal(math.NewUint(tc.medianGasPrice))) + assert.True(t, isFound) + assert.True(t, medianGasPrice.Equal(math.NewUint(tc.medianGasPrice))) } // set block timestamp @@ -285,23 +285,23 @@ func TestKeeper_CheckAndUpdateCctxGasPrice(t *testing.T) { gasPriceIncrease, feesPaid, err := k.CheckAndUpdateCctxGasPrice(ctx, tc.cctx, tc.flags) if tc.isError { - require.Error(t, err) + assert.Error(t, err) return } - require.NoError(t, err) + assert.NoError(t, err) // check values - require.True(t, gasPriceIncrease.Equal(tc.expectedGasPriceIncrease), "expected %s, got %s", tc.expectedGasPriceIncrease.String(), gasPriceIncrease.String()) - require.True(t, feesPaid.Equal(tc.expectedAdditionalFees), "expected %s, got %s", tc.expectedAdditionalFees.String(), feesPaid.String()) + assert.True(t, gasPriceIncrease.Equal(tc.expectedGasPriceIncrease), "expected %s, got %s", tc.expectedGasPriceIncrease.String(), gasPriceIncrease.String()) + assert.True(t, feesPaid.Equal(tc.expectedAdditionalFees), "expected %s, got %s", tc.expectedAdditionalFees.String(), feesPaid.String()) // check cctx if !tc.expectedGasPriceIncrease.IsZero() { cctx, found := k.GetCrossChainTx(ctx, tc.cctx.Index) - require.True(t, found) + assert.True(t, found) newGasPrice, err := cctx.GetCurrentOutTxParam().GetGasPrice() - require.NoError(t, err) - require.EqualValues(t, tc.expectedGasPriceIncrease.AddUint64(previousGasPrice).Uint64(), newGasPrice, "%d - %d", tc.expectedGasPriceIncrease.Uint64(), previousGasPrice) - require.EqualValues(t, tc.blockTimestamp.Unix(), cctx.CctxStatus.LastUpdateTimestamp) + assert.NoError(t, err) + assert.EqualValues(t, tc.expectedGasPriceIncrease.AddUint64(previousGasPrice).Uint64(), newGasPrice, "%d - %d", tc.expectedGasPriceIncrease.Uint64(), previousGasPrice) + assert.EqualValues(t, tc.blockTimestamp.Unix(), cctx.CctxStatus.LastUpdateTimestamp) } }) } diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index 13218eca13..764ce660d9 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -15,8 +15,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -188,9 +186,9 @@ func TestSendQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.Cctx(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -216,7 +214,7 @@ func TestSendQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.CctxAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) } @@ -227,7 +225,7 @@ func TestSendQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.CctxAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) } @@ -236,11 +234,11 @@ func TestSendQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.CctxAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.CctxAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/crosschain/keeper/cctx_utils_test.go b/x/crosschain/keeper/cctx_utils_test.go index 2d122bce7a..27c1509ffb 100644 --- a/x/crosschain/keeper/cctx_utils_test.go +++ b/x/crosschain/keeper/cctx_utils_test.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -44,12 +44,12 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.NoError(t, err) + assert.NoError(t, err) // check amount deposited in balance balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) - require.NoError(t, err) - require.Equal(t, uint64(42), balance.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(42), balance.Uint64()) // can refund again err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ @@ -61,10 +61,10 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.NoError(t, err) + assert.NoError(t, err) balance, err = zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) - require.NoError(t, err) - require.Equal(t, uint64(84), balance.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(84), balance.Uint64()) }) t.Run("should fail with invalid cctx", func(t *testing.T) { @@ -76,7 +76,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.ErrorContains(t, err, "unsupported coin type") + assert.ErrorContains(t, err, "unsupported coin type") err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -84,7 +84,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.ErrorContains(t, err, "unsupported coin type") + assert.ErrorContains(t, err, "unsupported coin type") err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -93,7 +93,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.ErrorContains(t, err, "only EVM chains are supported") + assert.ErrorContains(t, err, "only EVM chains are supported") err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -103,7 +103,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.ErrorContains(t, err, "invalid sender address") + assert.ErrorContains(t, err, "invalid sender address") err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -114,7 +114,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }, math.Uint{}, ) - require.ErrorContains(t, err, "no amount to refund") + assert.ErrorContains(t, err, "no amount to refund") err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -124,7 +124,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.ZeroUint(), ) - require.ErrorContains(t, err, "no amount to refund") + assert.ErrorContains(t, err, "no amount to refund") // the foreign coin has not been set err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ @@ -136,7 +136,7 @@ func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { }}, math.NewUint(42), ) - require.ErrorContains(t, err, "zrc not found") + assert.ErrorContains(t, err, "zrc not found") }) } @@ -145,8 +145,8 @@ func TestGetRevertGasLimit(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{}) - require.NoError(t, err) - require.Equal(t, uint64(0), gasLimit) + assert.NoError(t, err) + assert.Equal(t, uint64(0), gasLimit) }) t.Run("should return 0 if coin type is not gas or erc20", func(t *testing.T) { @@ -156,8 +156,8 @@ func TestGetRevertGasLimit(t *testing.T) { InboundTxParams: &types.InboundTxParams{ CoinType: common.CoinType_Zeta, }}) - require.NoError(t, err) - require.Equal(t, uint64(0), gasLimit) + assert.NoError(t, err) + assert.Equal(t, uint64(0), gasLimit) }) t.Run("should return the gas limit of the gas token", func(t *testing.T) { @@ -169,15 +169,15 @@ func TestGetRevertGasLimit(t *testing.T) { gas := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foo", "FOO") _, err := zk.FungibleKeeper.UpdateZRC20GasLimit(ctx, gas, big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: common.CoinType_Gas, SenderChainId: chainID, }}) - require.NoError(t, err) - require.Equal(t, uint64(42), gasLimit) + assert.NoError(t, err) + assert.Equal(t, uint64(42), gasLimit) }) t.Run("should return the gas limit of the associated asset", func(t *testing.T) { @@ -199,7 +199,7 @@ func TestGetRevertGasLimit(t *testing.T) { ) _, err := zk.FungibleKeeper.UpdateZRC20GasLimit(ctx, zrc20Addr, big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -207,8 +207,8 @@ func TestGetRevertGasLimit(t *testing.T) { SenderChainId: chainID, Asset: asset, }}) - require.NoError(t, err) - require.Equal(t, uint64(42), gasLimit) + assert.NoError(t, err) + assert.Equal(t, uint64(42), gasLimit) }) t.Run("should fail if no gas coin found", func(t *testing.T) { @@ -219,7 +219,7 @@ func TestGetRevertGasLimit(t *testing.T) { CoinType: common.CoinType_Gas, SenderChainId: 999999, }}) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) t.Run("should fail if query gas limit for gas coin fails", func(t *testing.T) { @@ -240,7 +240,7 @@ func TestGetRevertGasLimit(t *testing.T) { CoinType: common.CoinType_Gas, SenderChainId: chainID, }}) - require.ErrorIs(t, err, fungibletypes.ErrContractCall) + assert.ErrorIs(t, err, fungibletypes.ErrContractCall) }) t.Run("should fail if no asset found", func(t *testing.T) { @@ -251,7 +251,7 @@ func TestGetRevertGasLimit(t *testing.T) { CoinType: common.CoinType_ERC20, SenderChainId: 999999, }}) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) t.Run("should fail if query gas limit for asset fails", func(t *testing.T) { @@ -275,6 +275,6 @@ func TestGetRevertGasLimit(t *testing.T) { SenderChainId: chainID, Asset: asset, }}) - require.ErrorIs(t, err, fungibletypes.ErrContractCall) + assert.ErrorIs(t, err, fungibletypes.ErrContractCall) }) } diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index 65483d89c1..08287b7047 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -8,8 +8,8 @@ import ( "cosmossdk.io/math" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -41,8 +41,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, nil, ) - require.NoError(t, err) - require.False(t, reverted) + assert.NoError(t, err) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -70,8 +70,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, nil, ) - require.ErrorIs(t, err, errDeposit) - require.False(t, reverted) + assert.ErrorIs(t, err, errDeposit) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -114,8 +114,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.NoError(t, err) - require.False(t, reverted) + assert.NoError(t, err) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -159,8 +159,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, errDeposit) - require.False(t, reverted) + assert.ErrorIs(t, err, errDeposit) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -204,8 +204,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, errDeposit) - require.True(t, reverted) + assert.ErrorIs(t, err, errDeposit) + assert.True(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -248,8 +248,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, fungibletypes.ErrForeignCoinCapReached) - require.True(t, reverted) + assert.ErrorIs(t, err, fungibletypes.ErrForeignCoinCapReached) + assert.True(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -292,8 +292,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, fungibletypes.ErrPausedZRC20) - require.True(t, reverted) + assert.ErrorIs(t, err, fungibletypes.ErrPausedZRC20) + assert.True(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -334,8 +334,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, fungibletypes.ErrCallNonContract) - require.True(t, reverted) + assert.ErrorIs(t, err, fungibletypes.ErrCallNonContract) + assert.True(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -358,7 +358,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.ErrorIs(t, err, types.ErrUnableToParseAddress) + assert.ErrorIs(t, err, types.ErrUnableToParseAddress) }) t.Run("should deposit into address if address is parsed", func(t *testing.T) { @@ -373,7 +373,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount := big.NewInt(42) data, err := hex.DecodeString("DEADBEEF") - require.NoError(t, err) + assert.NoError(t, err) fungibleMock.On( "ZRC20DepositAndCallContract", ctx, @@ -399,8 +399,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.NoError(t, err) - require.False(t, reverted) + assert.NoError(t, err) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) @@ -416,7 +416,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount := big.NewInt(42) data, err := hex.DecodeString("DEADBEEF") - require.NoError(t, err) + assert.NoError(t, err) fungibleMock.On( "ZRC20DepositAndCallContract", ctx, @@ -442,8 +442,8 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { }, senderChain, ) - require.NoError(t, err) - require.False(t, reverted) + assert.NoError(t, err) + assert.False(t, reverted) fungibleMock.AssertExpectations(t) }) diff --git a/x/crosschain/keeper/finalized_inbounds_test.go b/x/crosschain/keeper/finalized_inbounds_test.go index 9946024aa8..29cdf83b0e 100644 --- a/x/crosschain/keeper/finalized_inbounds_test.go +++ b/x/crosschain/keeper/finalized_inbounds_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -16,14 +16,14 @@ func TestKeeper_IsFinalizedInbound(t *testing.T) { chainID := sample.Chain(5).ChainId eventIndex := sample.EventIndex() k.AddFinalizedInbound(ctx, intxHash, chainID, eventIndex) - require.True(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) + assert.True(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) }) t.Run("check false for non-finalized inbound", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) intxHash := sample.Hash().String() chainID := sample.Chain(5).ChainId eventIndex := sample.EventIndex() - require.False(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) + assert.False(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) }) t.Run("check true for finalized inbound list", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -38,7 +38,7 @@ func TestKeeper_IsFinalizedInbound(t *testing.T) { k.AddFinalizedInbound(ctx, txHashList[i], chainIdList[i], eventIndexList[i]) } for i := 0; i < listSize; i++ { - require.True(t, k.IsFinalizedInbound(ctx, txHashList[i], chainIdList[i], eventIndexList[i])) + assert.True(t, k.IsFinalizedInbound(ctx, txHashList[i], chainIdList[i], eventIndexList[i])) } }) } @@ -50,7 +50,7 @@ func TestKeeper_AddFinalizedInbound(t *testing.T) { chainID := sample.Chain(5).ChainId eventIndex := sample.EventIndex() k.AddFinalizedInbound(ctx, intxHash, chainID, eventIndex) - require.True(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) + assert.True(t, k.IsFinalizedInbound(ctx, intxHash, chainID, eventIndex)) }) } @@ -58,7 +58,7 @@ func TestKeeper_GetAllFinalizedInbound(t *testing.T) { t.Run("check empty list", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) list := k.GetAllFinalizedInbound(ctx) - require.Empty(t, list) + assert.Empty(t, list) }) t.Run("check list", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -73,10 +73,10 @@ func TestKeeper_GetAllFinalizedInbound(t *testing.T) { k.AddFinalizedInbound(ctx, txHashList[i], chainIdList[i], eventIndexList[i]) } list := k.GetAllFinalizedInbound(ctx) - require.Equal(t, listSize, len(list)) + assert.Equal(t, listSize, len(list)) for i := 0; i < listSize; i++ { - require.Contains(t, list, types.FinalizedInboundKey(txHashList[i], chainIdList[i], eventIndexList[i])) + assert.Contains(t, list, types.FinalizedInboundKey(txHashList[i], chainIdList[i], eventIndexList[i])) } - require.NotContains(t, list, types.FinalizedInboundKey(sample.Hash().String(), sample.Chain(5).ChainId, sample.EventIndex())) + assert.NotContains(t, list, types.FinalizedInboundKey(sample.Hash().String(), sample.Chain(5).ChainId, sample.EventIndex())) }) } diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index d0a702daf5..b15b2065af 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" zetacommon "github.com/zeta-chain/zetacore/common" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -42,7 +42,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -67,10 +67,10 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { // total fees must be 21000*2+1000=43000 // if the input amount of the cctx is 1e16, the output amount must be 1e16-43000=9999999999957000 err = k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount)) - require.NoError(t, err) - require.Equal(t, uint64(9999999999957000), cctx.GetCurrentOutTxParam().Amount.Uint64()) - require.Equal(t, uint64(21_000), cctx.GetCurrentOutTxParam().OutboundTxGasLimit) - require.Equal(t, "2", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) + assert.NoError(t, err) + assert.Equal(t, uint64(9999999999957000), cctx.GetCurrentOutTxParam().Amount.Uint64()) + assert.Equal(t, uint64(21_000), cctx.GetCurrentOutTxParam().OutboundTxGasLimit) + assert.Equal(t, "2", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) }) t.Run("should fail if not coin type gas", func(t *testing.T) { @@ -82,7 +82,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, } err := k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount)) - require.ErrorIs(t, err, types.ErrInvalidCoinType) + assert.ErrorIs(t, err, types.ErrInvalidCoinType) }) t.Run("should fail if chain is not supported", func(t *testing.T) { @@ -93,7 +93,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, } err := k.PayGasNativeAndUpdateCctx(ctx, 999999, &cctx, math.NewUint(inputAmount)) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) }) t.Run("should fail if can't query the gas price", func(t *testing.T) { @@ -124,7 +124,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { } err := k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount)) - require.ErrorIs(t, err, types.ErrCannotFindGasParams) + assert.ErrorIs(t, err, types.ErrCannotFindGasParams) }) t.Run("should fail if not enough amount for the fee", func(t *testing.T) { @@ -143,7 +143,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -166,7 +166,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { // 42999 < 43000 err = k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(42999)) - require.ErrorIs(t, err, types.ErrNotEnoughGas) + assert.ErrorIs(t, err, types.ErrNotEnoughGas) }) } @@ -199,7 +199,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -233,15 +233,15 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // total fees in gas must be 21000*2+1000=43000 // we calculate what it represents in erc20 expectedInZeta, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, big.NewInt(43000), gasZRC20) - require.NoError(t, err) + assert.NoError(t, err) expectedInZRC20, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZRC4AmountsIn(ctx, expectedInZeta, zrc20Addr) - require.NoError(t, err) + assert.NoError(t, err) err = k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) - require.NoError(t, err) - require.Equal(t, inputAmount-expectedInZRC20.Uint64(), cctx.GetCurrentOutTxParam().Amount.Uint64()) - require.Equal(t, uint64(21_000), cctx.GetCurrentOutTxParam().OutboundTxGasLimit) - require.Equal(t, "2", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) + assert.NoError(t, err) + assert.Equal(t, inputAmount-expectedInZRC20.Uint64(), cctx.GetCurrentOutTxParam().Amount.Uint64()) + assert.Equal(t, uint64(21_000), cctx.GetCurrentOutTxParam().OutboundTxGasLimit) + assert.Equal(t, "2", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) }) t.Run("should fail if not coin type erc20", func(t *testing.T) { @@ -253,7 +253,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, } err := k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) - require.ErrorIs(t, err, types.ErrInvalidCoinType) + assert.ErrorIs(t, err, types.ErrInvalidCoinType) }) t.Run("should fail if chain is not supported", func(t *testing.T) { @@ -264,7 +264,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, } err := k.PayGasInERC20AndUpdateCctx(ctx, 999999, &cctx, math.NewUint(inputAmount), false) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) }) t.Run("should fail if can't query the gas price", func(t *testing.T) { @@ -295,7 +295,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { } err := k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) - require.ErrorIs(t, err, types.ErrCannotFindGasParams) + assert.ErrorIs(t, err, types.ErrCannotFindGasParams) }) t.Run("should fail if can't find the ZRC20", func(t *testing.T) { @@ -315,7 +315,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -341,7 +341,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { } err = k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) t.Run("should fail if liquidity pool not setup", func(t *testing.T) { @@ -371,7 +371,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -397,7 +397,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { } err = k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) - require.ErrorIs(t, err, types.ErrNoLiquidityPool) + assert.ErrorIs(t, err, types.ErrNoLiquidityPool) }) t.Run("should fail if not enough amount for the fee", func(t *testing.T) { @@ -427,7 +427,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { sdk.UnwrapSDKContext(ctx), fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) - require.NoError(t, err) + assert.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ ChainId: chainID, MedianIndex: 0, @@ -461,13 +461,13 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // total fees in gas must be 21000*2+1000=43000 // we calculate what it represents in erc20 expectedInZeta, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, big.NewInt(43000), gasZRC20) - require.NoError(t, err) + assert.NoError(t, err) expectedInZRC20, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZRC4AmountsIn(ctx, expectedInZeta, zrc20Addr) - require.NoError(t, err) + assert.NoError(t, err) // Provide expected value minus 1 err = k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUintFromBigInt(expectedInZRC20).SubUint64(1), false) - require.ErrorIs(t, err, types.ErrNotEnoughGas) + assert.ErrorIs(t, err, types.ErrNotEnoughGas) }) } @@ -504,16 +504,16 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { } // gasLimit * gasPrice * 2 = 1000 * 2 * 2 = 4000 expectedOutTxGasFeeInZeta, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, big.NewInt(4000), zrc20) - require.NoError(t, err) + assert.NoError(t, err) // the output amount must be input amount - (out tx fee in zeta + protocol flat fee) expectedFeeInZeta := types.GetProtocolFee().Add(math.NewUintFromBigInt(expectedOutTxGasFeeInZeta)) inputAmount := expectedFeeInZeta.Add(math.NewUint(100000)) err = k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, inputAmount, false) - require.NoError(t, err) - require.Equal(t, "100000", cctx.GetCurrentOutTxParam().Amount.String()) - require.Equal(t, "4", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) // gas price is doubled - require.True(t, cctx.ZetaFees.Equal(expectedFeeInZeta.Add(math.NewUint(100))), "expected %s, got %s", expectedFeeInZeta.String(), cctx.ZetaFees.String()) + assert.NoError(t, err) + assert.Equal(t, "100000", cctx.GetCurrentOutTxParam().Amount.String()) + assert.Equal(t, "4", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) // gas price is doubled + assert.True(t, cctx.ZetaFees.Equal(expectedFeeInZeta.Add(math.NewUint(100))), "expected %s, got %s", expectedFeeInZeta.String(), cctx.ZetaFees.String()) // can call with undefined zeta fees cctx = types.CrossChainTx{ @@ -528,14 +528,14 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { }, } expectedOutTxGasFeeInZeta, err = zk.FungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, big.NewInt(4000), zrc20) - require.NoError(t, err) + assert.NoError(t, err) expectedFeeInZeta = types.GetProtocolFee().Add(math.NewUintFromBigInt(expectedOutTxGasFeeInZeta)) inputAmount = expectedFeeInZeta.Add(math.NewUint(100000)) err = k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, inputAmount, false) - require.NoError(t, err) - require.Equal(t, "100000", cctx.GetCurrentOutTxParam().Amount.String()) - require.Equal(t, "4", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) // gas price is doubled - require.True(t, cctx.ZetaFees.Equal(expectedFeeInZeta), "expected %s, got %s", expectedFeeInZeta.String(), cctx.ZetaFees.String()) + assert.NoError(t, err) + assert.Equal(t, "100000", cctx.GetCurrentOutTxParam().Amount.String()) + assert.Equal(t, "4", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) // gas price is doubled + assert.True(t, cctx.ZetaFees.Equal(expectedFeeInZeta), "expected %s, got %s", expectedFeeInZeta.String(), cctx.ZetaFees.String()) }) t.Run("should fail if pay gas in zeta with coin type other than zeta", func(t *testing.T) { @@ -547,7 +547,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { }, } err := k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(100000), false) - require.ErrorIs(t, err, types.ErrInvalidCoinType) + assert.ErrorIs(t, err, types.ErrInvalidCoinType) }) t.Run("should fail if chain is not supported", func(t *testing.T) { @@ -558,7 +558,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { }, } err := k.PayGasInZetaAndUpdateCctx(ctx, 999999, &cctx, math.NewUint(100000), false) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) }) t.Run("should fail if can't query the gas price", func(t *testing.T) { @@ -589,7 +589,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { } err := k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(100000), false) - require.ErrorIs(t, err, types.ErrUnableToGetGasPrice) + assert.ErrorIs(t, err, types.ErrUnableToGetGasPrice) }) t.Run("should fail if not enough amount for the fee", func(t *testing.T) { @@ -623,12 +623,12 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { ZetaFees: math.NewUint(100), } expectedOutTxGasFeeInZeta, err := zk.FungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, big.NewInt(4000), zrc20) - require.NoError(t, err) + assert.NoError(t, err) expectedFeeInZeta := types.GetProtocolFee().Add(math.NewUintFromBigInt(expectedOutTxGasFeeInZeta)) // set input amount lower than total zeta fee inputAmount := expectedFeeInZeta.Sub(math.NewUint(1)) err = k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, inputAmount, false) - require.ErrorIs(t, err, types.ErrNotEnoughZetaBurnt) + assert.ErrorIs(t, err, types.ErrNotEnoughZetaBurnt) }) } diff --git a/x/crosschain/keeper/grpc_query_cctx_test.go b/x/crosschain/keeper/grpc_query_cctx_test.go index cd5d1e3c14..63b47e7f50 100644 --- a/x/crosschain/keeper/grpc_query_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_cctx_test.go @@ -5,7 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -68,19 +68,19 @@ func TestKeeper_CctxListPending(t *testing.T) { t.Run("should fail for empty req", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) _, err := k.CctxListPending(ctx, nil) - require.ErrorContains(t, err, "invalid request") + assert.ErrorContains(t, err, "invalid request") }) t.Run("should fail if limit is too high", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: keeper.MaxPendingCctxs + 1}) - require.ErrorContains(t, err, "limit exceeds max limit of") + assert.ErrorContains(t, err, "limit exceeds max limit of") }) t.Run("should fail if no TSS", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: 1}) - require.ErrorContains(t, err, "tss not found") + assert.ErrorContains(t, err, "tss not found") }) t.Run("should return empty list if no nonces", func(t *testing.T) { @@ -90,7 +90,7 @@ func TestKeeper_CctxListPending(t *testing.T) { zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: 1}) - require.ErrorContains(t, err, "pending nonces not found") + assert.ErrorContains(t, err, "pending nonces not found") }) t.Run("can retrieve pending cctx in range", func(t *testing.T) { @@ -101,16 +101,16 @@ func TestKeeper_CctxListPending(t *testing.T) { cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 2000, chainID, tss, zk) res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID, Limit: 100}) - require.NoError(t, err) - require.Equal(t, 100, len(res.CrossChainTx)) - require.EqualValues(t, cctxs[0:100], res.CrossChainTx) - require.EqualValues(t, uint64(1000), res.TotalPending) + assert.NoError(t, err) + assert.Equal(t, 100, len(res.CrossChainTx)) + assert.EqualValues(t, cctxs[0:100], res.CrossChainTx) + assert.EqualValues(t, uint64(1000), res.TotalPending) res, err = k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID}) - require.NoError(t, err) - require.Equal(t, keeper.MaxPendingCctxs, len(res.CrossChainTx)) - require.EqualValues(t, cctxs[0:keeper.MaxPendingCctxs], res.CrossChainTx) - require.EqualValues(t, uint64(1000), res.TotalPending) + assert.NoError(t, err) + assert.Equal(t, keeper.MaxPendingCctxs, len(res.CrossChainTx)) + assert.EqualValues(t, cctxs[0:keeper.MaxPendingCctxs], res.CrossChainTx) + assert.EqualValues(t, uint64(1000), res.TotalPending) }) t.Run("can retrieve pending cctx with range smaller than max", func(t *testing.T) { @@ -121,10 +121,10 @@ func TestKeeper_CctxListPending(t *testing.T) { cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 1100, chainID, tss, zk) res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID}) - require.NoError(t, err) - require.Equal(t, 100, len(res.CrossChainTx)) - require.EqualValues(t, cctxs, res.CrossChainTx) - require.EqualValues(t, uint64(100), res.TotalPending) + assert.NoError(t, err) + assert.Equal(t, 100, len(res.CrossChainTx)) + assert.EqualValues(t, cctxs, res.CrossChainTx) + assert.EqualValues(t, uint64(100), res.TotalPending) }) t.Run("can retrieve pending cctx with pending cctx below nonce low", func(t *testing.T) { @@ -136,23 +136,23 @@ func TestKeeper_CctxListPending(t *testing.T) { // set some cctxs as pending below nonce cctx1, found := k.GetCrossChainTx(ctx, "940") - require.True(t, found) + assert.True(t, found) cctx1.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx1) cctx2, found := k.GetCrossChainTx(ctx, "955") - require.True(t, found) + assert.True(t, found) cctx2.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx2) res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID, Limit: 100}) - require.NoError(t, err) - require.Equal(t, 100, len(res.CrossChainTx)) + assert.NoError(t, err) + assert.Equal(t, 100, len(res.CrossChainTx)) expectedCctxs := append([]*types.CrossChainTx{&cctx1, &cctx2}, cctxs[0:98]...) - require.EqualValues(t, expectedCctxs, res.CrossChainTx) + assert.EqualValues(t, expectedCctxs, res.CrossChainTx) // pending nonce + 2 - require.EqualValues(t, uint64(1002), res.TotalPending) + assert.EqualValues(t, uint64(1002), res.TotalPending) }) } diff --git a/x/crosschain/keeper/grpc_query_gas_price_test.go b/x/crosschain/keeper/grpc_query_gas_price_test.go index 5c2d12cadd..7b4a88cf0c 100644 --- a/x/crosschain/keeper/grpc_query_gas_price_test.go +++ b/x/crosschain/keeper/grpc_query_gas_price_test.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -46,9 +45,9 @@ func TestGasPriceQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.GasPrice(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -73,7 +72,7 @@ func TestGasPriceQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.GasPriceAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.GasPrice[j-i]) } @@ -84,7 +83,7 @@ func TestGasPriceQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.GasPriceAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.GasPrice[j-i]) } @@ -93,11 +92,11 @@ func TestGasPriceQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.GasPriceAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.GasPriceAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go index 5704fdc54a..6d00f1b562 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -58,10 +58,10 @@ func TestInTxHashToCctxQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.InTxHashToCctx(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.NoError(t, err) - require.Equal(t, + assert.NoError(t, err) + assert.Equal(t, nullify.Fill(tc.response), nullify.Fill(response), ) @@ -89,9 +89,9 @@ func TestInTxHashToCctxQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.InTxHashToCctxAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.InTxHashToCctx), step) - require.Subset(t, + assert.NoError(t, err) + assert.LessOrEqual(t, len(resp.InTxHashToCctx), step) + assert.Subset(t, nullify.Fill(msgs), nullify.Fill(resp.InTxHashToCctx), ) @@ -102,9 +102,9 @@ func TestInTxHashToCctxQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.InTxHashToCctxAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.InTxHashToCctx), step) - require.Subset(t, + assert.NoError(t, err) + assert.LessOrEqual(t, len(resp.InTxHashToCctx), step) + assert.Subset(t, nullify.Fill(msgs), nullify.Fill(resp.InTxHashToCctx), ) @@ -113,16 +113,16 @@ func TestInTxHashToCctxQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.InTxHashToCctxAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.ElementsMatch(t, nullify.Fill(msgs), nullify.Fill(resp.InTxHashToCctx), ) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.InTxHashToCctxAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } @@ -157,10 +157,10 @@ func TestKeeper_InTxHashToCctxDataQuery(t *testing.T) { InTxHash: inTxHashToCctx.InTxHash, } res, err := keeper.InTxHashToCctxData(wctx, req) - require.NoError(t, err) - require.Equal(t, len(cctxs), len(res.CrossChainTxs)) + assert.NoError(t, err) + assert.Equal(t, len(cctxs), len(res.CrossChainTxs)) for i := range cctxs { - require.Equal(t, nullify.Fill(cctxs[i]), nullify.Fill(res.CrossChainTxs[i])) + assert.Equal(t, nullify.Fill(cctxs[i]), nullify.Fill(res.CrossChainTxs[i])) } }) t.Run("in tx hash not found", func(t *testing.T) { @@ -168,7 +168,7 @@ func TestKeeper_InTxHashToCctxDataQuery(t *testing.T) { InTxHash: "notfound", } _, err := keeper.InTxHashToCctxData(wctx, req) - require.ErrorIs(t, err, status.Error(codes.NotFound, "not found")) + assert.ErrorIs(t, err, status.Error(codes.NotFound, "not found")) }) t.Run("cctx not indexed return internal error", func(t *testing.T) { keeper.SetInTxHashToCctx(ctx, types.InTxHashToCctx{ @@ -180,6 +180,6 @@ func TestKeeper_InTxHashToCctxDataQuery(t *testing.T) { InTxHash: "nocctx", } _, err := keeper.InTxHashToCctxData(wctx, req) - require.ErrorIs(t, err, status.Error(codes.Internal, "cctx indexed notfound doesn't exist")) + assert.ErrorIs(t, err, status.Error(codes.Internal, "cctx indexed notfound doesn't exist")) }) } diff --git a/x/crosschain/keeper/grpc_query_last_block_height_test.go b/x/crosschain/keeper/grpc_query_last_block_height_test.go index b2fd0463cf..428a246a61 100644 --- a/x/crosschain/keeper/grpc_query_last_block_height_test.go +++ b/x/crosschain/keeper/grpc_query_last_block_height_test.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -46,9 +45,9 @@ func TestLastBlockHeightQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.LastBlockHeight(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -73,7 +72,7 @@ func TestLastBlockHeightQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.LastBlockHeightAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) } @@ -84,7 +83,7 @@ func TestLastBlockHeightQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.LastBlockHeightAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) } @@ -93,11 +92,11 @@ func TestLastBlockHeightQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.LastBlockHeightAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.LastBlockHeightAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/crosschain/keeper/grpc_query_out_tx_tracker_test.go b/x/crosschain/keeper/grpc_query_out_tx_tracker_test.go index 39f5ad3673..5951acf881 100644 --- a/x/crosschain/keeper/grpc_query_out_tx_tracker_test.go +++ b/x/crosschain/keeper/grpc_query_out_tx_tracker_test.go @@ -39,10 +39,10 @@ package keeper_test // t.Run(tc.desc, func(t *testing.T) { // response, err := keeper.OutTxTracker(wctx, tc.request) // if tc.err != nil { -// require.ErrorIs(t, err, tc.err) +// assert.ErrorIs(t, err, tc.err) // } else { -// require.NoError(t, err) -// require.Equal(t, +// assert.NoError(t, err) +// assert.Equal(t, // nullify.Fill(tc.response), // nullify.Fill(response), // ) @@ -70,9 +70,9 @@ package keeper_test // step := 2 // for i := 0; i < len(msgs); i += step { // resp, err := keeper.OutTxTrackerAll(wctx, request(nil, uint64(i), uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.OutTxTracker), step) -// require.Subset(t, +// assert.NoError(t, err) +// assert.LessOrEqual(t, len(resp.OutTxTracker), step) +// assert.Subset(t, // nullify.Fill(msgs), // nullify.Fill(resp.OutTxTracker), // ) @@ -83,9 +83,9 @@ package keeper_test // var next []byte // for i := 0; i < len(msgs); i += step { // resp, err := keeper.OutTxTrackerAll(wctx, request(next, 0, uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.OutTxTracker), step) -// require.Subset(t, +// assert.NoError(t, err) +// assert.LessOrEqual(t, len(resp.OutTxTracker), step) +// assert.Subset(t, // nullify.Fill(msgs), // nullify.Fill(resp.OutTxTracker), // ) @@ -94,15 +94,15 @@ package keeper_test // }) // t.Run("Total", func(t *testing.T) { // resp, err := keeper.OutTxTrackerAll(wctx, request(nil, 0, 0, true)) -// require.NoError(t, err) -// require.Equal(t, len(msgs), int(resp.Pagination.Total)) -// require.ElementsMatch(t, +// assert.NoError(t, err) +// assert.Equal(t, len(msgs), int(resp.Pagination.Total)) +// assert.ElementsMatch(t, // nullify.Fill(msgs), // nullify.Fill(resp.OutTxTracker), // ) // }) // t.Run("InvalidRequest", func(t *testing.T) { // _, err := keeper.OutTxTrackerAll(wctx, nil) -// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) +// assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) // }) //} diff --git a/x/crosschain/keeper/in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/in_tx_hash_to_cctx_test.go index 6eb0118cf9..2084724f44 100644 --- a/x/crosschain/keeper/in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/in_tx_hash_to_cctx_test.go @@ -7,7 +7,7 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/keeper" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -30,8 +30,8 @@ func TestInTxHashToCctxGet(t *testing.T) { rst, found := keeper.GetInTxHashToCctx(ctx, item.InTxHash, ) - require.True(t, found) - require.Equal(t, + assert.True(t, found) + assert.Equal(t, nullify.Fill(&item), nullify.Fill(&rst), ) @@ -47,14 +47,14 @@ func TestInTxHashToCctxRemove(t *testing.T) { _, found := keeper.GetInTxHashToCctx(ctx, item.InTxHash, ) - require.False(t, found) + assert.False(t, found) } } func TestInTxHashToCctxGetAll(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) items := createNInTxHashToCctx(keeper, ctx, 10) - require.ElementsMatch(t, + assert.ElementsMatch(t, nullify.Fill(items), nullify.Fill(keeper.GetAllInTxHashToCctx(ctx)), ) diff --git a/x/crosschain/keeper/in_tx_tracker_test.go b/x/crosschain/keeper/in_tx_tracker_test.go index a4bda41192..841e4a2326 100644 --- a/x/crosschain/keeper/in_tx_tracker_test.go +++ b/x/crosschain/keeper/in_tx_tracker_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" @@ -31,15 +31,15 @@ func TestKeeper_GetAllInTxTrackerForChain(t *testing.T) { intxTrackers := createNInTxTracker(keeper, ctx, 10, 5) for _, item := range intxTrackers { rst, found := keeper.GetInTxTracker(ctx, item.ChainId, item.TxHash) - require.True(t, found) - require.Equal(t, item, rst) + assert.True(t, found) + assert.Equal(t, item, rst) } }) t.Run("Get all InTx trackers", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) intxTrackers := createNInTxTracker(keeper, ctx, 10, 5) rst := keeper.GetAllInTxTracker(ctx) - require.Equal(t, intxTrackers, rst) + assert.Equal(t, intxTrackers, rst) }) t.Run("Get all InTx trackers for chain", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -51,39 +51,39 @@ func TestKeeper_GetAllInTxTrackerForChain(t *testing.T) { sort.SliceStable(intxTrackersNew, func(i, j int) bool { return intxTrackersNew[i].TxHash < intxTrackersNew[j].TxHash }) - require.Equal(t, intxTrackersNew, rst) + assert.Equal(t, intxTrackersNew, rst) }) t.Run("Get all InTx trackers for chain paginated by limit", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) intxTrackers := createNInTxTracker(keeper, ctx, 100, 6) rst, pageRes, err := keeper.GetAllInTxTrackerForChainPaginated(ctx, 6, &query.PageRequest{Limit: 10, CountTotal: true}) - require.NoError(t, err) - require.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) - require.Equal(t, len(intxTrackers), int(pageRes.Total)) + assert.NoError(t, err) + assert.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) + assert.Equal(t, len(intxTrackers), int(pageRes.Total)) }) t.Run("Get all InTx trackers for chain paginated by offset", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) intxTrackers := createNInTxTracker(keeper, ctx, 100, 6) rst, pageRes, err := keeper.GetAllInTxTrackerForChainPaginated(ctx, 6, &query.PageRequest{Offset: 10, CountTotal: true}) - require.NoError(t, err) - require.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) - require.Equal(t, len(intxTrackers), int(pageRes.Total)) + assert.NoError(t, err) + assert.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) + assert.Equal(t, len(intxTrackers), int(pageRes.Total)) }) t.Run("Get all InTx trackers paginated by limit", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) intxTrackers := append(createNInTxTracker(keeper, ctx, 10, 6), createNInTxTracker(keeper, ctx, 10, 7)...) rst, pageRes, err := keeper.GetAllInTxTrackerPaginated(ctx, &query.PageRequest{Limit: 20, CountTotal: true}) - require.NoError(t, err) - require.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) - require.Equal(t, len(intxTrackers), int(pageRes.Total)) + assert.NoError(t, err) + assert.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) + assert.Equal(t, len(intxTrackers), int(pageRes.Total)) }) t.Run("Get all InTx trackers paginated by offset", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) intxTrackers := append(createNInTxTracker(keeper, ctx, 100, 6), createNInTxTracker(keeper, ctx, 100, 7)...) rst, pageRes, err := keeper.GetAllInTxTrackerPaginated(ctx, &query.PageRequest{Offset: 10, CountTotal: true}) - require.NoError(t, err) - require.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) - require.Equal(t, len(intxTrackers), int(pageRes.Total)) + assert.NoError(t, err) + assert.Subset(t, nullify.Fill(intxTrackers), nullify.Fill(rst)) + assert.Equal(t, len(intxTrackers), int(pageRes.Total)) }) t.Run("Delete InTxTracker", func(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -98,6 +98,6 @@ func TestKeeper_GetAllInTxTrackerForChain(t *testing.T) { keeper.RemoveInTxTrackerIfExists(ctx, item.ChainId, item.TxHash) } rst := keeper.GetAllInTxTrackerForChain(ctx, 6) - require.Equal(t, 0, len(rst)) + assert.Equal(t, 0, len(rst)) }) } diff --git a/x/crosschain/keeper/keeper_test.go b/x/crosschain/keeper/keeper_test.go index 3a65063a16..7bc0af5fb1 100644 --- a/x/crosschain/keeper/keeper_test.go +++ b/x/crosschain/keeper/keeper_test.go @@ -12,7 +12,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" @@ -29,7 +29,7 @@ func setupKeeper(t testing.TB) (*Keeper, sdk.Context) { stateStore := store.NewCommitMultiStore(db) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) + assert.NoError(t, stateStore.LoadLatestVersion()) registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go index f9b7c380e0..8a1953d3b8 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -32,11 +32,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { CctxIndex: "cctx_index", }) - require.NoError(t, err) + assert.NoError(t, err) cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") - require.True(t, found) - require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) - require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) + assert.True(t, found) + assert.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) + assert.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) }) t.Run("can abort a cctx in pending outbound", func(t *testing.T) { @@ -59,11 +59,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { CctxIndex: "cctx_index", }) - require.NoError(t, err) + assert.NoError(t, err) cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") - require.True(t, found) - require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) - require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) + assert.True(t, found) + assert.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) + assert.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) }) t.Run("can abort a cctx in pending revert", func(t *testing.T) { @@ -86,11 +86,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { CctxIndex: "cctx_index", }) - require.NoError(t, err) + assert.NoError(t, err) cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") - require.True(t, found) - require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) - require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) + assert.True(t, found) + assert.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) + assert.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) }) t.Run("cannot abort a cctx in pending outbound if not admin", func(t *testing.T) { @@ -110,7 +110,7 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { Creator: sample.AccAddress(), CctxIndex: "cctx_index", }) - require.ErrorIs(t, err, observertypes.ErrNotAuthorized) + assert.ErrorIs(t, err, observertypes.ErrNotAuthorized) }) t.Run("cannot abort a cctx if doesn't exist", func(t *testing.T) { @@ -124,7 +124,7 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { Creator: admin, CctxIndex: "cctx_index", }) - require.ErrorIs(t, err, crosschaintypes.ErrCannotFindCctx) + assert.ErrorIs(t, err, crosschaintypes.ErrCannotFindCctx) }) t.Run("cannot abort a cctx if not pending", func(t *testing.T) { @@ -146,6 +146,6 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { Creator: admin, CctxIndex: "cctx_index", }) - require.ErrorIs(t, err, crosschaintypes.ErrStatusNotPending) + assert.ErrorIs(t, err, crosschaintypes.ErrStatusNotPending) }) } diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 7457068b38..f2b646017a 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -19,7 +19,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := int64(5) txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) msgServer := keeper.NewMsgServerImpl(*k) _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ @@ -31,16 +31,16 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: block.Hash().Hex(), TxIndex: txIndex, }) - require.NoError(t, err) + assert.NoError(t, err) _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.True(t, found) + assert.True(t, found) }) t.Run("fail to add proof based tracker with wrong tx hash", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getValidEthChainID(t) txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) msgServer := keeper.NewMsgServerImpl(*k) _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ @@ -52,16 +52,16 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: block.Hash().Hex(), TxIndex: txIndex, }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + assert.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.False(t, found) + assert.False(t, found) }) t.Run("fail to add proof based tracker with wrong chain id", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getValidEthChainID(t) txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) msgServer := keeper.NewMsgServerImpl(*k) _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ @@ -73,9 +73,9 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: block.Hash().Hex(), TxIndex: txIndex, }) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.False(t, found) + assert.False(t, found) }) t.Run("fail normal user submit without proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -92,9 +92,9 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: "", TxIndex: 0, }) - require.ErrorIs(t, err, observertypes.ErrNotAuthorized) + assert.ErrorIs(t, err, observertypes.ErrNotAuthorized) _, found := k.GetInTxTracker(ctx, chainID, tx_hash) - require.False(t, found) + assert.False(t, found) }) t.Run("admin add tx tracker", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -113,9 +113,9 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: "", TxIndex: 0, }) - require.NoError(t, err) + assert.NoError(t, err) _, found := k.GetInTxTracker(ctx, chainID, tx_hash) - require.True(t, found) + assert.True(t, found) }) t.Run("admin submit fake tracker", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -134,11 +134,11 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: "", TxIndex: 0, }) - require.NoError(t, err) + assert.NoError(t, err) _, found := k.GetInTxTracker(ctx, chainID, "Malicious TX HASH") - require.True(t, found) + assert.True(t, found) _, found = k.GetInTxTracker(ctx, chainID, tx_hash) - require.False(t, found) + assert.False(t, found) }) } diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go index 72820fcffc..546650d61a 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/common/ethereum" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -30,7 +29,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { setAdminPolicies(ctx, zk, admin) chainID := getEthereumChainID() txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, 0) msgServer := keeper.NewMsgServerImpl(*k) @@ -43,9 +42,9 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: 0, Nonce: 0, }) - require.NoError(t, err) + assert.NoError(t, err) _, found := k.GetOutTxTracker(ctx, chainID, 0) - require.True(t, found) + assert.True(t, found) }) t.Run("unable to add tracker admin exceeding maximum allowed length of hashlist without proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -53,7 +52,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { setAdminPolicies(ctx, zk, admin) chainID := getEthereumChainID() txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, 0) k.SetOutTxTracker(ctx, types.OutTxTracker{ @@ -82,17 +81,17 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: 0, Nonce: 0, }) - require.NoError(t, err) + assert.NoError(t, err) tracker, found := k.GetOutTxTracker(ctx, chainID, 0) - require.True(t, found) - require.Equal(t, 2, len(tracker.HashList)) + assert.True(t, found) + assert.Equal(t, 2, len(tracker.HashList)) }) t.Run("fail add proof based tracker with wrong chainID", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) msgServer := keeper.NewMsgServerImpl(*k) @@ -105,16 +104,16 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) + assert.False(t, found) }) t.Run("fail add proof based tracker with wrong nonce", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, 1) msgServer := keeper.NewMsgServerImpl(*k) @@ -127,16 +126,16 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: 1, }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + assert.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, 1) - require.False(t, found) + assert.False(t, found) }) t.Run("fail add proof based tracker with wrong tx_hash", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) msgServer := keeper.NewMsgServerImpl(*k) @@ -149,16 +148,16 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + assert.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) + assert.False(t, found) }) t.Run("fail proof based tracker with incorrect proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) msgServer := keeper.NewMsgServerImpl(*k) @@ -171,15 +170,15 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, err, types.ErrProofVerificationFail) + assert.ErrorIs(t, err, types.ErrProofVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) + assert.False(t, found) }) t.Run("add proof based tracker with correct proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) msgServer := keeper.NewMsgServerImpl(*k) @@ -192,15 +191,15 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.NoError(t, err) + assert.NoError(t, err) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) + assert.True(t, found) }) t.Run("add proven txHash even if length of hashList is already 2", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) k.SetOutTxTracker(ctx, types.OutTxTracker{ @@ -229,20 +228,20 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.NoError(t, err) + assert.NoError(t, err) tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - require.Equal(t, 3, len(tracker.HashList)) + assert.True(t, found) + assert.Equal(t, 3, len(tracker.HashList)) // Proven tracker is prepended to the list - require.True(t, tracker.HashList[0].Proved) - require.False(t, tracker.HashList[1].Proved) - require.False(t, tracker.HashList[2].Proved) + assert.True(t, tracker.HashList[0].Proved) + assert.False(t, tracker.HashList[1].Proved) + assert.False(t, tracker.HashList[2].Proved) }) t.Run("add proof for existing txHash", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) + assert.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) k.SetOutTxTracker(ctx, types.OutTxTracker{ @@ -258,7 +257,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { }) tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) assert.True(t, found) - require.False(t, tracker.HashList[0].Proved) + assert.False(t, tracker.HashList[0].Proved) msgServer := keeper.NewMsgServerImpl(*k) _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: sample.AccAddress(), @@ -269,11 +268,11 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.NoError(t, err) + assert.NoError(t, err) tracker, found = k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - require.Equal(t, 1, len(tracker.HashList)) - require.True(t, tracker.HashList[0].Proved) + assert.True(t, found) + assert.Equal(t, 1, len(tracker.HashList)) + assert.True(t, tracker.HashList[0].Proved) }) } diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go index 4d909abdf0..c8aadf0de4 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go @@ -6,7 +6,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -25,20 +25,20 @@ func TestKeeper_MigrateTSSFundsForChain(t *testing.T) { amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) gp, found := k.GetMedianGasPriceInUint(ctx, chain.ChainId) - require.True(t, found) + assert.True(t, found) _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, ChainId: chain.ChainId, Amount: amount, }) - require.NoError(t, err) + assert.NoError(t, err) hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() cctx, found := k.GetCrossChainTx(ctx, index) - require.True(t, found) + assert.True(t, found) multipliedValue, err := common.MultiplyGasPrice(gp, crosschaintypes.TssMigrationGasMultiplierEVM) - require.NoError(t, err) - require.Equal(t, multipliedValue.String(), cctx.GetCurrentOutTxParam().OutboundTxGasPrice) + assert.NoError(t, err) + assert.Equal(t, multipliedValue.String(), cctx.GetCurrentOutTxParam().OutboundTxGasPrice) }) } @@ -56,14 +56,14 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.NoError(t, err) + assert.NoError(t, err) hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() cctx, found := k.GetCrossChainTx(ctx, index) - require.True(t, found) + assert.True(t, found) feeCalculated := sdk.NewUint(cctx.GetCurrentOutTxParam().OutboundTxGasLimit). Mul(sdkmath.NewUintFromString(cctx.GetCurrentOutTxParam().OutboundTxGasPrice)) - require.Equal(t, cctx.GetCurrentOutTxParam().Amount.String(), amount.Sub(feeCalculated).String()) + assert.Equal(t, cctx.GetCurrentOutTxParam().Amount.String(), amount.Sub(feeCalculated).String()) }) t.Run("not enough funds in tss address for migration", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -78,11 +78,11 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.ErrorContains(t, err, crosschaintypes.ErrCannotMigrateTssFunds.Error()) + assert.ErrorContains(t, err, crosschaintypes.ErrCannotMigrateTssFunds.Error()) hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() _, found := k.GetCrossChainTx(ctx, index) - require.False(t, found) + assert.False(t, found) }) t.Run("unable to migrate funds if new TSS is not created ", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -97,11 +97,11 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.ErrorContains(t, err, "no new tss address has been generated") + assert.ErrorContains(t, err, "no new tss address has been generated") hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() _, found := k.GetCrossChainTx(ctx, index) - require.False(t, found) + assert.False(t, found) }) t.Run("unable to migrate funds when nonce low does not match nonce high", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -122,12 +122,12 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) - require.ErrorContains(t, err, "cannot migrate funds when there are pending nonces") + assert.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) + assert.ErrorContains(t, err, "cannot migrate funds when there are pending nonces") hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() _, found := k.GetCrossChainTx(ctx, index) - require.False(t, found) + assert.False(t, found) }) t.Run("unable to migrate funds when a pending cctx is presnt in migration info", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -155,14 +155,14 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) - require.ErrorContains(t, err, "cannot migrate funds while there are pending migrations") + assert.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) + assert.ErrorContains(t, err, "cannot migrate funds while there are pending migrations") hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() _, found := k.GetCrossChainTx(ctx, index) - require.False(t, found) + assert.False(t, found) _, found = k.GetCrossChainTx(ctx, existingCctx.Index) - require.True(t, found) + assert.True(t, found) }) t.Run("unable to migrate funds if current TSS is not present in TSSHistory and no new TSS has been generated", func(t *testing.T) { @@ -174,7 +174,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, false, false) currentTss, found := k.GetObserverKeeper().GetTSS(ctx) - require.True(t, found) + assert.True(t, found) newTss := sample.Tss() newTss.FinalizedZetaHeight = currentTss.FinalizedZetaHeight - 10 newTss.KeyGenZetaHeight = currentTss.KeyGenZetaHeight - 10 @@ -184,12 +184,12 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { ChainId: chain.ChainId, Amount: amount, }) - require.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) - require.ErrorContains(t, err, "current tss is the latest") + assert.ErrorIs(t, err, crosschaintypes.ErrCannotMigrateTssFunds) + assert.ErrorContains(t, err, "current tss is the latest") hash := crypto.Keccak256Hash([]byte(indexString)) index := hash.Hex() _, found = k.GetCrossChainTx(ctx, index) - require.False(t, found) + assert.False(t, found) }) } func setupTssMigrationParams( diff --git a/x/crosschain/keeper/msg_server_update_tss_test.go b/x/crosschain/keeper/msg_server_update_tss_test.go index 9d1207d427..6f9ff04e8e 100644 --- a/x/crosschain/keeper/msg_server_update_tss_test.go +++ b/x/crosschain/keeper/msg_server_update_tss_test.go @@ -3,9 +3,8 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -134,16 +133,16 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined k.SetCrossChainTx(ctx, *cctx) - require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), 1) + assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), 1) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssNew.TssPubkey, }) - require.ErrorContains(t, err, "cannot update tss address not enough migrations have been created and completed") - require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) + assert.ErrorContains(t, err, "cannot update tss address not enough migrations have been created and completed") + assert.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) tss, found := k.GetObserverKeeper().GetTSS(ctx) - require.True(t, found) - require.Equal(t, tssOld, tss) + assert.True(t, found) + assert.Equal(t, tssOld, tss) migrators := k.GetObserverKeeper().GetAllTssFundMigrators(ctx) assert.Equal(t, 1, len(migrators)) }) diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx.go b/x/crosschain/keeper/msg_server_vote_inbound_tx.go index 57c3e54041..3b4034c485 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx.go @@ -32,7 +32,7 @@ import ( // // If the receiver chain is a connected chain, the `FinalizeInbound` method is // called to prepare the CCTX to be processed as an outbound transaction. To -// cover the outbound transaction fee, the required amount of tokens submitted +// cover the outbound transaction fee, the assertd amount of tokens submitted // with the CCTX are swapped using a Uniswap V2 contract instance on ZetaChain // for the ZRC20 of the gas token of the receiver chain. The ZRC20 tokens are // then burned. The nonce is updated. If everything is successful, the CCTX diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index 17319d1f8a..30af53fdcc 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -31,7 +31,7 @@ import ( // status. // // If the previous status was `PendingOutbound`, a new revert transaction is -// created. To cover the revert transaction fee, the required amount of tokens +// created. To cover the revert transaction fee, the assertd amount of tokens // submitted with the CCTX are swapped using a Uniswap V2 contract instance on // ZetaChain for the ZRC20 of the gas token of the receiver chain. The ZRC20 // tokens are then diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go index b5ad6ab78d..0f1c15ac17 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go @@ -7,7 +7,7 @@ import ( "testing" "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -102,10 +102,10 @@ func TestKeeper_FundGasStabilityPoolFromRemainingFees(t *testing.T) { err := k.FundGasStabilityPoolFromRemainingFees(ctx, *outbound, 42) if tc.isError { - require.Error(t, err) + assert.Error(t, err) return } - require.NoError(t, err) + assert.NoError(t, err) fungibleMock.AssertExpectations(t) }) diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go index 82cd292fb2..324ac6ff02 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -45,25 +45,25 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.NoError(t, err) - require.NotNil(t, res) + assert.NoError(t, err) + assert.NotNil(t, res) zrc20 := res.Zrc20Address cctxIndex := res.CctxIndex // check zrc20 and cctx created assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(zrc20)) fc, found := zk.FungibleKeeper.GetForeignCoins(ctx, zrc20) - require.True(t, found) - require.EqualValues(t, "foo", fc.Name) - require.EqualValues(t, erc20Address, fc.Asset) + assert.True(t, found) + assert.EqualValues(t, "foo", fc.Name) + assert.EqualValues(t, erc20Address, fc.Asset) cctx, found := k.GetCrossChainTx(ctx, cctxIndex) - require.True(t, found) - require.EqualValues(t, fmt.Sprintf("%s:%s", common.CmdWhitelistERC20, erc20Address), cctx.RelayedMessage) + assert.True(t, found) + assert.EqualValues(t, fmt.Sprintf("%s:%s", common.CmdWhitelistERC20, erc20Address), cctx.RelayedMessage) // check gas limit is set gasLimit, err := zk.FungibleKeeper.QueryGasLimit(ctx, ethcommon.HexToAddress(zrc20)) - require.NoError(t, err) - require.Equal(t, uint64(100000), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(100000), gasLimit.Uint64()) // Ensure that whitelist a new erc20 create a cctx with a different index res, err = msgServer.WhitelistERC20(ctx, &types.MsgWhitelistERC20{ @@ -75,9 +75,9 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.NoError(t, err) - require.NotNil(t, res) - require.NotEqual(t, cctxIndex, res.CctxIndex) + assert.NoError(t, err) + assert.NotNil(t, res) + assert.NotEqual(t, cctxIndex, res.CctxIndex) }) t.Run("should fail if not authorized", func(t *testing.T) { @@ -94,7 +94,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if invalid erc20 address", func(t *testing.T) { @@ -114,7 +114,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) t.Run("should fail if foreign coin already exists for the asset", func(t *testing.T) { @@ -141,7 +141,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.ErrorIs(t, err, fungibletypes.ErrForeignCoinAlreadyExist) + assert.ErrorIs(t, err, fungibletypes.ErrForeignCoinAlreadyExist) }) t.Run("should fail if no tss set", func(t *testing.T) { @@ -163,7 +163,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.ErrorIs(t, err, types.ErrCannotFindTSSKeys) + assert.ErrorIs(t, err, types.ErrCannotFindTSSKeys) }) t.Run("should fail if nox valid chain ID", func(t *testing.T) { @@ -185,6 +185,6 @@ func TestKeeper_WhitelistERC20(t *testing.T) { Decimals: 18, GasLimit: 100000, }) - require.ErrorIs(t, err, types.ErrInvalidChainID) + assert.ErrorIs(t, err, types.ErrInvalidChainID) }) } diff --git a/x/crosschain/keeper/out_tx_tracker_test.go b/x/crosschain/keeper/out_tx_tracker_test.go index 4b849b4c3d..5644d30db4 100644 --- a/x/crosschain/keeper/out_tx_tracker_test.go +++ b/x/crosschain/keeper/out_tx_tracker_test.go @@ -5,7 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -33,8 +33,8 @@ func TestOutTxTrackerGet(t *testing.T) { item.ChainId, item.Nonce, ) - require.True(t, found) - require.Equal(t, + assert.True(t, found) + assert.Equal(t, nullify.Fill(&item), nullify.Fill(&rst), ) @@ -52,14 +52,14 @@ func TestOutTxTrackerRemove(t *testing.T) { item.ChainId, item.Nonce, ) - require.False(t, found) + assert.False(t, found) } } func TestOutTxTrackerGetAll(t *testing.T) { keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) items := createNOutTxTracker(keeper, ctx, 10) - require.ElementsMatch(t, + assert.ElementsMatch(t, nullify.Fill(items), nullify.Fill(keeper.GetAllOutTxTracker(ctx)), ) diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 83f37b2799..088d10e604 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -12,7 +12,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/ethereum/go-ethereum/common" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" "github.com/zeta-chain/zetacore/cmd/zetacored/config" zetacommon "github.com/zeta-chain/zetacore/common" @@ -40,7 +40,7 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { case 1: return zetacommon.GoerliChain().ChainId default: - require.Fail(t, "invalid index") + assert.Fail(t, "invalid index") } return 0 } @@ -48,10 +48,10 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { // assert that a contract has been deployed by checking stored code is non-empty. func assertContractDeployment(t *testing.T, k *evmkeeper.Keeper, ctx sdk.Context, contractAddress common.Address) { acc := k.GetAccount(ctx, contractAddress) - require.NotNil(t, acc) + assert.NotNil(t, acc) code := k.GetCode(ctx, common.BytesToHash(acc.CodeHash)) - require.NotEmpty(t, code) + assert.NotEmpty(t, code) } // deploySystemContracts deploys the system contracts and returns their addresses. @@ -64,28 +64,28 @@ func deploySystemContracts( var err error wzeta, err = k.DeployWZETA(ctx) - require.NoError(t, err) - require.NotEmpty(t, wzeta) + assert.NoError(t, err) + assert.NotEmpty(t, wzeta) assertContractDeployment(t, evmk, ctx, wzeta) uniswapV2Factory, err = k.DeployUniswapV2Factory(ctx) - require.NoError(t, err) - require.NotEmpty(t, uniswapV2Factory) + assert.NoError(t, err) + assert.NotEmpty(t, uniswapV2Factory) assertContractDeployment(t, evmk, ctx, uniswapV2Factory) uniswapV2Router, err = k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) - require.NoError(t, err) - require.NotEmpty(t, uniswapV2Router) + assert.NoError(t, err) + assert.NotEmpty(t, uniswapV2Router) assertContractDeployment(t, evmk, ctx, uniswapV2Router) connector, err = k.DeployConnectorZEVM(ctx, wzeta) - require.NoError(t, err) - require.NotEmpty(t, connector) + assert.NoError(t, err) + assert.NotEmpty(t, connector) assertContractDeployment(t, evmk, ctx, connector) systemContract, err = k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, uniswapV2Router) - require.NoError(t, err) - require.NotEmpty(t, systemContract) + assert.NoError(t, err) + assert.NotEmpty(t, systemContract) assertContractDeployment(t, evmk, ctx, systemContract) return @@ -109,7 +109,7 @@ func setupGasCoin( 8, nil, ) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) return addr } @@ -135,7 +135,7 @@ func deployZRC20( assetAddress, big.NewInt(21_000), ) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) return addr } @@ -149,22 +149,22 @@ func setupZRC20Pool( zrc20Addr common.Address, ) { routerAddress, err := k.GetUniswapV2Router02Address(ctx) - require.NoError(t, err) + assert.NoError(t, err) routerABI, err := uniswapv2router02.UniswapV2Router02MetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) // enough for the small numbers used in test liquidityAmount := big.NewInt(1e17) // mint some zrc20 and zeta _, err = k.DepositZRC20(ctx, zrc20Addr, types.ModuleAddressEVM, liquidityAmount) - require.NoError(t, err) + assert.NoError(t, err) err = bankKeeper.MintCoins( ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdk.NewIntFromBigInt(liquidityAmount))), ) - require.NoError(t, err) + assert.NoError(t, err) // approve the router to spend the zeta err = k.CallZRC20Approve( @@ -175,7 +175,7 @@ func setupZRC20Pool( liquidityAmount, false, ) - require.NoError(t, err) + assert.NoError(t, err) // add the liquidity //function addLiquidityETH( @@ -203,7 +203,7 @@ func setupZRC20Pool( types.ModuleAddressEVM, liquidityAmount, ) - require.NoError(t, err) + assert.NoError(t, err) } // setAdminPolicies sets the admin policies for the observer module with group 1 and 2 diff --git a/x/crosschain/keeper/zeta_accounting_test.go b/x/crosschain/keeper/zeta_accounting_test.go index 1d5e1f7921..a20ada338c 100644 --- a/x/crosschain/keeper/zeta_accounting_test.go +++ b/x/crosschain/keeper/zeta_accounting_test.go @@ -5,7 +5,7 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -19,20 +19,20 @@ func TestKeeper_AddZetaAccounting(t *testing.T) { AbortedZetaAmount: originalAmount, }) val, found := k.GetZetaAccounting(ctx) - require.True(t, found) - require.Equal(t, originalAmount, val.AbortedZetaAmount) + assert.True(t, found) + assert.Equal(t, originalAmount, val.AbortedZetaAmount) addAmount := sdkmath.NewUint(rand.Uint64()) k.AddZetaAbortedAmount(ctx, addAmount) val, found = k.GetZetaAccounting(ctx) - require.True(t, found) - require.Equal(t, originalAmount.Add(addAmount), val.AbortedZetaAmount) + assert.True(t, found) + assert.Equal(t, originalAmount.Add(addAmount), val.AbortedZetaAmount) }) t.Run("cant find aborted amount", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) val, found := k.GetZetaAccounting(ctx) - require.False(t, found) - require.Equal(t, types.ZetaAccounting{}, val) + assert.False(t, found) + assert.Equal(t, types.ZetaAccounting{}, val) }) t.Run("add very high zeta amount", func(t *testing.T) { @@ -42,8 +42,8 @@ func TestKeeper_AddZetaAccounting(t *testing.T) { AbortedZetaAmount: highAmount, }) val, found := k.GetZetaAccounting(ctx) - require.True(t, found) - require.Equal(t, highAmount, val.AbortedZetaAmount) + assert.True(t, found) + assert.Equal(t, highAmount, val.AbortedZetaAmount) }) } diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 5ff2f9ee54..98c005c4c8 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -148,13 +147,13 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { v4.SetBitcoinFinalizedInbound(ctx, k) // check finalized inbound - require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", common.GoerliChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", common.EthChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xccc", common.MumbaiChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x111", common.BtcMainnetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x222", common.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x333", common.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x444", common.BtcRegtestChain().ChainId, 0)) + assert.False(t, k.IsFinalizedInbound(ctx, "0xaaa", common.GoerliChain().ChainId, 0)) + assert.False(t, k.IsFinalizedInbound(ctx, "0xbbb", common.EthChain().ChainId, 0)) + assert.False(t, k.IsFinalizedInbound(ctx, "0xccc", common.MumbaiChain().ChainId, 0)) + assert.True(t, k.IsFinalizedInbound(ctx, "0x111", common.BtcMainnetChain().ChainId, 0)) + assert.True(t, k.IsFinalizedInbound(ctx, "0x222", common.BtcTestNetChain().ChainId, 0)) + assert.True(t, k.IsFinalizedInbound(ctx, "0x333", common.BtcTestNetChain().ChainId, 0)) + assert.True(t, k.IsFinalizedInbound(ctx, "0x444", common.BtcRegtestChain().ChainId, 0)) }) } diff --git a/x/crosschain/types/cctx_utils_test.go b/x/crosschain/types/cctx_utils_test.go index 381ef47f6c..6c8be1561d 100644 --- a/x/crosschain/types/cctx_utils_test.go +++ b/x/crosschain/types/cctx_utils_test.go @@ -4,7 +4,7 @@ import ( "math/rand" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -14,13 +14,13 @@ func TestCrossChainTx_GetCurrentOutTxParam(t *testing.T) { cctx := sample.CrossChainTx(t, "foo") cctx.OutboundTxParams = []*types.OutboundTxParams{} - require.Equal(t, &types.OutboundTxParams{}, cctx.GetCurrentOutTxParam()) + assert.Equal(t, &types.OutboundTxParams{}, cctx.GetCurrentOutTxParam()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r)} - require.Equal(t, cctx.OutboundTxParams[0], cctx.GetCurrentOutTxParam()) + assert.Equal(t, cctx.OutboundTxParams[0], cctx.GetCurrentOutTxParam()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r), sample.OutboundTxParams(r)} - require.Equal(t, cctx.OutboundTxParams[1], cctx.GetCurrentOutTxParam()) + assert.Equal(t, cctx.OutboundTxParams[1], cctx.GetCurrentOutTxParam()) } func TestCrossChainTx_IsCurrentOutTxRevert(t *testing.T) { @@ -28,13 +28,13 @@ func TestCrossChainTx_IsCurrentOutTxRevert(t *testing.T) { cctx := sample.CrossChainTx(t, "foo") cctx.OutboundTxParams = []*types.OutboundTxParams{} - require.False(t, cctx.IsCurrentOutTxRevert()) + assert.False(t, cctx.IsCurrentOutTxRevert()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r)} - require.False(t, cctx.IsCurrentOutTxRevert()) + assert.False(t, cctx.IsCurrentOutTxRevert()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r), sample.OutboundTxParams(r)} - require.True(t, cctx.IsCurrentOutTxRevert()) + assert.True(t, cctx.IsCurrentOutTxRevert()) } func TestCrossChainTx_OriginalDestinationChainID(t *testing.T) { @@ -42,13 +42,13 @@ func TestCrossChainTx_OriginalDestinationChainID(t *testing.T) { cctx := sample.CrossChainTx(t, "foo") cctx.OutboundTxParams = []*types.OutboundTxParams{} - require.Equal(t, int64(-1), cctx.OriginalDestinationChainID()) + assert.Equal(t, int64(-1), cctx.OriginalDestinationChainID()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r)} - require.Equal(t, cctx.OutboundTxParams[0].ReceiverChainId, cctx.OriginalDestinationChainID()) + assert.Equal(t, cctx.OutboundTxParams[0].ReceiverChainId, cctx.OriginalDestinationChainID()) cctx.OutboundTxParams = []*types.OutboundTxParams{sample.OutboundTxParams(r), sample.OutboundTxParams(r)} - require.Equal(t, cctx.OutboundTxParams[0].ReceiverChainId, cctx.OriginalDestinationChainID()) + assert.Equal(t, cctx.OutboundTxParams[0].ReceiverChainId, cctx.OriginalDestinationChainID()) } func TestOutboundTxParams_GetGasPrice(t *testing.T) { @@ -58,10 +58,10 @@ func TestOutboundTxParams_GetGasPrice(t *testing.T) { outTxParams.OutboundTxGasPrice = "42" gasPrice, err := outTxParams.GetGasPrice() - require.NoError(t, err) - require.EqualValues(t, uint64(42), gasPrice) + assert.NoError(t, err) + assert.EqualValues(t, uint64(42), gasPrice) outTxParams.OutboundTxGasPrice = "invalid" _, err = outTxParams.GetGasPrice() - require.Error(t, err) + assert.Error(t, err) } diff --git a/x/crosschain/types/genesis_test.go b/x/crosschain/types/genesis_test.go index 2b8b5eb80f..9fe7a827ea 100644 --- a/x/crosschain/types/genesis_test.go +++ b/x/crosschain/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -82,9 +82,9 @@ func TestGenesisState_Validate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { - require.NoError(t, err) + assert.NoError(t, err) } else { - require.Error(t, err) + assert.Error(t, err) } }) } diff --git a/x/crosschain/types/message_abort_stuck_cctx_test.go b/x/crosschain/types/message_abort_stuck_cctx_test.go index 40bdcf4794..02eb7c50fd 100644 --- a/x/crosschain/types/message_abort_stuck_cctx_test.go +++ b/x/crosschain/types/message_abort_stuck_cctx_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -36,10 +36,10 @@ func TestMsgAbortStuckCCTX_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/crosschain/types/message_add_to_in_tx_tracker_test.go b/x/crosschain/types/message_add_to_in_tx_tracker_test.go index c05272224f..22d7ff08e9 100644 --- a/x/crosschain/types/message_add_to_in_tx_tracker_test.go +++ b/x/crosschain/types/message_add_to_in_tx_tracker_test.go @@ -5,7 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -52,10 +52,10 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/crosschain/types/message_add_to_out_tx_tracker_test.go b/x/crosschain/types/message_add_to_out_tx_tracker_test.go index 8a06041989..8caa666b53 100644 --- a/x/crosschain/types/message_add_to_out_tx_tracker_test.go +++ b/x/crosschain/types/message_add_to_out_tx_tracker_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -32,10 +32,10 @@ func TestMsgAddToWatchList_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/crosschain/types/message_migrate_tss_funds_test.go b/x/crosschain/types/message_migrate_tss_funds_test.go index a03a4e9ef4..1bc7389651 100644 --- a/x/crosschain/types/message_migrate_tss_funds_test.go +++ b/x/crosschain/types/message_migrate_tss_funds_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -49,10 +49,10 @@ func TestNewMsgMigrateTssFunds(t *testing.T) { keeper.SetConfig(false) err := tt.msg.ValidateBasic() if tt.error { - require.Error(t, err) + assert.Error(t, err) return } else { - require.NoError(t, err) + assert.NoError(t, err) } }) } diff --git a/x/crosschain/types/message_update_tss_address_test.go b/x/crosschain/types/message_update_tss_address_test.go index ae2bcb25a4..ede82f094c 100644 --- a/x/crosschain/types/message_update_tss_address_test.go +++ b/x/crosschain/types/message_update_tss_address_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/keeper" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -45,10 +45,10 @@ func TestMessageUpdateTssAddress_ValidateBasic(t *testing.T) { keeper.SetConfig(false) err := tt.msg.ValidateBasic() if tt.error { - require.Error(t, err) + assert.Error(t, err) return } else { - require.NoError(t, err) + assert.NoError(t, err) } }) } diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go index 777fb6f244..29704a9101 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -125,10 +125,10 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } @@ -153,89 +153,89 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { EventIndex: 42, } hash := msg.Digest() - require.NotEmpty(t, hash, "hash should not be empty") + assert.NotEmpty(t, hash, "hash should not be empty") // creator not used msg2 := msg msg2.Creator = sample.AccAddress() hash2 := msg2.Digest() - require.Equal(t, hash, hash2, "creator should not change hash") + assert.Equal(t, hash, hash2, "creator should not change hash") // in block height not used msg2 = msg msg2.InBlockHeight = 43 hash2 = msg2.Digest() - require.Equal(t, hash, hash2, "in block height should not change hash") + assert.Equal(t, hash, hash2, "in block height should not change hash") // sender used msg2 = msg msg2.Sender = sample.AccAddress() hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "sender should change hash") + assert.NotEqual(t, hash, hash2, "sender should change hash") // sender chain ID used msg2 = msg msg2.SenderChainId = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "sender chain ID should change hash") + assert.NotEqual(t, hash, hash2, "sender chain ID should change hash") // tx origin used msg2 = msg msg2.TxOrigin = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "tx origin should change hash") + assert.NotEqual(t, hash, hash2, "tx origin should change hash") // receiver used msg2 = msg msg2.Receiver = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "receiver should change hash") + assert.NotEqual(t, hash, hash2, "receiver should change hash") // receiver chain ID used msg2 = msg msg2.ReceiverChain = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "receiver chain ID should change hash") + assert.NotEqual(t, hash, hash2, "receiver chain ID should change hash") // amount used msg2 = msg msg2.Amount = math.NewUint(43) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "amount should change hash") + assert.NotEqual(t, hash, hash2, "amount should change hash") // message used msg2 = msg msg2.Message = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "message should change hash") + assert.NotEqual(t, hash, hash2, "message should change hash") // in tx hash used msg2 = msg msg2.InTxHash = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "in tx hash should change hash") + assert.NotEqual(t, hash, hash2, "in tx hash should change hash") // gas limit used msg2 = msg msg2.GasLimit = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "gas limit should change hash") + assert.NotEqual(t, hash, hash2, "gas limit should change hash") // coin type used msg2 = msg msg2.CoinType = common.CoinType_ERC20 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "coin type should change hash") + assert.NotEqual(t, hash, hash2, "coin type should change hash") // asset used msg2 = msg msg2.Asset = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "asset should change hash") + assert.NotEqual(t, hash, hash2, "asset should change hash") // event index used msg2 = msg msg2.EventIndex = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "event index should change hash") + assert.NotEqual(t, hash, hash2, "event index should change hash") } diff --git a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go index cce6a29c3c..fda1a04d1d 100644 --- a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -91,10 +91,10 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } @@ -117,77 +117,77 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { CoinType: common.CoinType_Zeta, } hash := msg.Digest() - require.NotEmpty(t, hash, "hash should not be empty") + assert.NotEmpty(t, hash, "hash should not be empty") // creator not used msg2 := msg msg2.Creator = sample.AccAddress() hash2 := msg2.Digest() - require.Equal(t, hash, hash2, "creator should not change hash") + assert.Equal(t, hash, hash2, "creator should not change hash") // status not used msg2 = msg msg2.Status = common.ReceiveStatus_Failed hash2 = msg2.Digest() - require.Equal(t, hash, hash2, "status should not change hash") + assert.Equal(t, hash, hash2, "status should not change hash") // cctx hash used msg2 = msg msg2.CctxHash = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "cctx hash should change hash") + assert.NotEqual(t, hash, hash2, "cctx hash should change hash") // observed outbound tx hash used msg2 = msg msg2.ObservedOutTxHash = sample.StringRandom(r, 32) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "observed outbound tx hash should change hash") + assert.NotEqual(t, hash, hash2, "observed outbound tx hash should change hash") // observed outbound tx block height used msg2 = msg msg2.ObservedOutTxBlockHeight = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "observed outbound tx block height should change hash") + assert.NotEqual(t, hash, hash2, "observed outbound tx block height should change hash") // observed outbound tx gas used used msg2 = msg msg2.ObservedOutTxGasUsed = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "observed outbound tx gas used should change hash") + assert.NotEqual(t, hash, hash2, "observed outbound tx gas used should change hash") // observed outbound tx effective gas price used msg2 = msg msg2.ObservedOutTxEffectiveGasPrice = math.NewInt(43) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "observed outbound tx effective gas price should change hash") + assert.NotEqual(t, hash, hash2, "observed outbound tx effective gas price should change hash") // observed outbound tx effective gas limit used msg2 = msg msg2.ObservedOutTxEffectiveGasLimit = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "observed outbound tx effective gas limit should change hash") + assert.NotEqual(t, hash, hash2, "observed outbound tx effective gas limit should change hash") // zeta minted used msg2 = msg msg2.ValueReceived = math.NewUint(43) hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "zeta minted should change hash") + assert.NotEqual(t, hash, hash2, "zeta minted should change hash") // out tx chain used msg2 = msg msg2.OutTxChain = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "out tx chain should change hash") + assert.NotEqual(t, hash, hash2, "out tx chain should change hash") // out tx tss nonce used msg2 = msg msg2.OutTxTssNonce = 43 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "out tx tss nonce should change hash") + assert.NotEqual(t, hash, hash2, "out tx tss nonce should change hash") // coin type used msg2 = msg msg2.CoinType = common.CoinType_ERC20 hash2 = msg2.Digest() - require.NotEqual(t, hash, hash2, "coin type should change hash") + assert.NotEqual(t, hash, hash2, "coin type should change hash") } diff --git a/x/emissions/genesis_test.go b/x/emissions/genesis_test.go index cae3948ce1..7ad8ec6aa6 100644 --- a/x/emissions/genesis_test.go +++ b/x/emissions/genesis_test.go @@ -3,7 +3,7 @@ package emissions_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/testutil/sample" @@ -25,10 +25,10 @@ func TestGenesis(t *testing.T) { k, ctx := keepertest.EmissionsKeeper(t) emissions.InitGenesis(ctx, *k, genesisState) got := emissions.ExportGenesis(ctx, *k) - require.NotNil(t, got) + assert.NotNil(t, got) // Compare genesis after init and export nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState, *got) + assert.Equal(t, genesisState, *got) } diff --git a/x/emissions/types/genesis_test.go b/x/emissions/types/genesis_test.go index 6e0f27b4bc..46853a4e94 100644 --- a/x/emissions/types/genesis_test.go +++ b/x/emissions/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/emissions/types" ) @@ -27,9 +27,9 @@ func TestGenesisState_Validate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { - require.NoError(t, err) + assert.NoError(t, err) } else { - require.Error(t, err) + assert.Error(t, err) } }) } diff --git a/x/fungible/client/cli/query_foreign_coins_test.go b/x/fungible/client/cli/query_foreign_coins_test.go index b2e2602f7c..e661ee62c7 100644 --- a/x/fungible/client/cli/query_foreign_coins_test.go +++ b/x/fungible/client/cli/query_foreign_coins_test.go @@ -8,7 +8,7 @@ package cli_test // // "github.com/cosmos/cosmos-sdk/client/flags" // clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" -// "github.com/stretchr/testify/require" +// "github.com/stretchr/testify/assert" // tmcli "github.com/tendermint/tendermint/libs/cli" // "google.golang.org/grpc/codes" // "google.golang.org/grpc/status" @@ -26,7 +26,7 @@ package cli_test // t.Helper() // cfg := network.DefaultConfig() // state := types.GenesisState{} -// require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) +// assert.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) // // for i := 0; i < n; i++ { // foreignCoins := types.ForeignCoins{ @@ -36,7 +36,7 @@ package cli_test // state.ForeignCoinsList = append(state.ForeignCoinsList, foreignCoins) // } // buf, err := cfg.Codec.MarshalJSON(&state) -// require.NoError(t, err) +// assert.NoError(t, err) // cfg.GenesisState[types.ModuleName] = buf // return network.New(t, cfg), state.ForeignCoinsList //} @@ -79,14 +79,14 @@ package cli_test // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowForeignCoins(), args) // if tc.err != nil { // stat, ok := status.FromError(tc.err) -// require.True(t, ok) -// require.ErrorIs(t, stat.Err(), tc.err) +// assert.True(t, ok) +// assert.ErrorIs(t, stat.Err(), tc.err) // } else { -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryGetForeignCoinsResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.NotNil(t, resp.ForeignCoins) -// require.Equal(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.NotNil(t, resp.ForeignCoins) +// assert.Equal(t, // nullify.Fill(&tc.obj), // nullify.Fill(&resp.ForeignCoins), // ) @@ -119,11 +119,11 @@ package cli_test // for i := 0; i < len(objs); i += step { // args := request(nil, uint64(i), uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListForeignCoins(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllForeignCoinsResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.LessOrEqual(t, len(resp.ForeignCoins), step) -// require.Subset(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.LessOrEqual(t, len(resp.ForeignCoins), step) +// assert.Subset(t, // nullify.Fill(objs), // nullify.Fill(resp.ForeignCoins), // ) @@ -135,11 +135,11 @@ package cli_test // for i := 0; i < len(objs); i += step { // args := request(next, 0, uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListForeignCoins(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllForeignCoinsResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.LessOrEqual(t, len(resp.ForeignCoins), step) -// require.Subset(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.LessOrEqual(t, len(resp.ForeignCoins), step) +// assert.Subset(t, // nullify.Fill(objs), // nullify.Fill(resp.ForeignCoins), // ) @@ -149,12 +149,12 @@ package cli_test // t.Run("Total", func(t *testing.T) { // args := request(nil, 0, uint64(len(objs)), true) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListForeignCoins(), args) -// require.NoError(t, err) +// assert.NoError(t, err) // var resp types.QueryAllForeignCoinsResponse -// require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) -// require.NoError(t, err) -// require.Equal(t, len(objs), int(resp.Pagination.Total)) -// require.ElementsMatch(t, +// assert.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +// assert.NoError(t, err) +// assert.Equal(t, len(objs), int(resp.Pagination.Total)) +// assert.ElementsMatch(t, // nullify.Fill(objs), // nullify.Fill(resp.ForeignCoins), // ) diff --git a/x/fungible/genesis_test.go b/x/fungible/genesis_test.go index 119e862a18..2b72fb443f 100644 --- a/x/fungible/genesis_test.go +++ b/x/fungible/genesis_test.go @@ -3,7 +3,7 @@ package fungible_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/testutil/sample" @@ -26,10 +26,10 @@ func TestGenesis(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeper(t) fungible.InitGenesis(ctx, *k, genesisState) got := fungible.ExportGenesis(ctx, *k) - require.NotNil(t, got) + assert.NotNil(t, got) // Compare genesis after init and export nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState, *got) + assert.Equal(t, genesisState, *got) } diff --git a/x/fungible/keeper/deposits_test.go b/x/fungible/keeper/deposits_test.go index 4131a1e00d..d352851be3 100644 --- a/x/fungible/keeper/deposits_test.go +++ b/x/fungible/keeper/deposits_test.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/contracts" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" @@ -40,12 +40,12 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.NoError(t, err) - require.False(t, contractCall) + assert.NoError(t, err) + assert.False(t, contractCall) balance, err := k.BalanceOfZRC4(ctx, zrc20, to) - require.NoError(t, err) - require.Equal(t, big.NewInt(42), balance) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(42), balance) }) t.Run("can deposit non-gas coin for transfers", func(t *testing.T) { @@ -72,12 +72,12 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_ERC20, assetAddress, ) - require.NoError(t, err) - require.False(t, contractCall) + assert.NoError(t, err) + assert.False(t, contractCall) balance, err := k.BalanceOfZRC4(ctx, zrc20, to) - require.NoError(t, err) - require.Equal(t, big.NewInt(42), balance) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(42), balance) }) t.Run("should fail if trying to call a contract with data to a EOC", func(t *testing.T) { @@ -104,7 +104,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_ERC20, assetAddress, ) - require.ErrorIs(t, err, types.ErrCallNonContract) + assert.ErrorIs(t, err, types.ErrCallNonContract) }) t.Run("can deposit coin for transfers with liquidity cap not reached", func(t *testing.T) { @@ -121,17 +121,17 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { // there is an initial total supply minted during gas pool setup initialTotalSupply, err := k.TotalSupplyZRC4(ctx, zrc20) - require.NoError(t, err) + assert.NoError(t, err) // set a liquidity cap coin, found := k.GetForeignCoins(ctx, zrc20.String()) - require.True(t, found) + assert.True(t, found) coin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) k.SetForeignCoins(ctx, coin) // increase total supply _, err = k.DepositZRC20(ctx, zrc20, sample.EthAddress(), big.NewInt(500)) - require.NoError(t, err) + assert.NoError(t, err) // deposit to := sample.EthAddress() @@ -145,12 +145,12 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.NoError(t, err) - require.False(t, contractCall) + assert.NoError(t, err) + assert.False(t, contractCall) balance, err := k.BalanceOfZRC4(ctx, zrc20, to) - require.NoError(t, err) - require.Equal(t, big.NewInt(500), balance) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(500), balance) }) t.Run("should fail if coin paused", func(t *testing.T) { @@ -167,7 +167,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { // pause the coin coin, found := k.GetForeignCoins(ctx, zrc20.String()) - require.True(t, found) + assert.True(t, found) coin.Paused = true k.SetForeignCoins(ctx, coin) @@ -182,7 +182,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.ErrorIs(t, err, types.ErrPausedZRC20) + assert.ErrorIs(t, err, types.ErrPausedZRC20) }) t.Run("should fail if liquidity cap reached", func(t *testing.T) { @@ -199,17 +199,17 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { // there is an initial total supply minted during gas pool setup initialTotalSupply, err := k.TotalSupplyZRC4(ctx, zrc20) - require.NoError(t, err) + assert.NoError(t, err) // set a liquidity cap coin, found := k.GetForeignCoins(ctx, zrc20.String()) - require.True(t, found) + assert.True(t, found) coin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) k.SetForeignCoins(ctx, coin) // increase total supply _, err = k.DepositZRC20(ctx, zrc20, sample.EthAddress(), big.NewInt(500)) - require.NoError(t, err) + assert.NoError(t, err) // deposit (500 + 501 > 1000) to := sample.EthAddress() @@ -223,7 +223,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.ErrorIs(t, err, types.ErrForeignCoinCapReached) + assert.ErrorIs(t, err, types.ErrForeignCoinCapReached) }) t.Run("should fail if gas coin not found", func(t *testing.T) { @@ -249,7 +249,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.ErrorIs(t, err, crosschaintypes.ErrGasCoinNotFound) + assert.ErrorIs(t, err, crosschaintypes.ErrGasCoinNotFound) }) t.Run("should fail if zrc20 not found", func(t *testing.T) { @@ -275,7 +275,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_ERC20, assetAddress, ) - require.ErrorIs(t, err, crosschaintypes.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, crosschaintypes.ErrForeignCoinNotFound) }) t.Run("should return contract call if receiver is a contract", func(t *testing.T) { @@ -291,7 +291,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chain.ChainId, "foobar", "foobar") example, err := k.DeployContract(ctx, contracts.ExampleMetaData) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, example) // deposit @@ -305,12 +305,12 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.NoError(t, err) - require.True(t, contractCall) + assert.NoError(t, err) + assert.True(t, contractCall) balance, err := k.BalanceOfZRC4(ctx, zrc20, example) - require.NoError(t, err) - require.Equal(t, big.NewInt(42), balance) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(42), balance) // check onCrossChainCall() hook was called assertExampleBarValue(t, ctx, k, example, 42) @@ -329,7 +329,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chain.ChainId, "foobar", "foobar") reverter, err := k.DeployContract(ctx, contracts.ReverterMetaData) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, reverter) // deposit @@ -343,11 +343,11 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { common.CoinType_Gas, sample.EthAddress().String(), ) - require.Error(t, err) - require.True(t, contractCall) + assert.Error(t, err) + assert.True(t, contractCall) balance, err := k.BalanceOfZRC4(ctx, zrc20, reverter) - require.NoError(t, err) - require.EqualValues(t, int64(0), balance.Int64()) + assert.NoError(t, err) + assert.EqualValues(t, int64(0), balance.Int64()) }) } diff --git a/x/fungible/keeper/evm_hooks_test.go b/x/fungible/keeper/evm_hooks_test.go index 43e8a58326..ae77d2d202 100644 --- a/x/fungible/keeper/evm_hooks_test.go +++ b/x/fungible/keeper/evm_hooks_test.go @@ -4,7 +4,7 @@ import ( "testing" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -97,15 +97,15 @@ func TestKeeper_CheckPausedZRC20(t *testing.T) { t.Run(tc.name, func(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeper(t) - requireUnpaused := func(zrc20 string) { + assertUnpaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) - require.True(t, found) - require.False(t, fc.Paused) + assert.True(t, found) + assert.False(t, fc.Paused) } - requirePaused := func(zrc20 string) { + assertPaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) - require.True(t, found) - require.True(t, fc.Paused) + assert.True(t, found) + assert.True(t, fc.Paused) } // setup ZRC20 @@ -117,17 +117,17 @@ func TestKeeper_CheckPausedZRC20(t *testing.T) { k.SetForeignCoins(ctx, pausedZRC20) // check paused status - requireUnpaused(addrUnpausedZRC20A.Hex()) - requireUnpaused(addrUnpausedZRC20B.Hex()) - requireUnpaused(addrUnpausedZRC20C.Hex()) - requirePaused(addrPausedZRC20.Hex()) + assertUnpaused(addrUnpausedZRC20A.Hex()) + assertUnpaused(addrUnpausedZRC20B.Hex()) + assertUnpaused(addrUnpausedZRC20C.Hex()) + assertPaused(addrPausedZRC20.Hex()) // process test err := k.CheckPausedZRC20(ctx, tc.receipt) if tc.wantErr { - require.ErrorIs(t, err, types.ErrPausedZRC20) + assert.ErrorIs(t, err, types.ErrPausedZRC20) } else { - require.NoError(t, err) + assert.NoError(t, err) } }) } diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 80bd42a2f3..877dc70c02 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -10,8 +10,8 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" zetacommon "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/server/config" @@ -26,8 +26,8 @@ import ( // get a valid chain id independently of the build flag func getValidChainID(t *testing.T) int64 { list := zetacommon.DefaultChainsList() - require.NotEmpty(t, list) - require.NotNil(t, list[0]) + assert.NotEmpty(t, list) + assert.NotNil(t, list[0]) return list[0].ChainId } @@ -35,10 +35,10 @@ func getValidChainID(t *testing.T) int64 { // assert that a contract has been deployed by checking stored code is non-empty. func assertContractDeployment(t *testing.T, k *evmkeeper.Keeper, ctx sdk.Context, contractAddress common.Address) { acc := k.GetAccount(ctx, contractAddress) - require.NotNil(t, acc) + assert.NotNil(t, acc) code := k.GetCode(ctx, common.BytesToHash(acc.CodeHash)) - require.NotEmpty(t, code) + assert.NotEmpty(t, code) } // deploySystemContracts deploys the system contracts and returns their addresses. @@ -51,28 +51,28 @@ func deploySystemContracts( var err error wzeta, err = k.DeployWZETA(ctx) - require.NoError(t, err) - require.NotEmpty(t, wzeta) + assert.NoError(t, err) + assert.NotEmpty(t, wzeta) assertContractDeployment(t, evmk, ctx, wzeta) uniswapV2Factory, err = k.DeployUniswapV2Factory(ctx) - require.NoError(t, err) - require.NotEmpty(t, uniswapV2Factory) + assert.NoError(t, err) + assert.NotEmpty(t, uniswapV2Factory) assertContractDeployment(t, evmk, ctx, uniswapV2Factory) uniswapV2Router, err = k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) - require.NoError(t, err) - require.NotEmpty(t, uniswapV2Router) + assert.NoError(t, err) + assert.NotEmpty(t, uniswapV2Router) assertContractDeployment(t, evmk, ctx, uniswapV2Router) connector, err = k.DeployConnectorZEVM(ctx, wzeta) - require.NoError(t, err) - require.NotEmpty(t, connector) + assert.NoError(t, err) + assert.NotEmpty(t, connector) assertContractDeployment(t, evmk, ctx, connector) systemContract, err = k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, uniswapV2Router) - require.NoError(t, err) - require.NotEmpty(t, systemContract) + assert.NoError(t, err) + assert.NotEmpty(t, systemContract) assertContractDeployment(t, evmk, ctx, systemContract) return @@ -87,7 +87,7 @@ func assertExampleBarValue( expected int64, ) { exampleABI, err := contracts.ExampleMetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) res, err := k.CallEVM( ctx, *exampleABI, @@ -100,11 +100,11 @@ func assertExampleBarValue( "bar", ) unpacked, err := exampleABI.Unpack("bar", res.Ret) - require.NoError(t, err) - require.NotZero(t, len(unpacked)) + assert.NoError(t, err) + assert.NotZero(t, len(unpacked)) bar, ok := unpacked[0].(*big.Int) - require.True(t, ok) - require.Equal(t, big.NewInt(expected), bar) + assert.True(t, ok) + assert.Equal(t, big.NewInt(expected), bar) } func TestKeeper_DeployZRC20Contract(t *testing.T) { @@ -125,42 +125,42 @@ func TestKeeper_DeployZRC20Contract(t *testing.T) { "foobar", big.NewInt(1000), ) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, addr) // check foreign coin foreignCoins, found := k.GetForeignCoins(ctx, addr.Hex()) - require.True(t, found) - require.Equal(t, "foobar", foreignCoins.Asset) - require.Equal(t, chainID, foreignCoins.ForeignChainId) - require.Equal(t, uint32(8), foreignCoins.Decimals) - require.Equal(t, "foo", foreignCoins.Name) - require.Equal(t, "bar", foreignCoins.Symbol) - require.Equal(t, zetacommon.CoinType_Gas, foreignCoins.CoinType) - require.Equal(t, uint64(1000), foreignCoins.GasLimit) + assert.True(t, found) + assert.Equal(t, "foobar", foreignCoins.Asset) + assert.Equal(t, chainID, foreignCoins.ForeignChainId) + assert.Equal(t, uint32(8), foreignCoins.Decimals) + assert.Equal(t, "foo", foreignCoins.Name) + assert.Equal(t, "bar", foreignCoins.Symbol) + assert.Equal(t, zetacommon.CoinType_Gas, foreignCoins.CoinType) + assert.Equal(t, uint64(1000), foreignCoins.GasLimit) // can get the zrc20 data zrc20Data, err := k.QueryZRC20Data(ctx, addr) - require.NoError(t, err) - require.Equal(t, "foo", zrc20Data.Name) - require.Equal(t, "bar", zrc20Data.Symbol) - require.Equal(t, uint8(8), zrc20Data.Decimals) + assert.NoError(t, err) + assert.Equal(t, "foo", zrc20Data.Name) + assert.Equal(t, "bar", zrc20Data.Symbol) + assert.Equal(t, uint8(8), zrc20Data.Decimals) // can deposit tokens to := sample.EthAddress() oldBalance, err := k.BalanceOfZRC4(ctx, addr, to) - require.NoError(t, err) - require.NotNil(t, oldBalance) - require.Equal(t, int64(0), oldBalance.Int64()) + assert.NoError(t, err) + assert.NotNil(t, oldBalance) + assert.Equal(t, int64(0), oldBalance.Int64()) amount := big.NewInt(100) _, err = k.DepositZRC20(ctx, addr, to, amount) - require.NoError(t, err) + assert.NoError(t, err) newBalance, err := k.BalanceOfZRC4(ctx, addr, to) - require.NoError(t, err) - require.NotNil(t, newBalance) - require.Equal(t, amount.Int64(), newBalance.Int64()) + assert.NoError(t, err) + assert.NotNil(t, newBalance) + assert.Equal(t, amount.Int64(), newBalance.Int64()) }) } @@ -174,23 +174,23 @@ func TestKeeper_DeploySystemContract(t *testing.T) { // can find system contract address found, err := k.GetSystemContractAddress(ctx) - require.NoError(t, err) - require.Equal(t, systemContract, found) + assert.NoError(t, err) + assert.Equal(t, systemContract, found) // can find factory address found, err = k.GetUniswapV2FactoryAddress(ctx) - require.NoError(t, err) - require.Equal(t, uniswapV2Factory, found) + assert.NoError(t, err) + assert.Equal(t, uniswapV2Factory, found) // can find router address found, err = k.GetUniswapV2Router02Address(ctx) - require.NoError(t, err) - require.Equal(t, uniswapV2Router, found) + assert.NoError(t, err) + assert.Equal(t, uniswapV2Router, found) // can find the wzeta contract address found, err = k.GetWZetaContractAddress(ctx) - require.NoError(t, err) - require.Equal(t, wzeta, found) + assert.NoError(t, err) + assert.Equal(t, wzeta, found) }) t.Run("can deposit into wzeta", func(t *testing.T) { @@ -200,21 +200,21 @@ func TestKeeper_DeploySystemContract(t *testing.T) { wzeta, _, _, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) balance, err := k.BalanceOfZRC4(ctx, wzeta, types.ModuleAddressEVM) - require.NoError(t, err) - require.NotNil(t, balance) - require.Equal(t, int64(0), balance.Int64()) + assert.NoError(t, err) + assert.NotNil(t, balance) + assert.Equal(t, int64(0), balance.Int64()) amount := big.NewInt(100) err = sdkk.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("azeta", sdk.NewIntFromBigInt(amount)))) - require.NoError(t, err) + assert.NoError(t, err) err = k.CallWZetaDeposit(ctx, types.ModuleAddressEVM, amount) - require.NoError(t, err) + assert.NoError(t, err) balance, err = k.BalanceOfZRC4(ctx, wzeta, types.ModuleAddressEVM) - require.NoError(t, err) - require.NotNil(t, balance) - require.Equal(t, amount.Int64(), balance.Int64()) + assert.NoError(t, err) + assert.NotNil(t, balance) + assert.Equal(t, amount.Int64(), balance.Int64()) }) } @@ -228,7 +228,7 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chainID, "foobar", "FOOBAR") example, err := k.DeployContract(ctx, contracts.ExampleMetaData) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, example) res, err := k.DepositZRC20AndCallContract( @@ -243,15 +243,15 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { big.NewInt(42), []byte(""), ) - require.NoError(t, err) - require.False(t, types.IsContractReverted(res, err)) + assert.NoError(t, err) + assert.False(t, types.IsContractReverted(res, err)) balance, err := k.BalanceOfZRC4(ctx, zrc20, example) - require.NoError(t, err) - require.Equal(t, int64(42), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(42), balance.Int64()) // check onCrossChainCall has been called exampleABI, err := contracts.ExampleMetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) res, err = k.CallEVM( ctx, *exampleABI, @@ -264,11 +264,11 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { "bar", ) unpacked, err := exampleABI.Unpack("bar", res.Ret) - require.NoError(t, err) - require.NotZero(t, len(unpacked)) + assert.NoError(t, err) + assert.NotZero(t, len(unpacked)) bar, ok := unpacked[0].(*big.Int) - require.True(t, ok) - require.Equal(t, big.NewInt(42), bar) + assert.True(t, ok) + assert.Equal(t, big.NewInt(42), bar) }) t.Run("should return a revert error when the underlying contract call revert", func(t *testing.T) { @@ -281,7 +281,7 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { // Deploy reverter reverter, err := k.DeployContract(ctx, contracts.ReverterMetaData) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, reverter) res, err := k.DepositZRC20AndCallContract( @@ -296,10 +296,10 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { big.NewInt(42), []byte(""), ) - require.True(t, types.IsContractReverted(res, err)) + assert.True(t, types.IsContractReverted(res, err)) balance, err := k.BalanceOfZRC4(ctx, zrc20, reverter) - require.NoError(t, err) - require.Zero(t, balance.Int64()) + assert.NoError(t, err) + assert.Zero(t, balance.Int64()) }) t.Run("should revert if the underlying contract doesn't exist", func(t *testing.T) { @@ -322,7 +322,7 @@ func TestKeeper_DepositZRC20AndCallContract(t *testing.T) { big.NewInt(42), []byte(""), ) - require.True(t, types.IsContractReverted(res, err)) + assert.True(t, types.IsContractReverted(res, err)) }) } @@ -333,10 +333,10 @@ func TestKeeper_CallEVMWithData(t *testing.T) { // Deploy example contract, err := k.DeployContract(ctx, contracts.ExampleMetaData) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, contract) abi, err := contracts.ExampleMetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) // doRevert make contract reverted res, err := k.CallEVM( @@ -350,12 +350,12 @@ func TestKeeper_CallEVMWithData(t *testing.T) { false, "doRevert", ) - require.Nil(t, res) - require.True(t, types.IsContractReverted(res, err)) + assert.Nil(t, res) + assert.True(t, types.IsContractReverted(res, err)) // check reason is included for revert error // 0xbfb4ebcf is the hash of "Foo()" - require.Contains(t, err.Error(), "reason: 0xbfb4ebcf") + assert.Contains(t, err.Error(), "reason: 0xbfb4ebcf") res, err = k.CallEVM( ctx, @@ -368,8 +368,8 @@ func TestKeeper_CallEVMWithData(t *testing.T) { false, "doRevertWithMessage", ) - require.Nil(t, res) - require.True(t, types.IsContractReverted(res, err)) + assert.Nil(t, res) + assert.True(t, types.IsContractReverted(res, err)) res, err = k.CallEVM( ctx, @@ -382,8 +382,8 @@ func TestKeeper_CallEVMWithData(t *testing.T) { false, "doRevertWithRequire", ) - require.Nil(t, res) - require.True(t, types.IsContractReverted(res, err)) + assert.Nil(t, res) + assert.True(t, types.IsContractReverted(res, err)) // Not a revert error if another type of error res, err = k.CallEVM( @@ -397,10 +397,10 @@ func TestKeeper_CallEVMWithData(t *testing.T) { false, "doNotExist", ) - require.Nil(t, res) - require.Error(t, err) - require.False(t, types.IsContractReverted(res, err)) - require.NotContains(t, err.Error(), "reason:") + assert.Nil(t, res) + assert.Error(t, err) + assert.False(t, types.IsContractReverted(res, err)) + assert.NotContains(t, err.Error(), "reason:") // No revert with successfull call res, err = k.CallEVM( @@ -414,9 +414,9 @@ func TestKeeper_CallEVMWithData(t *testing.T) { false, "doSucceed", ) - require.NotNil(t, res) - require.NoError(t, err) - require.False(t, types.IsContractReverted(res, err)) + assert.NotNil(t, res) + assert.NoError(t, err) + assert.False(t, types.IsContractReverted(res, err)) }) t.Run("apply new message without gas limit estimates gas", func(t *testing.T) { @@ -473,8 +473,8 @@ func TestKeeper_CallEVMWithData(t *testing.T) { big.NewInt(100), nil, ) - require.NoError(t, err) - require.Equal(t, msgRes, res) + assert.NoError(t, err) + assert.Equal(t, msgRes, res) // Assert that the expected methods were called mockAuthKeeper.AssertExpectations(t) @@ -523,8 +523,8 @@ func TestKeeper_CallEVMWithData(t *testing.T) { big.NewInt(100), big.NewInt(1000), ) - require.NoError(t, err) - require.Equal(t, msgRes, res) + assert.NoError(t, err) + assert.Equal(t, msgRes, res) // Assert that the expected methods were called mockAuthKeeper.AssertExpectations(t) @@ -549,7 +549,7 @@ func TestKeeper_CallEVMWithData(t *testing.T) { big.NewInt(100), nil, ) - require.ErrorIs(t, err, sample.ErrSample) + assert.ErrorIs(t, err, sample.ErrSample) }) t.Run("EstimateGas failure returns error", func(t *testing.T) { @@ -585,7 +585,7 @@ func TestKeeper_CallEVMWithData(t *testing.T) { big.NewInt(100), nil, ) - require.ErrorIs(t, err, sample.ErrSample) + assert.ErrorIs(t, err, sample.ErrSample) }) t.Run("ApplyMessage failure returns error", func(t *testing.T) { @@ -639,6 +639,6 @@ func TestKeeper_CallEVMWithData(t *testing.T) { big.NewInt(100), nil, ) - require.ErrorIs(t, err, sample.ErrSample) + assert.ErrorIs(t, err, sample.ErrSample) }) } diff --git a/x/fungible/keeper/foreign_coins_test.go b/x/fungible/keeper/foreign_coins_test.go index 0a5a0f37f0..c82f4d96be 100644 --- a/x/fungible/keeper/foreign_coins_test.go +++ b/x/fungible/keeper/foreign_coins_test.go @@ -4,7 +4,7 @@ import ( "strconv" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -68,12 +68,12 @@ func TestKeeper_GetGasCoinForForeignCoin(t *testing.T) { ) fc, found := k.GetGasCoinForForeignCoin(ctx, 1) - require.True(t, found) - require.Equal(t, "bar", fc.Name) + assert.True(t, found) + assert.Equal(t, "bar", fc.Name) fc, found = k.GetGasCoinForForeignCoin(ctx, 2) - require.False(t, found) + assert.False(t, found) fc, found = k.GetGasCoinForForeignCoin(ctx, 3) - require.False(t, found) + assert.False(t, found) } func TestKeeperGetForeignCoinFromAsset(t *testing.T) { @@ -122,16 +122,16 @@ func TestKeeperGetForeignCoinFromAsset(t *testing.T) { ) fc, found := k.GetForeignCoinFromAsset(ctx, gasAsset, 1) - require.True(t, found) - require.Equal(t, "bar", fc.Name) + assert.True(t, found) + assert.Equal(t, "bar", fc.Name) fc, found = k.GetForeignCoinFromAsset(ctx, sample.EthAddress().String(), 1) - require.False(t, found) + assert.False(t, found) fc, found = k.GetForeignCoinFromAsset(ctx, "invalid_address", 1) - require.False(t, found) + assert.False(t, found) fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 2) - require.False(t, found) + assert.False(t, found) fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 3) - require.False(t, found) + assert.False(t, found) }) t.Run("can get foreign coin with non-checksum address", func(t *testing.T) { @@ -148,7 +148,7 @@ func TestKeeperGetForeignCoinFromAsset(t *testing.T) { ) fc, found := k.GetForeignCoinFromAsset(ctx, "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", 1) - require.True(t, found) - require.Equal(t, "foo", fc.Name) + assert.True(t, found) + assert.Equal(t, "foo", fc.Name) }) } diff --git a/x/fungible/keeper/gas_coin_and_pool_test.go b/x/fungible/keeper/gas_coin_and_pool_test.go index 9bdd139fdc..196fc8a0fa 100644 --- a/x/fungible/keeper/gas_coin_and_pool_test.go +++ b/x/fungible/keeper/gas_coin_and_pool_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" @@ -32,7 +32,7 @@ func setupGasCoin( 8, nil, ) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) return addr } @@ -57,7 +57,7 @@ func deployZRC20( assetAddress, big.NewInt(21_000), ) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) return addr } @@ -76,7 +76,7 @@ func TestKeeper_SetupChainGasCoinAndPool(t *testing.T) { // can retrieve the gas coin found, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) - require.NoError(t, err) - require.Equal(t, zrc20, found) + assert.NoError(t, err) + assert.Equal(t, zrc20, found) }) } diff --git a/x/fungible/keeper/gas_price_test.go b/x/fungible/keeper/gas_price_test.go index ec1bf267d8..d5295ed560 100644 --- a/x/fungible/keeper/gas_price_test.go +++ b/x/fungible/keeper/gas_price_test.go @@ -5,7 +5,7 @@ import ( "testing" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -21,19 +21,19 @@ func TestKeeper_SetGasPrice(t *testing.T) { queryGasPrice := func(chainID *big.Int) *big.Int { abi, err := systemcontract.SystemContractMetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, system, keeper.BigIntZero, nil, false, false, "gasPriceByChainId", chainID) - require.NoError(t, err) + assert.NoError(t, err) unpacked, err := abi.Unpack("gasPriceByChainId", res.Ret) - require.NoError(t, err) + assert.NoError(t, err) gasPrice, ok := unpacked[0].(*big.Int) - require.True(t, ok) + assert.True(t, ok) return gasPrice } _, err := k.SetGasPrice(ctx, big.NewInt(1), big.NewInt(42)) - require.NoError(t, err) - require.Equal(t, big.NewInt(42), queryGasPrice(big.NewInt(1))) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(42), queryGasPrice(big.NewInt(1))) } func TestKeeper_SetGasCoin(t *testing.T) { @@ -43,11 +43,11 @@ func TestKeeper_SetGasCoin(t *testing.T) { deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) err := k.SetGasCoin(ctx, big.NewInt(1), gas) - require.NoError(t, err) + assert.NoError(t, err) found, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(1)) - require.NoError(t, err) - require.Equal(t, gas.Hex(), found.Hex()) + assert.NoError(t, err) + assert.Equal(t, gas.Hex(), found.Hex()) } func TestKeeper_SetGasZetaPool(t *testing.T) { @@ -59,17 +59,17 @@ func TestKeeper_SetGasZetaPool(t *testing.T) { queryZetaPool := func(chainID *big.Int) ethcommon.Address { abi, err := systemcontract.SystemContractMetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, system, keeper.BigIntZero, nil, false, false, "gasZetaPoolByChainId", chainID) - require.NoError(t, err) + assert.NoError(t, err) unpacked, err := abi.Unpack("gasZetaPoolByChainId", res.Ret) - require.NoError(t, err) + assert.NoError(t, err) pool, ok := unpacked[0].(ethcommon.Address) - require.True(t, ok) + assert.True(t, ok) return pool } err := k.SetGasZetaPool(ctx, big.NewInt(1), zrc20) - require.NoError(t, err) - require.NotEqual(t, ethcommon.Address{}, queryZetaPool(big.NewInt(1))) + assert.NoError(t, err) + assert.NotEqual(t, ethcommon.Address{}, queryZetaPool(big.NewInt(1))) } diff --git a/x/fungible/keeper/gas_stability_pool_test.go b/x/fungible/keeper/gas_stability_pool_test.go index 1c9bbc7b12..c2fb629267 100644 --- a/x/fungible/keeper/gas_stability_pool_test.go +++ b/x/fungible/keeper/gas_stability_pool_test.go @@ -4,7 +4,7 @@ import ( "math/big" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -15,21 +15,21 @@ func TestKeeper_EnsureGasStabilityPoolAccountCreated(t *testing.T) { // account doesn't exist acc := k.GetAuthKeeper().GetAccount(ctx, types.GasStabilityPoolAddress()) - require.Nil(t, acc) + assert.Nil(t, acc) // create the account k.EnsureGasStabilityPoolAccountCreated(ctx) acc = k.GetAuthKeeper().GetAccount(ctx, types.GasStabilityPoolAddress()) - require.NotNil(t, acc) - require.Equal(t, types.GasStabilityPoolAddress(), acc.GetAddress()) + assert.NotNil(t, acc) + assert.Equal(t, types.GasStabilityPoolAddress(), acc.GetAddress()) // can call the method again without side effects k.EnsureGasStabilityPoolAccountCreated(ctx) acc2 := k.GetAuthKeeper().GetAccount(ctx, types.GasStabilityPoolAddress()) - require.NotNil(t, acc2) - require.True(t, acc.GetAddress().Equals(acc2.GetAddress())) - require.Equal(t, acc.GetAccountNumber(), acc2.GetAccountNumber()) - require.Equal(t, acc.GetSequence(), acc2.GetSequence()) + assert.NotNil(t, acc2) + assert.True(t, acc.GetAddress().Equals(acc2.GetAddress())) + assert.Equal(t, acc.GetAccountNumber(), acc2.GetAccountNumber()) + assert.Equal(t, acc.GetSequence(), acc2.GetSequence()) }) } @@ -46,25 +46,25 @@ func TestKeeper_FundGasStabilityPool(t *testing.T) { // balance is initially 0 balance, err := k.GetGasStabilityPoolBalance(ctx, chainID) - require.NoError(t, err) - require.Equal(t, int64(0), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(0), balance.Int64()) // fund the gas stability pool err = k.FundGasStabilityPool(ctx, chainID, big.NewInt(100)) - require.NoError(t, err) + assert.NoError(t, err) // balance is now 100 balance, err = k.GetGasStabilityPoolBalance(ctx, chainID) - require.NoError(t, err) - require.Equal(t, int64(100), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(100), balance.Int64()) // withdraw from the gas stability pool err = k.WithdrawFromGasStabilityPool(ctx, chainID, big.NewInt(50)) - require.NoError(t, err) + assert.NoError(t, err) // balance is now 50 balance, err = k.GetGasStabilityPoolBalance(ctx, chainID) - require.NoError(t, err) - require.Equal(t, int64(50), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(50), balance.Int64()) }) } diff --git a/x/fungible/keeper/grpc_query_code_hash_test.go b/x/fungible/keeper/grpc_query_code_hash_test.go index e2359dc530..43d1010c90 100644 --- a/x/fungible/keeper/grpc_query_code_hash_test.go +++ b/x/fungible/keeper/grpc_query_code_hash_test.go @@ -4,7 +4,7 @@ import ( "testing" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -17,14 +17,14 @@ func TestKeeper_CodeHash(t *testing.T) { wzeta, _, _, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) acc := sdkk.EvmKeeper.GetAccount(ctx, wzeta) - require.NotNil(t, acc) - require.NotNil(t, acc.CodeHash) + assert.NotNil(t, acc) + assert.NotNil(t, acc.CodeHash) res, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ Address: wzeta.Hex(), }) - require.NoError(t, err) - require.Equal(t, ethcommon.BytesToHash(acc.CodeHash).Hex(), res.CodeHash) + assert.NoError(t, err) + assert.Equal(t, ethcommon.BytesToHash(acc.CodeHash).Hex(), res.CodeHash) }) t.Run("should return error if address is invalid", func(t *testing.T) { @@ -33,8 +33,8 @@ func TestKeeper_CodeHash(t *testing.T) { _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ Address: "invalid", }) - require.Error(t, err) - require.ErrorContains(t, err, "invalid address") + assert.Error(t, err) + assert.ErrorContains(t, err, "invalid address") }) t.Run("should return error if account not found", func(t *testing.T) { @@ -43,8 +43,8 @@ func TestKeeper_CodeHash(t *testing.T) { _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ Address: sample.EthAddress().Hex(), }) - require.Error(t, err) - require.ErrorContains(t, err, "account not found") + assert.Error(t, err) + assert.ErrorContains(t, err, "account not found") }) t.Run("should return error if account is not a contract", func(t *testing.T) { @@ -54,7 +54,7 @@ func TestKeeper_CodeHash(t *testing.T) { _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ Address: types.ModuleAddressEVM.Hex(), }) - require.Error(t, err) - require.ErrorContains(t, err, "account is not a contract") + assert.Error(t, err) + assert.ErrorContains(t, err, "account is not a contract") }) } diff --git a/x/fungible/keeper/grpc_query_foreign_coins_test.go b/x/fungible/keeper/grpc_query_foreign_coins_test.go index 76b4b2e7c0..bb9f641364 100644 --- a/x/fungible/keeper/grpc_query_foreign_coins_test.go +++ b/x/fungible/keeper/grpc_query_foreign_coins_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -54,10 +54,10 @@ func TestForeignCoinsQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.ForeignCoins(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.NoError(t, err) - require.Equal(t, + assert.NoError(t, err) + assert.Equal(t, nullify.Fill(tc.response), nullify.Fill(response), ) @@ -85,9 +85,9 @@ func TestForeignCoinsQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.ForeignCoinsAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.ForeignCoins), step) - require.Subset(t, + assert.NoError(t, err) + assert.LessOrEqual(t, len(resp.ForeignCoins), step) + assert.Subset(t, nullify.Fill(msgs), nullify.Fill(resp.ForeignCoins), ) @@ -98,9 +98,9 @@ func TestForeignCoinsQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.ForeignCoinsAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.ForeignCoins), step) - require.Subset(t, + assert.NoError(t, err) + assert.LessOrEqual(t, len(resp.ForeignCoins), step) + assert.Subset(t, nullify.Fill(msgs), nullify.Fill(resp.ForeignCoins), ) @@ -109,15 +109,15 @@ func TestForeignCoinsQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.ForeignCoinsAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.ElementsMatch(t, nullify.Fill(msgs), nullify.Fill(resp.ForeignCoins), ) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.ForeignCoinsAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/fungible/keeper/grpc_query_params_test.go b/x/fungible/keeper/grpc_query_params_test.go index 634c6a38f6..377fe3f664 100644 --- a/x/fungible/keeper/grpc_query_params_test.go +++ b/x/fungible/keeper/grpc_query_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -16,6 +16,6 @@ func TestParamsQuery(t *testing.T) { keeper.SetParams(ctx, params) response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) + assert.NoError(t, err) + assert.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go index 1e64419f1a..b31725f422 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -36,24 +36,24 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { common.CoinType_Gas, 1000000, )) - require.NoError(t, err) + assert.NoError(t, err) gasAddress := res.Address assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(gasAddress)) // can retrieve the gas coin foreignCoin, found := k.GetForeignCoins(ctx, gasAddress) - require.True(t, found) - require.Equal(t, foreignCoin.CoinType, common.CoinType_Gas) - require.Contains(t, foreignCoin.Name, "foo") + assert.True(t, found) + assert.Equal(t, foreignCoin.CoinType, common.CoinType_Gas) + assert.Contains(t, foreignCoin.Name, "foo") // check gas limit gasLimit, err := k.QueryGasLimit(ctx, ethcommon.HexToAddress(foreignCoin.Zrc20ContractAddress)) - require.NoError(t, err) - require.Equal(t, uint64(1000000), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(1000000), gasLimit.Uint64()) gas, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) - require.NoError(t, err) - require.Equal(t, gasAddress, gas.Hex()) + assert.NoError(t, err) + assert.Equal(t, gasAddress, gas.Hex()) // can deploy non-gas zrc20 res, err = msgServer.DeployFungibleCoinZRC20(ctx, types.NewMsgDeployFungibleCoinZRC20( @@ -66,24 +66,24 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { common.CoinType_ERC20, 2000000, )) - require.NoError(t, err) + assert.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.Address)) foreignCoin, found = k.GetForeignCoins(ctx, res.Address) - require.True(t, found) - require.Equal(t, foreignCoin.CoinType, common.CoinType_ERC20) - require.Contains(t, foreignCoin.Name, "bar") + assert.True(t, found) + assert.Equal(t, foreignCoin.CoinType, common.CoinType_ERC20) + assert.Contains(t, foreignCoin.Name, "bar") // check gas limit gasLimit, err = k.QueryGasLimit(ctx, ethcommon.HexToAddress(foreignCoin.Zrc20ContractAddress)) - require.NoError(t, err) - require.Equal(t, uint64(2000000), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(2000000), gasLimit.Uint64()) // gas should remain the same gas, err = k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) - require.NoError(t, err) - require.NotEqual(t, res.Address, gas.Hex()) - require.Equal(t, gasAddress, gas.Hex()) + assert.NoError(t, err) + assert.NotEqual(t, res.Address, gas.Hex()) + assert.Equal(t, gasAddress, gas.Hex()) }) t.Run("should not deploy a new zrc20 if not admin", func(t *testing.T) { @@ -104,8 +104,8 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { common.CoinType_Gas, 1000000, )) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should not deploy a new zrc20 with wrong decimal", func(t *testing.T) { @@ -128,8 +128,8 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { common.CoinType_Gas, 1000000, )) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) }) t.Run("should not deploy a new zrc20 with invalid chain ID", func(t *testing.T) { @@ -151,8 +151,8 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { common.CoinType_Gas, 1000000, )) - require.Error(t, err) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) + assert.Error(t, err) + assert.ErrorIs(t, err, observertypes.ErrSupportedChains) }) t.Run("should not deploy an existing gas or erc20 contract", func(t *testing.T) { @@ -177,17 +177,17 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { // Attempt to deploy the same gas token twice should result in error _, err := keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) - require.NoError(t, err) + assert.NoError(t, err) _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) // Similar to above, redeploying existing erc20 should also fail deployMsg.CoinType = common.CoinType_ERC20 _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) - require.NoError(t, err) + assert.NoError(t, err) _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) }) } diff --git a/x/fungible/keeper/msg_server_deploy_system_contract_test.go b/x/fungible/keeper/msg_server_deploy_system_contract_test.go index 86b9745021..601405d89c 100644 --- a/x/fungible/keeper/msg_server_deploy_system_contract_test.go +++ b/x/fungible/keeper/msg_server_deploy_system_contract_test.go @@ -8,7 +8,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/keeper" @@ -25,8 +25,8 @@ func TestMsgServer_DeploySystemContracts(t *testing.T) { setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) res, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(admin)) - require.NoError(t, err) - require.NotNil(t, res) + assert.NoError(t, err) + assert.NotNil(t, res) assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.UniswapV2Factory)) assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.Wzeta)) assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.UniswapV2Router)) @@ -42,7 +42,7 @@ func TestMsgServer_DeploySystemContracts(t *testing.T) { setAdminPolicies(ctx, zk, nonadmin, observertypes.Policy_Type_group1) _, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(nonadmin)) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if contract deployment fails", func(t *testing.T) { @@ -62,7 +62,7 @@ func TestMsgServer_DeploySystemContracts(t *testing.T) { ).Return(nil, errors.New("failed to estimate gas")) _, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(admin)) - require.Error(t, err) - require.Contains(t, err.Error(), "failed to deploy") + assert.Error(t, err) + assert.Contains(t, err.Error(), "failed to deploy") }) } diff --git a/x/fungible/keeper/msg_server_remove_foreign_coin_test.go b/x/fungible/keeper/msg_server_remove_foreign_coin_test.go index fedfe7315b..848e609b2f 100644 --- a/x/fungible/keeper/msg_server_remove_foreign_coin_test.go +++ b/x/fungible/keeper/msg_server_remove_foreign_coin_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/keeper" @@ -25,12 +25,12 @@ func TestMsgServer_RemoveForeignCoin(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chainID, "foo", "foo") _, found := k.GetForeignCoins(ctx, zrc20.Hex()) - require.True(t, found) + assert.True(t, found) _, err := msgServer.RemoveForeignCoin(ctx, types.NewMsgRemoveForeignCoin(admin, zrc20.Hex())) - require.NoError(t, err) + assert.NoError(t, err) _, found = k.GetForeignCoins(ctx, zrc20.Hex()) - require.False(t, found) + assert.False(t, found) }) t.Run("should fail if not admin", func(t *testing.T) { @@ -43,8 +43,8 @@ func TestMsgServer_RemoveForeignCoin(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chainID, "foo", "foo") _, err := msgServer.RemoveForeignCoin(ctx, types.NewMsgRemoveForeignCoin(sample.AccAddress(), zrc20.Hex())) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if not found", func(t *testing.T) { @@ -55,7 +55,7 @@ func TestMsgServer_RemoveForeignCoin(t *testing.T) { setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) _, err := msgServer.RemoveForeignCoin(ctx, types.NewMsgRemoveForeignCoin(admin, sample.EthAddress().Hex())) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) }) } diff --git a/x/fungible/keeper/msg_server_udpate_zrc20_liquidity_cap_test.go b/x/fungible/keeper/msg_server_udpate_zrc20_liquidity_cap_test.go index ea51fabc14..f42286928a 100644 --- a/x/fungible/keeper/msg_server_udpate_zrc20_liquidity_cap_test.go +++ b/x/fungible/keeper/msg_server_udpate_zrc20_liquidity_cap_test.go @@ -5,7 +5,7 @@ import ( "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/keeper" @@ -32,11 +32,11 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.NewUint(42), )) - require.NoError(t, err) + assert.NoError(t, err) coin, found := k.GetForeignCoins(ctx, coinAddress) - require.True(t, found) - require.True(t, coin.LiquidityCap.Equal(math.NewUint(42)), "invalid liquidity cap", coin.LiquidityCap.String()) + assert.True(t, found) + assert.True(t, coin.LiquidityCap.Equal(math.NewUint(42)), "invalid liquidity cap", coin.LiquidityCap.String()) // can update liquidity cap again _, err = msgServer.UpdateZRC20LiquidityCap(ctx, types.NewMsgUpdateZRC20LiquidityCap( @@ -44,11 +44,11 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.NewUint(4200000), )) - require.NoError(t, err) + assert.NoError(t, err) coin, found = k.GetForeignCoins(ctx, coinAddress) - require.True(t, found) - require.True(t, coin.LiquidityCap.Equal(math.NewUint(4200000)), "invalid liquidity cap", coin.LiquidityCap.String()) + assert.True(t, found) + assert.True(t, coin.LiquidityCap.Equal(math.NewUint(4200000)), "invalid liquidity cap", coin.LiquidityCap.String()) // can set liquidity cap to 0 _, err = msgServer.UpdateZRC20LiquidityCap(ctx, types.NewMsgUpdateZRC20LiquidityCap( @@ -56,11 +56,11 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.NewUint(0), )) - require.NoError(t, err) + assert.NoError(t, err) coin, found = k.GetForeignCoins(ctx, coinAddress) - require.True(t, found) - require.True(t, coin.LiquidityCap.Equal(math.ZeroUint()), "invalid liquidity cap", coin.LiquidityCap.String()) + assert.True(t, found) + assert.True(t, coin.LiquidityCap.Equal(math.ZeroUint()), "invalid liquidity cap", coin.LiquidityCap.String()) // can set liquidity cap to nil _, err = msgServer.UpdateZRC20LiquidityCap(ctx, types.NewMsgUpdateZRC20LiquidityCap( @@ -68,11 +68,11 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.Uint{}, )) - require.NoError(t, err) + assert.NoError(t, err) coin, found = k.GetForeignCoins(ctx, coinAddress) - require.True(t, found) - require.True(t, coin.LiquidityCap.Equal(math.ZeroUint()), "invalid liquidity cap", coin.LiquidityCap.String()) + assert.True(t, found) + assert.True(t, coin.LiquidityCap.Equal(math.ZeroUint()), "invalid liquidity cap", coin.LiquidityCap.String()) }) t.Run("should fail if not admin", func(t *testing.T) { @@ -92,8 +92,8 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.NewUint(42), )) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if zrc20 does not exist", func(t *testing.T) { @@ -109,7 +109,7 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) { coinAddress, math.NewUint(42), )) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) } diff --git a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go index cb8e894eb0..f133236476 100644 --- a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go +++ b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/evmos/ethermint/x/evm/statedb" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" zetacommon "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -35,7 +35,7 @@ func codeHashFromAddress(t *testing.T, ctx sdk.Context, k *keeper.Keeper, contra res, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ Address: contractAddr, }) - require.NoError(t, err) + assert.NoError(t, err) return res.CodeHash } @@ -51,10 +51,10 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // sample chainIDs and addresses chainList := zetacommon.DefaultChainsList() - require.True(t, len(chainList) > 1) - require.NotNil(t, chainList[0]) - require.NotNil(t, chainList[1]) - require.NotEqual(t, chainList[0].ChainId, chainList[1].ChainId) + assert.True(t, len(chainList) > 1) + assert.NotNil(t, chainList[0]) + assert.NotNil(t, chainList[1]) + assert.NotEqual(t, chainList[0].ChainId, chainList[1].ChainId) chainID1 := chainList[0].ChainId chainID2 := chainList[1].ChainId @@ -67,28 +67,28 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // do some operation to populate the state _, err := k.DepositZRC20(ctx, zrc20, addr1, big.NewInt(100)) - require.NoError(t, err) + assert.NoError(t, err) _, err = k.DepositZRC20(ctx, zrc20, addr2, big.NewInt(200)) - require.NoError(t, err) + assert.NoError(t, err) // check the state checkState := func() { // state that should not change balance, err := k.BalanceOfZRC4(ctx, zrc20, addr1) - require.NoError(t, err) - require.Equal(t, int64(100), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(100), balance.Int64()) balance, err = k.BalanceOfZRC4(ctx, zrc20, addr2) - require.NoError(t, err) - require.Equal(t, int64(200), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(200), balance.Int64()) totalSupply, err := k.TotalSupplyZRC4(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, int64(10000300), totalSupply.Int64()) // 10000000 minted on deploy + assert.NoError(t, err) + assert.Equal(t, int64(10000300), totalSupply.Int64()) // 10000000 minted on deploy } checkState() chainID, err := k.QueryChainIDFromContract(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, chainID1, chainID.Int64()) + assert.NoError(t, err) + assert.Equal(t, chainID1, chainID.Int64()) // deploy new zrc20 newCodeAddress, err := k.DeployZRC20Contract( @@ -101,7 +101,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { "beta", big.NewInt(90_000), ) - require.NoError(t, err) + assert.NoError(t, err) codeHash := codeHashFromAddress(t, ctx, k, newCodeAddress.Hex()) // update the bytecode @@ -110,29 +110,29 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { zrc20.Hex(), codeHash, )) - require.NoError(t, err) + assert.NoError(t, err) // check the returned new bytecode hash matches the one in the account acct := sdkk.EvmKeeper.GetAccount(ctx, zrc20) - require.Equal(t, acct.CodeHash, ethcommon.HexToHash(codeHash).Bytes()) + assert.Equal(t, acct.CodeHash, ethcommon.HexToHash(codeHash).Bytes()) // check the state // balances and total supply should remain // BYTECODE value is immutable and therefore part of the code, this value should change checkState() chainID, err = k.QueryChainIDFromContract(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, chainID2, chainID.Int64()) + assert.NoError(t, err) + assert.Equal(t, chainID2, chainID.Int64()) // can continue to interact with the contract _, err = k.DepositZRC20(ctx, zrc20, addr1, big.NewInt(1000)) - require.NoError(t, err) + assert.NoError(t, err) balance, err := k.BalanceOfZRC4(ctx, zrc20, addr1) - require.NoError(t, err) - require.Equal(t, int64(1100), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(1100), balance.Int64()) totalSupply, err := k.TotalSupplyZRC4(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, int64(10001300), totalSupply.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(10001300), totalSupply.Int64()) // can change again bytecode newCodeAddress, err = k.DeployZRC20Contract( @@ -146,22 +146,22 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { big.NewInt(90_000), ) codeHash = codeHashFromAddress(t, ctx, k, newCodeAddress.Hex()) - require.NoError(t, err) + assert.NoError(t, err) _, err = msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, zrc20.Hex(), codeHash, )) - require.NoError(t, err) + assert.NoError(t, err) balance, err = k.BalanceOfZRC4(ctx, zrc20, addr1) - require.NoError(t, err) - require.Equal(t, int64(1100), balance.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(1100), balance.Int64()) totalSupply, err = k.TotalSupplyZRC4(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, int64(10001300), totalSupply.Int64()) + assert.NoError(t, err) + assert.Equal(t, int64(10001300), totalSupply.Int64()) chainID, err = k.QueryChainIDFromContract(ctx, zrc20) - require.NoError(t, err) - require.Equal(t, chainID1, chainID.Int64()) + assert.NoError(t, err) + assert.Equal(t, chainID1, chainID.Int64()) }) t.Run("can update the bytecode of the wzeta connector contract", func(t *testing.T) { @@ -177,8 +177,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // deploy a new connector that will become official connector newConnector, err := k.DeployConnectorZEVM(ctx, wzeta) - require.NoError(t, err) - require.NotEmpty(t, newConnector) + assert.NoError(t, err) + assert.NotEmpty(t, newConnector) assertContractDeployment(t, sdkk.EvmKeeper, ctx, newConnector) // can update the bytecode of the new connector with the old connector contract @@ -187,7 +187,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { newConnector.Hex(), codeHash, )) - require.NoError(t, err) + assert.NoError(t, err) }) t.Run("should fail if unauthorized", func(t *testing.T) { @@ -199,7 +199,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { sample.EthAddress().Hex(), sample.Hash().Hex(), )) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail invalid contract address", func(t *testing.T) { @@ -214,7 +214,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { ContractAddress: "invalid", NewCodeHash: sample.Hash().Hex(), }) - require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) t.Run("should fail if can't get contract account", func(t *testing.T) { @@ -238,7 +238,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { contractAddr.Hex(), sample.Hash().Hex(), )) - require.ErrorIs(t, err, types.ErrContractNotFound) + assert.ErrorIs(t, err, types.ErrContractNotFound) mockEVMKeeper.AssertExpectations(t) }) @@ -258,7 +258,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { wzeta.Hex(), sample.Hash().Hex(), )) - require.ErrorIs(t, err, types.ErrInvalidContract) + assert.ErrorIs(t, err, types.ErrInvalidContract) }) t.Run("should fail if system contract not found", func(t *testing.T) { @@ -279,7 +279,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { connector.Hex(), sample.Hash().Hex(), )) - require.ErrorIs(t, err, types.ErrSystemContractNotFound) + assert.ErrorIs(t, err, types.ErrSystemContractNotFound) }) t.Run("should fail if can't set account with new bytecode", func(t *testing.T) { @@ -316,7 +316,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { contractAddr.Hex(), newCodeHash, )) - require.ErrorIs(t, err, types.ErrSetBytecode) + assert.ErrorIs(t, err, types.ErrSetBytecode) mockEVMKeeper.AssertExpectations(t) }) diff --git a/x/fungible/keeper/msg_server_update_system_contract_test.go b/x/fungible/keeper/msg_server_update_system_contract_test.go index b464da209c..028d0ed215 100644 --- a/x/fungible/keeper/msg_server_update_system_contract_test.go +++ b/x/fungible/keeper/msg_server_update_system_contract_test.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" zetacommon "github.com/zeta-chain/zetacore/common" @@ -27,20 +27,20 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { queryZRC20SystemContract := func(contract common.Address) string { abi, err := zrc20.ZRC20MetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, contract, keeper.BigIntZero, nil, false, false, "SYSTEM_CONTRACT_ADDRESS") - require.NoError(t, err) + assert.NoError(t, err) unpacked, err := abi.Unpack("SYSTEM_CONTRACT_ADDRESS", res.Ret) - require.NoError(t, err) + assert.NoError(t, err) address, ok := unpacked[0].(common.Address) - require.True(t, ok) + assert.True(t, ok) return address.Hex() } chains := zetacommon.DefaultChainsList() - require.True(t, len(chains) > 1) - require.NotNil(t, chains[0]) - require.NotNil(t, chains[1]) + assert.True(t, len(chains) > 1) + assert.NotNil(t, chains[0]) + assert.NotNil(t, chains[1]) chainID1 := chains[0].ChainId chainID2 := chains[1].ChainId @@ -50,28 +50,28 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { // deploy a new system contracts newSystemContract, err := k.DeployContract(ctx, systemcontract.SystemContractMetaData, wzeta, factory, router) - require.NoError(t, err) - require.NotEqual(t, oldSystemContract, newSystemContract) + assert.NoError(t, err) + assert.NotEqual(t, oldSystemContract, newSystemContract) // can update the system contract _, err = msgServer.UpdateSystemContract(ctx, types.NewMsgUpdateSystemContract(admin, newSystemContract.Hex())) - require.NoError(t, err) + assert.NoError(t, err) // can retrieve the system contract sc, found := k.GetSystemContract(ctx) - require.True(t, found) - require.Equal(t, newSystemContract.Hex(), sc.SystemContract) + assert.True(t, found) + assert.Equal(t, newSystemContract.Hex(), sc.SystemContract) // check gas updated foundGas1, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID1)) - require.NoError(t, err) - require.Equal(t, gas1, foundGas1) + assert.NoError(t, err) + assert.Equal(t, gas1, foundGas1) foundGas2, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID2)) - require.NoError(t, err) - require.Equal(t, gas2, foundGas2) + assert.NoError(t, err) + assert.Equal(t, gas2, foundGas2) - require.Equal(t, newSystemContract.Hex(), queryZRC20SystemContract(gas1)) - require.Equal(t, newSystemContract.Hex(), queryZRC20SystemContract(gas2)) + assert.Equal(t, newSystemContract.Hex(), queryZRC20SystemContract(gas1)) + assert.Equal(t, newSystemContract.Hex(), queryZRC20SystemContract(gas2)) }) t.Run("should not update the system contract if not admin", func(t *testing.T) { @@ -82,13 +82,13 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { // deploy a new system contracts wzeta, factory, router, _, oldSystemContract := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) newSystemContract, err := k.DeployContract(ctx, systemcontract.SystemContractMetaData, wzeta, factory, router) - require.NoError(t, err) - require.NotEqual(t, oldSystemContract, newSystemContract) + assert.NoError(t, err) + assert.NotEqual(t, oldSystemContract, newSystemContract) // should not update the system contract if not admin _, err = msgServer.UpdateSystemContract(ctx, types.NewMsgUpdateSystemContract(sample.AccAddress(), newSystemContract.Hex())) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should not update the system contract if invalid address", func(t *testing.T) { @@ -101,12 +101,12 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { // deploy a new system contracts wzeta, factory, router, _, oldSystemContract := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) newSystemContract, err := k.DeployContract(ctx, systemcontract.SystemContractMetaData, wzeta, factory, router) - require.NoError(t, err) - require.NotEqual(t, oldSystemContract, newSystemContract) + assert.NoError(t, err) + assert.NotEqual(t, oldSystemContract, newSystemContract) // should not update the system contract if invalid address _, err = msgServer.UpdateSystemContract(ctx, types.NewMsgUpdateSystemContract(admin, "invalid")) - require.Error(t, err) - require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + assert.Error(t, err) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) } diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go b/x/fungible/keeper/msg_server_update_zrc20_paused_status.go index fcbb37bfaa..3fe9380f2f 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go +++ b/x/fungible/keeper/msg_server_update_zrc20_paused_status.go @@ -27,12 +27,12 @@ func (k msgServer) UpdateZRC20PausedStatus( } // check if the sender is the admin - // unpausing requires group2 admin - requirePolicyAccount := zetaObserverTypes.Policy_Type_group1 + // unpausing asserts group2 admin + assertPolicyAccount := zetaObserverTypes.Policy_Type_group1 if msg.Action == types.UpdatePausedStatusAction_UNPAUSE { - requirePolicyAccount = zetaObserverTypes.Policy_Type_group2 + assertPolicyAccount = zetaObserverTypes.Policy_Type_group2 } - if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(requirePolicyAccount) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(assertPolicyAccount) { return nil, cosmoserrors.Wrap(sdkerrors.ErrUnauthorized, "Update can only be executed by the correct policy account") } diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go b/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go index 2183cccf9c..bd6b69874e 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go +++ b/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/keeper" @@ -18,15 +18,15 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() - requireUnpaused := func(zrc20 string) { + assertUnpaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) - require.True(t, found) - require.False(t, fc.Paused) + assert.True(t, found) + assert.False(t, fc.Paused) } - requirePaused := func(zrc20 string) { + assertPaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) - require.True(t, found) - require.True(t, fc.Paused) + assert.True(t, found) + assert.True(t, fc.Paused) } // setup zrc20 @@ -34,9 +34,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20A)) k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20B)) k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20C)) - requireUnpaused(zrc20A) - requireUnpaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertUnpaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -49,10 +49,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_PAUSE, )) - require.NoError(t, err) - requirePaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assert.NoError(t, err) + assertPaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -64,10 +64,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_UNPAUSE, )) - require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assert.NoError(t, err) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -79,10 +79,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_PAUSE, )) - require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assert.NoError(t, err) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -94,10 +94,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_UNPAUSE, )) - require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assert.NoError(t, err) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -111,10 +111,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_PAUSE, )) - require.NoError(t, err) - requirePaused(zrc20A) - requirePaused(zrc20B) - requirePaused(zrc20C) + assert.NoError(t, err) + assertPaused(zrc20A) + assertPaused(zrc20B) + assertPaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -128,10 +128,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_UNPAUSE, )) - require.NoError(t, err) - requireUnpaused(zrc20A) - requireUnpaused(zrc20B) - requireUnpaused(zrc20C) + assert.NoError(t, err) + assertUnpaused(zrc20A) + assertUnpaused(zrc20B) + assertUnpaused(zrc20C) }) t.Run("should fail if invalid message", func(t *testing.T) { @@ -141,10 +141,10 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) invalidMsg := types.NewMsgUpdateZRC20PausedStatus(admin, []string{}, types.UpdatePausedStatusAction_PAUSE) - require.ErrorIs(t, invalidMsg.ValidateBasic(), sdkerrors.ErrInvalidRequest) + assert.ErrorIs(t, invalidMsg.ValidateBasic(), sdkerrors.ErrInvalidRequest) _, err := msgServer.UpdateZRC20PausedStatus(ctx, invalidMsg) - require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) }) t.Run("should fail if not authorized", func(t *testing.T) { @@ -166,7 +166,7 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_UNPAUSE, )) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if zrc20 does not exist", func(t *testing.T) { @@ -188,6 +188,6 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { }, types.UpdatePausedStatusAction_PAUSE, )) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) } diff --git a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go index 108c70c664..288f158c31 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go +++ b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go @@ -9,8 +9,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -36,8 +36,8 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { // initial protocol fee is zero protocolFee, err := k.QueryProtocolFlatFee(ctx, zrc20Addr) - require.NoError(t, err) - require.Zero(t, protocolFee.Uint64()) + assert.NoError(t, err) + assert.Zero(t, protocolFee.Uint64()) // can update the protocol fee and gas limit _, err = msgServer.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( @@ -46,15 +46,15 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.NewUint(42), )) - require.NoError(t, err) + assert.NoError(t, err) // can query the updated fee protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(42), protocolFee.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(42), protocolFee.Uint64()) gasLimit, err := k.QueryGasLimit(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(42), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(42), gasLimit.Uint64()) // can update protocol fee only _, err = msgServer.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( @@ -63,13 +63,13 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(43), math.Uint{}, )) - require.NoError(t, err) + assert.NoError(t, err) protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(43), protocolFee.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(43), protocolFee.Uint64()) gasLimit, err = k.QueryGasLimit(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(42), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(42), gasLimit.Uint64()) // can update gas limit only _, err = msgServer.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( @@ -78,13 +78,13 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.Uint{}, math.NewUint(44), )) - require.NoError(t, err) + assert.NoError(t, err) protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(43), protocolFee.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(43), protocolFee.Uint64()) gasLimit, err = k.QueryGasLimit(ctx, zrc20Addr) - require.NoError(t, err) - require.Equal(t, uint64(44), gasLimit.Uint64()) + assert.NoError(t, err) + assert.Equal(t, uint64(44), gasLimit.Uint64()) }) t.Run("should fail if not authorized", func(t *testing.T) { @@ -97,7 +97,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.Uint{}, )) - require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + assert.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) t.Run("should fail if invalid zrc20 address", func(t *testing.T) { @@ -112,7 +112,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.Uint{}, )) - require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + assert.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) t.Run("should fail if can't retrieve the foreign coin", func(t *testing.T) { @@ -127,7 +127,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.Uint{}, )) - require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + assert.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) t.Run("should fail if can't query old fee", func(t *testing.T) { @@ -148,7 +148,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.Uint{}, )) - require.ErrorIs(t, err, types.ErrContractCall) + assert.ErrorIs(t, err, types.ErrContractCall) }) t.Run("should fail if contract call for setting new protocol fee fails", func(t *testing.T) { @@ -173,9 +173,9 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { // this is the query (commit == false) zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) protocolFlatFee, err := zrc20ABI.Methods["PROTOCOL_FLAT_FEE"].Outputs.Pack(big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) mockEVMKeeper.On( "ApplyMessage", mock.Anything, @@ -185,7 +185,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { ).Return(&evmtypes.MsgEthereumTxResponse{Ret: protocolFlatFee}, nil) gasLimit, err := zrc20ABI.Methods["GAS_LIMIT"].Outputs.Pack(big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) mockEVMKeeper.On( "ApplyMessage", mock.Anything, @@ -209,7 +209,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.NewUint(42), math.Uint{}, )) - require.ErrorIs(t, err, types.ErrContractCall) + assert.ErrorIs(t, err, types.ErrContractCall) mockEVMKeeper.AssertExpectations(t) }) @@ -236,9 +236,9 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { // this is the query (commit == false) zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() - require.NoError(t, err) + assert.NoError(t, err) protocolFlatFee, err := zrc20ABI.Methods["PROTOCOL_FLAT_FEE"].Outputs.Pack(big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) mockEVMKeeper.On( "ApplyMessage", mock.Anything, @@ -248,7 +248,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { ).Return(&evmtypes.MsgEthereumTxResponse{Ret: protocolFlatFee}, nil) gasLimit, err := zrc20ABI.Methods["GAS_LIMIT"].Outputs.Pack(big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) mockEVMKeeper.On( "ApplyMessage", mock.Anything, @@ -272,7 +272,7 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { math.Uint{}, math.NewUint(42), )) - require.ErrorIs(t, err, types.ErrContractCall) + assert.ErrorIs(t, err, types.ErrContractCall) mockEVMKeeper.AssertExpectations(t) }) diff --git a/x/fungible/keeper/params_test.go b/x/fungible/keeper/params_test.go index b3b9497a74..377e13b4ce 100644 --- a/x/fungible/keeper/params_test.go +++ b/x/fungible/keeper/params_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -14,5 +14,5 @@ func TestGetParams(t *testing.T) { k.SetParams(ctx, params) - require.EqualValues(t, params, k.GetParams(ctx)) + assert.EqualValues(t, params, k.GetParams(ctx)) } diff --git a/x/fungible/keeper/system_contract_test.go b/x/fungible/keeper/system_contract_test.go index 3874f52435..3148b8c44c 100644 --- a/x/fungible/keeper/system_contract_test.go +++ b/x/fungible/keeper/system_contract_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -15,13 +15,13 @@ func TestKeeper_GetSystemContract(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeper(t) k.SetSystemContract(ctx, types.SystemContract{SystemContract: "test"}) val, found := k.GetSystemContract(ctx) - require.True(t, found) - require.Equal(t, types.SystemContract{SystemContract: "test"}, val) + assert.True(t, found) + assert.Equal(t, types.SystemContract{SystemContract: "test"}, val) // can remove contract k.RemoveSystemContract(ctx) _, found = k.GetSystemContract(ctx) - require.False(t, found) + assert.False(t, found) } func TestKeeper_GetSystemContractAddress(t *testing.T) { @@ -29,13 +29,13 @@ func TestKeeper_GetSystemContractAddress(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) _, err := k.GetSystemContractAddress(ctx) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrStateVariableNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrStateVariableNotFound) _, _, _, _, systemContract := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) found, err := k.GetSystemContractAddress(ctx) - require.NoError(t, err) - require.Equal(t, systemContract, found) + assert.NoError(t, err) + assert.Equal(t, systemContract, found) } func TestKeeper_GetWZetaContractAddress(t *testing.T) { @@ -43,13 +43,13 @@ func TestKeeper_GetWZetaContractAddress(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) _, err := k.GetWZetaContractAddress(ctx) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrStateVariableNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrStateVariableNotFound) wzeta, _, _, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) found, err := k.GetWZetaContractAddress(ctx) - require.NoError(t, err) - require.Equal(t, wzeta, found) + assert.NoError(t, err) + assert.Equal(t, wzeta, found) } func TestKeeper_GetUniswapV2FactoryAddress(t *testing.T) { @@ -57,13 +57,13 @@ func TestKeeper_GetUniswapV2FactoryAddress(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) _, err := k.GetUniswapV2FactoryAddress(ctx) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrStateVariableNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrStateVariableNotFound) _, factory, _, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) found, err := k.GetUniswapV2FactoryAddress(ctx) - require.NoError(t, err) - require.Equal(t, factory, found) + assert.NoError(t, err) + assert.Equal(t, factory, found) } func TestKeeper_GetUniswapV2Router02Address(t *testing.T) { @@ -71,13 +71,13 @@ func TestKeeper_GetUniswapV2Router02Address(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) _, err := k.GetUniswapV2Router02Address(ctx) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrStateVariableNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrStateVariableNotFound) _, _, router, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) found, err := k.GetUniswapV2Router02Address(ctx) - require.NoError(t, err) - require.Equal(t, router, found) + assert.NoError(t, err) + assert.Equal(t, router, found) } func TestKeeper_CallWZetaDeposit(t *testing.T) { @@ -89,23 +89,23 @@ func TestKeeper_CallWZetaDeposit(t *testing.T) { ethAddr := common.BytesToAddress(addr.Bytes()) coins := sample.Coins() err := sdkk.BankKeeper.MintCoins(ctx, types.ModuleName, sample.Coins()) - require.NoError(t, err) + assert.NoError(t, err) err = sdkk.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, coins) - require.NoError(t, err) + assert.NoError(t, err) // fail if no system contract err = k.CallWZetaDeposit(ctx, ethAddr, big.NewInt(42)) - require.Error(t, err) + assert.Error(t, err) deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) // deposit err = k.CallWZetaDeposit(ctx, ethAddr, big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) balance, err := k.QueryWZetaBalanceOf(ctx, ethAddr) - require.NoError(t, err) - require.Equal(t, big.NewInt(42), balance) + assert.NoError(t, err) + assert.Equal(t, big.NewInt(42), balance) } func TestKeeper_QuerySystemContractGasCoinZRC20(t *testing.T) { @@ -114,13 +114,13 @@ func TestKeeper_QuerySystemContractGasCoinZRC20(t *testing.T) { chainID := getValidChainID(t) _, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) - require.Error(t, err) - require.ErrorIs(t, err, types.ErrStateVariableNotFound) + assert.Error(t, err) + assert.ErrorIs(t, err, types.ErrStateVariableNotFound) deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chainID, "foobar", "foobar") found, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) - require.NoError(t, err) - require.Equal(t, zrc20, found) + assert.NoError(t, err) + assert.Equal(t, zrc20, found) } diff --git a/x/fungible/keeper/zeta_test.go b/x/fungible/keeper/zeta_test.go index cec34d06ea..4eea6b70ad 100644 --- a/x/fungible/keeper/zeta_test.go +++ b/x/fungible/keeper/zeta_test.go @@ -6,7 +6,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/cmd/zetacored/config" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -20,12 +20,12 @@ func TestKeeper_MintZetaToEVMAccount(t *testing.T) { acc := sample.Bech32AccAddress() bal := sdkk.BankKeeper.GetBalance(ctx, acc, config.BaseDenom) - require.True(t, bal.IsZero()) + assert.True(t, bal.IsZero()) err := k.MintZetaToEVMAccount(ctx, acc, big.NewInt(42)) - require.NoError(t, err) + assert.NoError(t, err) bal = sdkk.BankKeeper.GetBalance(ctx, acc, config.BaseDenom) - require.True(t, bal.Amount.Equal(sdk.NewInt(42))) + assert.True(t, bal.Amount.Equal(sdk.NewInt(42))) }) coins42 := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdk.NewInt(42))) @@ -43,7 +43,7 @@ func TestKeeper_MintZetaToEVMAccount(t *testing.T) { ).Return(errors.New("error")) err := k.MintZetaToEVMAccount(ctx, sample.Bech32AccAddress(), big.NewInt(42)) - require.Error(t, err) + assert.Error(t, err) mockBankKeeper.AssertExpectations(t) }) @@ -70,7 +70,7 @@ func TestKeeper_MintZetaToEVMAccount(t *testing.T) { ).Return(errors.New("error")) err := k.MintZetaToEVMAccount(ctx, acc, big.NewInt(42)) - require.Error(t, err) + assert.Error(t, err) mockBankKeeper.AssertExpectations(t) }) diff --git a/x/fungible/types/evm_test.go b/x/fungible/types/evm_test.go index 0be4d916da..4e81bb3562 100644 --- a/x/fungible/types/evm_test.go +++ b/x/fungible/types/evm_test.go @@ -7,16 +7,16 @@ import ( "github.com/ethereum/go-ethereum/core/vm" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/fungible/types" ) func TestIsContractReverted(t *testing.T) { - require.True(t, types.IsContractReverted(nil, vm.ErrExecutionReverted)) - require.True(t, types.IsContractReverted(nil, fmt.Errorf("foo : %s", vm.ErrExecutionReverted.Error()))) - require.True(t, types.IsContractReverted(&evmtypes.MsgEthereumTxResponse{VmError: "foo"}, nil)) + assert.True(t, types.IsContractReverted(nil, vm.ErrExecutionReverted)) + assert.True(t, types.IsContractReverted(nil, fmt.Errorf("foo : %s", vm.ErrExecutionReverted.Error()))) + assert.True(t, types.IsContractReverted(&evmtypes.MsgEthereumTxResponse{VmError: "foo"}, nil)) - require.False(t, types.IsContractReverted(nil, nil)) - require.False(t, types.IsContractReverted(nil, errors.New("foo"))) - require.False(t, types.IsContractReverted(&evmtypes.MsgEthereumTxResponse{VmError: ""}, nil)) + assert.False(t, types.IsContractReverted(nil, nil)) + assert.False(t, types.IsContractReverted(nil, errors.New("foo"))) + assert.False(t, types.IsContractReverted(&evmtypes.MsgEthereumTxResponse{VmError: ""}, nil)) } diff --git a/x/fungible/types/gas_stablity_pool_test.go b/x/fungible/types/gas_stablity_pool_test.go index c0ec0000f5..dfeac5b484 100644 --- a/x/fungible/types/gas_stablity_pool_test.go +++ b/x/fungible/types/gas_stablity_pool_test.go @@ -3,16 +3,16 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/fungible/types" ) func TestGetGasStabilityPoolAddress(t *testing.T) { address := types.GasStabilityPoolAddress() - require.False(t, address.Empty()) + assert.False(t, address.Empty()) } func TestGetGasStabilityPoolAddressEVM(t *testing.T) { address := types.GasStabilityPoolAddressEVM() - require.NotEmpty(t, address) + assert.NotEmpty(t, address) } diff --git a/x/fungible/types/genesis_test.go b/x/fungible/types/genesis_test.go index 57927528af..a5a16ba6f7 100644 --- a/x/fungible/types/genesis_test.go +++ b/x/fungible/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -51,9 +51,9 @@ func TestGenesisState_Validate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { - require.NoError(t, err) + assert.NoError(t, err) } else { - require.Error(t, err) + assert.Error(t, err) } }) } diff --git a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go index e107af7781..9addfd0eb5 100644 --- a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -49,10 +49,10 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/fungible/types/message_deploy_system_contracts_test.go b/x/fungible/types/message_deploy_system_contracts_test.go index b14aa419ed..ff4b7111fd 100644 --- a/x/fungible/types/message_deploy_system_contracts_test.go +++ b/x/fungible/types/message_deploy_system_contracts_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -33,10 +33,10 @@ func TestMsgDeploySystemContract_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/fungible/types/message_remove_foreign_coin_test.go b/x/fungible/types/message_remove_foreign_coin_test.go index 66a4c143f3..b5949c722f 100644 --- a/x/fungible/types/message_remove_foreign_coin_test.go +++ b/x/fungible/types/message_remove_foreign_coin_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -33,10 +33,10 @@ func TestMsgRemoveForeignCoin_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/fungible/types/message_update_contract_bytecode_test.go b/x/fungible/types/message_update_contract_bytecode_test.go index 02e8b3cfdd..9e7d0970cd 100644 --- a/x/fungible/types/message_update_contract_bytecode_test.go +++ b/x/fungible/types/message_update_contract_bytecode_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -56,9 +56,9 @@ func TestMsgUpdateContractBytecode_ValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.wantError { - require.Error(t, err) + assert.Error(t, err) } else { - require.NoError(t, err) + assert.NoError(t, err) } }) } diff --git a/x/fungible/types/message_update_system_contract_test.go b/x/fungible/types/message_update_system_contract_test.go index 8ee196ad39..00ce59b4ab 100644 --- a/x/fungible/types/message_update_system_contract_test.go +++ b/x/fungible/types/message_update_system_contract_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -43,10 +43,10 @@ func TestMsgUpdateSystemContract_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/fungible/types/message_update_zrc20_liquidity_cap_test.go b/x/fungible/types/message_update_zrc20_liquidity_cap_test.go index d59198ce39..f62193d63e 100644 --- a/x/fungible/types/message_update_zrc20_liquidity_cap_test.go +++ b/x/fungible/types/message_update_zrc20_liquidity_cap_test.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -61,10 +61,10 @@ func TestNewMsgUpdateZRC20LiquidityCap_ValidateBasics(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/fungible/types/message_update_zrc20_paused_status_test.go b/x/fungible/types/message_update_zrc20_paused_status_test.go index 326af3fe96..40ddf7c3ae 100644 --- a/x/fungible/types/message_update_zrc20_paused_status_test.go +++ b/x/fungible/types/message_update_zrc20_paused_status_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -94,9 +94,9 @@ func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.wantErr { - require.Error(t, err) + assert.Error(t, err) } else { - require.NoError(t, err) + assert.NoError(t, err) } }) } diff --git a/x/fungible/types/message_update_zrc20_withdraw_fee_test.go b/x/fungible/types/message_update_zrc20_withdraw_fee_test.go index 2aba73d42a..232dae1a46 100644 --- a/x/fungible/types/message_update_zrc20_withdraw_fee_test.go +++ b/x/fungible/types/message_update_zrc20_withdraw_fee_test.go @@ -6,7 +6,7 @@ import ( math "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -93,10 +93,10 @@ func TestMsgUpdateZRC20WithdrawFee_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/observer/genesis_test.go b/x/observer/genesis_test.go index 56cc00352f..853dc10996 100644 --- a/x/observer/genesis_test.go +++ b/x/observer/genesis_test.go @@ -3,7 +3,7 @@ package observer_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/testutil/sample" @@ -47,10 +47,10 @@ func TestGenesis(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) observer.InitGenesis(ctx, *k, genesisState) got := observer.ExportGenesis(ctx, *k) - require.NotNil(t, got) + assert.NotNil(t, got) // Compare genesis after init and export nullify.Fill(&genesisState) nullify.Fill(got) - require.Equal(t, genesisState, *got) + assert.Equal(t, genesisState, *got) } diff --git a/x/observer/keeper/chain_nonces_test.go b/x/observer/keeper/chain_nonces_test.go index 0c511d3f79..44118ecc5b 100644 --- a/x/observer/keeper/chain_nonces_test.go +++ b/x/observer/keeper/chain_nonces_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -17,8 +17,8 @@ func TestKeeper_GetChainNonces(t *testing.T) { } for _, n := range chainNoncesList { rst, found := k.GetChainNonces(ctx, n.Index) - require.True(t, found) - require.Equal(t, n, rst) + assert.True(t, found) + assert.Equal(t, n, rst) } }) t.Run("Get chain nonces not found", func(t *testing.T) { @@ -28,7 +28,7 @@ func TestKeeper_GetChainNonces(t *testing.T) { k.SetChainNonces(ctx, n) } _, found := k.GetChainNonces(ctx, "not_found") - require.False(t, found) + assert.False(t, found) }) t.Run("Get all chain nonces", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -37,6 +37,6 @@ func TestKeeper_GetChainNonces(t *testing.T) { k.SetChainNonces(ctx, n) } rst := k.GetAllChainNonces(ctx) - require.Equal(t, chainNoncesList, rst) + assert.Equal(t, chainNoncesList, rst) }) } diff --git a/x/observer/keeper/chain_params_test.go b/x/observer/keeper/chain_params_test.go index c9142b7526..f5283c7feb 100644 --- a/x/observer/keeper/chain_params_test.go +++ b/x/observer/keeper/chain_params_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -15,11 +15,11 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) // no core params list - require.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 0))) + assert.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 0))) // core params list but chain not in list setSupportedChain(ctx, *k, getValidEthChainIDWithIndex(t, 0)) - require.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 1))) + assert.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 1))) // chain params list but chain not supported chainParams := sample.ChainParams(getValidEthChainIDWithIndex(t, 0)) @@ -27,7 +27,7 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{chainParams}, }) - require.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 0))) + assert.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 0))) }) t.Run("return chain if chain found", func(t *testing.T) { @@ -35,21 +35,21 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { chainID := getValidEthChainIDWithIndex(t, 0) setSupportedChain(ctx, *k, getValidEthChainIDWithIndex(t, 1), chainID) chain := k.GetSupportedChainFromChainID(ctx, chainID) - require.NotNil(t, chain) - require.EqualValues(t, chainID, chain.ChainId) + assert.NotNil(t, chain) + assert.EqualValues(t, chainID, chain.ChainId) }) } func TestKeeper_GetSupportedChains(t *testing.T) { t.Run("return empty list if no core params list", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) - require.Empty(t, k.GetSupportedChains(ctx)) + assert.Empty(t, k.GetSupportedChains(ctx)) }) t.Run("return list containing supported chains", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) - require.Greater(t, len(common.ExternalChainList()), 5) + assert.Greater(t, len(common.ExternalChainList()), 5) supported1 := common.ExternalChainList()[0] supported2 := common.ExternalChainList()[1] unsupported := common.ExternalChainList()[2] @@ -69,10 +69,10 @@ func TestKeeper_GetSupportedChains(t *testing.T) { supportedChains := k.GetSupportedChains(ctx) - require.Len(t, supportedChains, 4) - require.EqualValues(t, supported1.ChainId, supportedChains[0].ChainId) - require.EqualValues(t, supported2.ChainId, supportedChains[1].ChainId) - require.EqualValues(t, supported3.ChainId, supportedChains[2].ChainId) - require.EqualValues(t, supported4.ChainId, supportedChains[3].ChainId) + assert.Len(t, supportedChains, 4) + assert.EqualValues(t, supported1.ChainId, supportedChains[0].ChainId) + assert.EqualValues(t, supported2.ChainId, supportedChains[1].ChainId) + assert.EqualValues(t, supported3.ChainId, supportedChains[2].ChainId) + assert.EqualValues(t, supported4.ChainId, supportedChains[3].ChainId) }) } diff --git a/x/observer/keeper/grpc_query_blame_test.go b/x/observer/keeper/grpc_query_blame_test.go index 8e66e3a2da..038a855305 100644 --- a/x/observer/keeper/grpc_query_blame_test.go +++ b/x/observer/keeper/grpc_query_blame_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -26,8 +26,8 @@ func TestKeeper_BlameByIdentifier(t *testing.T) { }) blameRecords, found := k.GetBlame(ctx, index) - require.True(t, found) - require.Equal(t, index, blameRecords.Index) + assert.True(t, found) + assert.Equal(t, index, blameRecords.Index) } func TestKeeper_BlameByChainAndNonce(t *testing.T) { @@ -45,9 +45,9 @@ func TestKeeper_BlameByChainAndNonce(t *testing.T) { }) blameRecords, found := k.GetBlamesByChainAndNonce(ctx, chainId, int64(nonce)) - require.True(t, found) - require.Equal(t, 1, len(blameRecords)) - require.Equal(t, index, blameRecords[0].Index) + assert.True(t, found) + assert.Equal(t, 1, len(blameRecords)) + assert.Equal(t, index, blameRecords[0].Index) } func TestKeeper_BlameAll(t *testing.T) { @@ -61,12 +61,12 @@ func TestKeeper_BlameAll(t *testing.T) { return blameList[i].Index < blameList[j].Index }) rst, pageRes, err := k.GetAllBlamePaginated(ctx, &query.PageRequest{Limit: 10, CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.Slice(rst, func(i, j int) bool { return rst[i].Index < rst[j].Index }) - require.Equal(t, blameList, rst) - require.Equal(t, len(blameList), int(pageRes.Total)) + assert.Equal(t, blameList, rst) + assert.Equal(t, len(blameList), int(pageRes.Total)) }) t.Run("GetBlameRecord by offset ", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -79,13 +79,13 @@ func TestKeeper_BlameAll(t *testing.T) { return blameList[i].Index < blameList[j].Index }) rst, pageRes, err := k.GetAllBlamePaginated(ctx, &query.PageRequest{Offset: uint64(offset), CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.Slice(rst, func(i, j int) bool { return rst[i].Index < rst[j].Index }) - require.Subset(t, blameList, rst) - require.Equal(t, len(blameList)-offset, len(rst)) - require.Equal(t, len(blameList), int(pageRes.Total)) + assert.Subset(t, blameList, rst) + assert.Equal(t, len(blameList)-offset, len(rst)) + assert.Equal(t, len(blameList), int(pageRes.Total)) }) t.Run("GetAllBlameRecord", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -100,11 +100,11 @@ func TestKeeper_BlameAll(t *testing.T) { sort.Slice(blameList, func(i, j int) bool { return blameList[i].Index < blameList[j].Index }) - require.Equal(t, blameList, rst) + assert.Equal(t, blameList, rst) }) t.Run("Get no records if nothing is set", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) rst := k.GetAllBlame(ctx) - require.Len(t, rst, 0) + assert.Len(t, rst, 0) }) } diff --git a/x/observer/keeper/grpc_query_keygen_test.go b/x/observer/keeper/grpc_query_keygen_test.go index f4c61aeabd..27c90a0c3a 100644 --- a/x/observer/keeper/grpc_query_keygen_test.go +++ b/x/observer/keeper/grpc_query_keygen_test.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "testing" @@ -29,9 +29,9 @@ func TestKeygenQuery(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.Keygen(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } diff --git a/x/observer/keeper/grpc_query_node_account_test.go b/x/observer/keeper/grpc_query_node_account_test.go index 37585214cf..3b36749b31 100644 --- a/x/observer/keeper/grpc_query_node_account_test.go +++ b/x/observer/keeper/grpc_query_node_account_test.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -46,9 +45,9 @@ func TestNodeAccountQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := keeper.NodeAccount(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -73,7 +72,7 @@ func TestNodeAccountQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { resp, err := keeper.NodeAccountAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.NodeAccount[j-i]) } @@ -84,7 +83,7 @@ func TestNodeAccountQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(msgs); i += step { resp, err := keeper.NodeAccountAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { assert.Equal(t, &msgs[j], resp.NodeAccount[j-i]) } @@ -93,11 +92,11 @@ func TestNodeAccountQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := keeper.NodeAccountAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + assert.NoError(t, err) + assert.Equal(t, len(msgs), int(resp.Pagination.Total)) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := keeper.NodeAccountAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/observer/keeper/grpc_query_nonces_test.go b/x/observer/keeper/grpc_query_nonces_test.go index 584f237e7b..809220e4c7 100644 --- a/x/observer/keeper/grpc_query_nonces_test.go +++ b/x/observer/keeper/grpc_query_nonces_test.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -51,9 +50,9 @@ func TestChainNoncesQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := k.ChainNonces(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -81,7 +80,7 @@ func TestChainNoncesQueryPaginated(t *testing.T) { step := 2 for i := 0; i < len(chainNonces); i += step { resp, err := k.ChainNoncesAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(chainNonces) && j < i+step; j++ { assert.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) } @@ -92,7 +91,7 @@ func TestChainNoncesQueryPaginated(t *testing.T) { var next []byte for i := 0; i < len(chainNonces); i += step { resp, err := k.ChainNoncesAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) + assert.NoError(t, err) for j := i; j < len(chainNonces) && j < i+step; j++ { assert.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) } @@ -101,11 +100,11 @@ func TestChainNoncesQueryPaginated(t *testing.T) { }) t.Run("Total", func(t *testing.T) { resp, err := k.ChainNoncesAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(chainNonces), int(resp.Pagination.Total)) + assert.NoError(t, err) + assert.Equal(t, len(chainNonces), int(resp.Pagination.Total)) }) t.Run("InvalidRequest", func(t *testing.T) { _, err := k.ChainNoncesAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + assert.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/observer/keeper/grpc_query_params_test.go b/x/observer/keeper/grpc_query_params_test.go index 4cd534fa59..3eaf8963f0 100644 --- a/x/observer/keeper/grpc_query_params_test.go +++ b/x/observer/keeper/grpc_query_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -15,6 +15,6 @@ func TestParamsQuery(t *testing.T) { keeper.SetParams(ctx, params) response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) + assert.NoError(t, err) + assert.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/observer/keeper/keeper_test.go b/x/observer/keeper/keeper_test.go index 7c13b7b0f2..41ad55a8d0 100644 --- a/x/observer/keeper/keeper_test.go +++ b/x/observer/keeper/keeper_test.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" "github.com/zeta-chain/zetacore/x/observer/types" @@ -26,7 +26,7 @@ func SetupKeeper(t testing.TB) (*Keeper, sdk.Context) { stateStore := store.NewCommitMultiStore(db) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) + assert.NoError(t, stateStore.LoadLatestVersion()) registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go index 7f475bad4c..3d9f35b446 100644 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ b/x/observer/keeper/msg_server_add_block_header_test.go @@ -7,7 +7,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -37,7 +36,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled bool IsBtcTypeChainEnabled bool validator stakingtypes.Validator - wantErr require.ErrorAssertionFunc + wantErr assert.ErrorAssertionFunc }{ { name: "success submit eth header", @@ -51,7 +50,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: require.NoError, + wantErr: assert.NoError, }, { name: "failure submit eth header eth disabled", @@ -65,8 +64,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - assert.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) + wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { + return assert.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }, }, { @@ -81,8 +80,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { + return assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }, }, { @@ -97,8 +96,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.Error(t, err) + wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { + return assert.Error(t, err) }, }, { @@ -113,7 +112,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: require.NoError, + wantErr: assert.NoError, }, { name: "should succeed to post 3rd header if 2nd header is posted", @@ -127,8 +126,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.Error(t, err) + wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { + return assert.Error(t, err) }, }, { @@ -143,8 +142,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.ErrorIs(t, err, types.ErrSupportedChains) + wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { + return assert.ErrorIs(t, err, types.ErrSupportedChains) }, }, } @@ -172,8 +171,8 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { tc.wantErr(t, err) if err == nil { bhs, found := k.GetBlockHeaderState(ctx, tc.msg.ChainId) - require.True(t, found) - require.Equal(t, tc.msg.Height, bhs.LatestHeight) + assert.True(t, found) + assert.Equal(t, tc.msg.Height, bhs.LatestHeight) } }) } diff --git a/x/observer/keeper/msg_server_remove_chain_params_test.go b/x/observer/keeper/msg_server_remove_chain_params_test.go index d99b301403..15a089ab3f 100644 --- a/x/observer/keeper/msg_server_remove_chain_params_test.go +++ b/x/observer/keeper/msg_server_remove_chain_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -39,39 +39,39 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { Creator: admin, ChainId: chain2, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has two chain params chainParamsList, found := k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 2) - require.Equal(t, chain1, chainParamsList.ChainParams[0].ChainId) - require.Equal(t, chain3, chainParamsList.ChainParams[1].ChainId) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 2) + assert.Equal(t, chain1, chainParamsList.ChainParams[0].ChainId) + assert.Equal(t, chain3, chainParamsList.ChainParams[1].ChainId) // remove chain params _, err = srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, ChainId: chain1, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has one chain params chainParamsList, found = k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 1) - require.Equal(t, chain3, chainParamsList.ChainParams[0].ChainId) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 1) + assert.Equal(t, chain3, chainParamsList.ChainParams[0].ChainId) // remove chain params _, err = srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, ChainId: chain3, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has no chain params chainParamsList, found = k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 0) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 0) }) t.Run("cannot remove chain params if not authorized", func(t *testing.T) { @@ -82,7 +82,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { Creator: sample.AccAddress(), ChainParams: sample.ChainParams(common.ExternalChainList()[0].ChainId), }) - require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) // group 1 should not be able to update core params admin := sample.AccAddress() @@ -92,7 +92,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { Creator: sample.AccAddress(), ChainParams: sample.ChainParams(common.ExternalChainList()[0].ChainId), }) - require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }) @@ -106,13 +106,13 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { // not found if no chain params _, found := k.GetChainParamsList(ctx) - require.False(t, found) + assert.False(t, found) _, err := srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, ChainId: common.ExternalChainList()[0].ChainId, }) - require.ErrorIs(t, err, types.ErrChainParamsNotFound) + assert.ErrorIs(t, err, types.ErrChainParamsNotFound) // add chain params k.SetChainParamsList(ctx, types.ChainParamsList{ @@ -128,6 +128,6 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { Creator: admin, ChainId: common.ExternalChainList()[3].ChainId, }) - require.ErrorIs(t, err, types.ErrChainParamsNotFound) + assert.ErrorIs(t, err, types.ErrChainParamsNotFound) }) } diff --git a/x/observer/keeper/msg_server_update_chain_params_test.go b/x/observer/keeper/msg_server_update_chain_params_test.go index 7b2f8a5cb3..8d8680c919 100644 --- a/x/observer/keeper/msg_server_update_chain_params_test.go +++ b/x/observer/keeper/msg_server_update_chain_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -27,7 +27,7 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { // check list initially empty _, found := k.GetChainParamsList(ctx) - require.False(t, found) + assert.False(t, found) // a new chain params can be added chainParams1 := sample.ChainParams(chain1) @@ -35,13 +35,13 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: admin, ChainParams: chainParams1, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has one chain params chainParamsList, found := k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 1) - require.Equal(t, chainParams1, chainParamsList.ChainParams[0]) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 1) + assert.Equal(t, chainParams1, chainParamsList.ChainParams[0]) // a new chian params can be added chainParams2 := sample.ChainParams(chain2) @@ -49,14 +49,14 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: admin, ChainParams: chainParams2, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has two chain params chainParamsList, found = k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 2) - require.Equal(t, chainParams1, chainParamsList.ChainParams[0]) - require.Equal(t, chainParams2, chainParamsList.ChainParams[1]) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 2) + assert.Equal(t, chainParams1, chainParamsList.ChainParams[0]) + assert.Equal(t, chainParams2, chainParamsList.ChainParams[1]) // a new chain params can be added chainParams3 := sample.ChainParams(chain3) @@ -64,15 +64,15 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: admin, ChainParams: chainParams3, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has three chain params chainParamsList, found = k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 3) - require.Equal(t, chainParams1, chainParamsList.ChainParams[0]) - require.Equal(t, chainParams2, chainParamsList.ChainParams[1]) - require.Equal(t, chainParams3, chainParamsList.ChainParams[2]) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 3) + assert.Equal(t, chainParams1, chainParamsList.ChainParams[0]) + assert.Equal(t, chainParams2, chainParamsList.ChainParams[1]) + assert.Equal(t, chainParams3, chainParamsList.ChainParams[2]) // chain params can be updated chainParams2.ConfirmationCount = chainParams2.ConfirmationCount + 1 @@ -80,15 +80,15 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: admin, ChainParams: chainParams2, }) - require.NoError(t, err) + assert.NoError(t, err) // check list has three chain params chainParamsList, found = k.GetChainParamsList(ctx) - require.True(t, found) - require.Len(t, chainParamsList.ChainParams, 3) - require.Equal(t, chainParams1, chainParamsList.ChainParams[0]) - require.Equal(t, chainParams2, chainParamsList.ChainParams[1]) - require.Equal(t, chainParams3, chainParamsList.ChainParams[2]) + assert.True(t, found) + assert.Len(t, chainParamsList.ChainParams, 3) + assert.Equal(t, chainParams1, chainParamsList.ChainParams[0]) + assert.Equal(t, chainParams2, chainParamsList.ChainParams[1]) + assert.Equal(t, chainParams3, chainParamsList.ChainParams[2]) }) t.Run("cannot update chain params if not authorized", func(t *testing.T) { @@ -99,7 +99,7 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: sample.AccAddress(), ChainParams: sample.ChainParams(common.ExternalChainList()[0].ChainId), }) - require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) // group 1 should not be able to update chain params admin := sample.AccAddress() @@ -109,7 +109,7 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { Creator: sample.AccAddress(), ChainParams: sample.ChainParams(common.ExternalChainList()[0].ChainId), }) - require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }) } diff --git a/x/observer/keeper/msg_server_update_crosschain_flags_test.go b/x/observer/keeper/msg_server_update_crosschain_flags_test.go index 555988694c..79654d6ed3 100644 --- a/x/observer/keeper/msg_server_update_crosschain_flags_test.go +++ b/x/observer/keeper/msg_server_update_crosschain_flags_test.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/keeper" @@ -46,17 +46,17 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsBtcTypeChainEnabled: false, }, }) - require.NoError(t, err) + assert.NoError(t, err) flags, found := k.GetCrosschainFlags(ctx) - require.True(t, found) - require.False(t, flags.IsInboundEnabled) - require.False(t, flags.IsOutboundEnabled) - require.Equal(t, int64(42), flags.GasPriceIncreaseFlags.EpochLength) - require.Equal(t, time.Minute*42, flags.GasPriceIncreaseFlags.RetryInterval) - require.Equal(t, uint32(42), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) - require.True(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) - require.False(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) + assert.True(t, found) + assert.False(t, flags.IsInboundEnabled) + assert.False(t, flags.IsOutboundEnabled) + assert.Equal(t, int64(42), flags.GasPriceIncreaseFlags.EpochLength) + assert.Equal(t, time.Minute*42, flags.GasPriceIncreaseFlags.RetryInterval) + assert.Equal(t, uint32(42), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) + assert.True(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) + assert.False(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) @@ -75,17 +75,17 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsBtcTypeChainEnabled: true, }, }) - require.NoError(t, err) + assert.NoError(t, err) flags, found = k.GetCrosschainFlags(ctx) - require.True(t, found) - require.True(t, flags.IsInboundEnabled) - require.True(t, flags.IsOutboundEnabled) - require.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) - require.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) - require.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) - require.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) - require.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) + assert.True(t, found) + assert.True(t, flags.IsInboundEnabled) + assert.True(t, flags.IsOutboundEnabled) + assert.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) + assert.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) + assert.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) + assert.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) + assert.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) // group 1 should be able to disable inbound and outbound setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group1) @@ -96,17 +96,17 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsInboundEnabled: false, IsOutboundEnabled: false, }) - require.NoError(t, err) + assert.NoError(t, err) flags, found = k.GetCrosschainFlags(ctx) - require.True(t, found) - require.False(t, flags.IsInboundEnabled) - require.False(t, flags.IsOutboundEnabled) - require.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) - require.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) - require.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) - require.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) - require.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) + assert.True(t, found) + assert.False(t, flags.IsInboundEnabled) + assert.False(t, flags.IsOutboundEnabled) + assert.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) + assert.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) + assert.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) + assert.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) + assert.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) // group 1 should be able to disable header verification setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group1) @@ -121,22 +121,22 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsBtcTypeChainEnabled: false, }, }) - require.NoError(t, err) + assert.NoError(t, err) flags, found = k.GetCrosschainFlags(ctx) - require.True(t, found) - require.False(t, flags.IsInboundEnabled) - require.False(t, flags.IsOutboundEnabled) - require.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) - require.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) - require.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) - require.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) - require.False(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) + assert.True(t, found) + assert.False(t, flags.IsInboundEnabled) + assert.False(t, flags.IsOutboundEnabled) + assert.Equal(t, int64(43), flags.GasPriceIncreaseFlags.EpochLength) + assert.Equal(t, time.Minute*43, flags.GasPriceIncreaseFlags.RetryInterval) + assert.Equal(t, uint32(43), flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) + assert.False(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) + assert.False(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) // if flags are not defined, default should be used k.RemoveCrosschainFlags(ctx) _, found = k.GetCrosschainFlags(ctx) - require.False(t, found) + assert.False(t, found) setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) @@ -145,15 +145,15 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsInboundEnabled: false, IsOutboundEnabled: true, }) - require.NoError(t, err) + assert.NoError(t, err) flags, found = k.GetCrosschainFlags(ctx) - require.True(t, found) - require.False(t, flags.IsInboundEnabled) - require.True(t, flags.IsOutboundEnabled) - require.Equal(t, types.DefaultGasPriceIncreaseFlags.EpochLength, flags.GasPriceIncreaseFlags.EpochLength) - require.Equal(t, types.DefaultGasPriceIncreaseFlags.RetryInterval, flags.GasPriceIncreaseFlags.RetryInterval) - require.Equal(t, types.DefaultGasPriceIncreaseFlags.GasPriceIncreasePercent, flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) + assert.True(t, found) + assert.False(t, flags.IsInboundEnabled) + assert.True(t, flags.IsOutboundEnabled) + assert.Equal(t, types.DefaultGasPriceIncreaseFlags.EpochLength, flags.GasPriceIncreaseFlags.EpochLength) + assert.Equal(t, types.DefaultGasPriceIncreaseFlags.RetryInterval, flags.GasPriceIncreaseFlags.RetryInterval) + assert.Equal(t, types.DefaultGasPriceIncreaseFlags.GasPriceIncreasePercent, flags.GasPriceIncreaseFlags.GasPriceIncreasePercent) }) t.Run("cannot update crosschain flags if not authorized", func(t *testing.T) { @@ -165,8 +165,8 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsInboundEnabled: false, IsOutboundEnabled: false, }) - require.Error(t, err) - require.Equal(t, types.ErrNotAuthorizedPolicy, err) + assert.Error(t, err) + assert.Equal(t, types.ErrNotAuthorizedPolicy, err) admin := sample.AccAddress() setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group1) @@ -176,7 +176,7 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { IsInboundEnabled: false, IsOutboundEnabled: true, }) - require.Error(t, err) - require.Equal(t, types.ErrNotAuthorizedPolicy, err) + assert.Error(t, err) + assert.Equal(t, types.ErrNotAuthorizedPolicy, err) }) } diff --git a/x/observer/keeper/nonce_to_cctx_test.go b/x/observer/keeper/nonce_to_cctx_test.go index 1cbd023fbd..9fc65fcea2 100644 --- a/x/observer/keeper/nonce_to_cctx_test.go +++ b/x/observer/keeper/nonce_to_cctx_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -17,8 +17,8 @@ func TestKeeper_GetNonceToCctx(t *testing.T) { } for _, n := range nonceToCctxList { rst, found := k.GetNonceToCctx(ctx, n.Tss, n.ChainId, n.Nonce) - require.True(t, found) - require.Equal(t, n, rst) + assert.True(t, found) + assert.Equal(t, n, rst) } }) t.Run("Get nonce to cctx not found", func(t *testing.T) { @@ -28,7 +28,7 @@ func TestKeeper_GetNonceToCctx(t *testing.T) { k.SetNonceToCctx(ctx, n) } _, found := k.GetNonceToCctx(ctx, "not_found", 1, 1) - require.False(t, found) + assert.False(t, found) }) t.Run("Get all nonce to cctx", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -37,6 +37,6 @@ func TestKeeper_GetNonceToCctx(t *testing.T) { k.SetNonceToCctx(ctx, n) } rst := k.GetAllNonceToCctx(ctx) - require.Equal(t, nonceToCctxList, rst) + assert.Equal(t, nonceToCctxList, rst) }) } diff --git a/x/observer/keeper/params_test.go b/x/observer/keeper/params_test.go index 5ec4c260a3..744e8e6080 100644 --- a/x/observer/keeper/params_test.go +++ b/x/observer/keeper/params_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -18,7 +18,7 @@ func TestGetParams(t *testing.T) { k.SetParams(ctx, params) - require.EqualValues(t, params, k.GetParams(ctx)) + assert.EqualValues(t, params, k.GetParams(ctx)) } func TestGenerateAddress(t *testing.T) { diff --git a/x/observer/keeper/pending_nonces_test.go b/x/observer/keeper/pending_nonces_test.go index 0cb61f090d..5fa115fd30 100644 --- a/x/observer/keeper/pending_nonces_test.go +++ b/x/observer/keeper/pending_nonces_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -21,12 +21,12 @@ func TestKeeper_PendingNoncesAll(t *testing.T) { k.SetPendingNonces(ctx, nonce) } rst, pageRes, err := k.GetAllPendingNoncesPaginated(ctx, &query.PageRequest{Limit: 10, CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.SliceStable(rst, func(i, j int) bool { return rst[i].ChainId < rst[j].ChainId }) - require.Equal(t, nonces, rst) - require.Equal(t, len(nonces), int(pageRes.Total)) + assert.Equal(t, nonces, rst) + assert.Equal(t, len(nonces), int(pageRes.Total)) }) t.Run("Get all pending nonces paginated by offset", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -39,13 +39,13 @@ func TestKeeper_PendingNoncesAll(t *testing.T) { } offset := 10 rst, pageRes, err := k.GetAllPendingNoncesPaginated(ctx, &query.PageRequest{Offset: uint64(offset), CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.SliceStable(rst, func(i, j int) bool { return rst[i].ChainId < rst[j].ChainId }) - require.Subset(t, nonces, rst) - require.Len(t, rst, len(nonces)-offset) - require.Equal(t, len(nonces), int(pageRes.Total)) + assert.Subset(t, nonces, rst) + assert.Len(t, rst, len(nonces)-offset) + assert.Equal(t, len(nonces), int(pageRes.Total)) }) t.Run("Get all pending nonces ", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -57,10 +57,10 @@ func TestKeeper_PendingNoncesAll(t *testing.T) { k.SetPendingNonces(ctx, nonce) } rst, err := k.GetAllPendingNonces(ctx) - require.NoError(t, err) + assert.NoError(t, err) sort.SliceStable(rst, func(i, j int) bool { return rst[i].ChainId < rst[j].ChainId }) - require.Equal(t, nonces, rst) + assert.Equal(t, nonces, rst) }) } diff --git a/x/observer/keeper/tss_test.go b/x/observer/keeper/tss_test.go index 37099a519b..91994ed6f0 100644 --- a/x/observer/keeper/tss_test.go +++ b/x/observer/keeper/tss_test.go @@ -6,14 +6,13 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -61,9 +60,9 @@ func TestTSSQuerySingle(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { response, err := k.TSS(wctx, tc.request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, tc.response, response) + assert.Equal(t, tc.response, response) } }) } @@ -101,9 +100,9 @@ func TestTSSQueryHistory(t *testing.T) { request := &types.QueryTssHistoryRequest{} response, err := keeper.TssHistory(wctx, request) if tc.err != nil { - require.ErrorIs(t, err, tc.err) + assert.ErrorIs(t, err, tc.err) } else { - require.Equal(t, len(tssList), len(response.TssList)) + assert.Equal(t, len(tssList), len(response.TssList)) prevTss, found := keeper.GetPreviousTSS(ctx) assert.Equal(t, tc.foundPrevious, found) if found { @@ -122,15 +121,15 @@ func TestKeeper_TssHistory(t *testing.T) { k.SetTSSHistory(ctx, tss) } rst, pageRes, err := k.GetAllTSSPaginated(ctx, &query.PageRequest{Limit: 20, CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.Slice(tssList, func(i, j int) bool { return tssList[i].FinalizedZetaHeight < tssList[j].FinalizedZetaHeight }) sort.Slice(rst, func(i, j int) bool { return rst[i].FinalizedZetaHeight < rst[j].FinalizedZetaHeight }) - require.Equal(t, tssList, rst) - require.Equal(t, len(tssList), int(pageRes.Total)) + assert.Equal(t, tssList, rst) + assert.Equal(t, len(tssList), int(pageRes.Total)) }) t.Run("Get tss history paginated by offset", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -140,16 +139,16 @@ func TestKeeper_TssHistory(t *testing.T) { k.SetTSSHistory(ctx, tss) } rst, pageRes, err := k.GetAllTSSPaginated(ctx, &query.PageRequest{Offset: uint64(offset), CountTotal: true}) - require.NoError(t, err) + assert.NoError(t, err) sort.Slice(tssList, func(i, j int) bool { return tssList[i].FinalizedZetaHeight < tssList[j].FinalizedZetaHeight }) sort.Slice(rst, func(i, j int) bool { return rst[i].FinalizedZetaHeight < rst[j].FinalizedZetaHeight }) - require.Subset(t, tssList, rst) - require.Equal(t, len(tssList)-offset, len(rst)) - require.Equal(t, len(tssList), int(pageRes.Total)) + assert.Subset(t, tssList, rst) + assert.Equal(t, len(tssList)-offset, len(rst)) + assert.Equal(t, len(tssList), int(pageRes.Total)) }) t.Run("Get all TSS without pagination", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -164,7 +163,7 @@ func TestKeeper_TssHistory(t *testing.T) { sort.Slice(rst, func(i, j int) bool { return rst[i].FinalizedZetaHeight < rst[j].FinalizedZetaHeight }) - require.Equal(t, tssList, rst) + assert.Equal(t, tssList, rst) }) t.Run("Get historical TSS", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -174,7 +173,7 @@ func TestKeeper_TssHistory(t *testing.T) { } r := rand.Intn((len(tssList)-1)-0) + 0 tss, found := k.GetHistoricalTssByFinalizedHeight(ctx, tssList[r].FinalizedZetaHeight) - require.True(t, found) - require.Equal(t, tssList[r], tss) + assert.True(t, found) + assert.Equal(t, tssList[r], tss) }) } diff --git a/x/observer/keeper/utils_test.go b/x/observer/keeper/utils_test.go index e62cc57758..3e99956e71 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" zetacommon "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -37,7 +36,7 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { case 1: return zetacommon.GoerliChain().ChainId default: - require.Fail(t, "invalid index") + assert.Fail(t, "invalid index") } return 0 } diff --git a/x/observer/migrations/v3/migrate_test.go b/x/observer/migrations/v3/migrate_test.go index 604fd0a9c7..a2b3574bff 100644 --- a/x/observer/migrations/v3/migrate_test.go +++ b/x/observer/migrations/v3/migrate_test.go @@ -3,7 +3,7 @@ package v3_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" v3 "github.com/zeta-chain/zetacore/x/observer/migrations/v3" @@ -18,9 +18,9 @@ func TestMigrateStore(t *testing.T) { params.AdminPolicy = []*types.Admin_Policy{} k.SetParams(ctx, params) err := v3.MigrateStore(ctx, k) - require.NoError(t, err) + assert.NoError(t, err) params = k.GetParams(ctx) - require.Len(t, params.AdminPolicy, 0) + assert.Len(t, params.AdminPolicy, 0) // update admin policy admin := sample.AccAddress() @@ -41,11 +41,11 @@ func TestMigrateStore(t *testing.T) { } k.SetParams(ctx, params) err = v3.MigrateStore(ctx, k) - require.NoError(t, err) + assert.NoError(t, err) params = k.GetParams(ctx) - require.Len(t, params.AdminPolicy, 2) - require.Equal(t, params.AdminPolicy[0].PolicyType, types.Policy_Type_group1) - require.Equal(t, params.AdminPolicy[1].PolicyType, types.Policy_Type_group2) - require.Equal(t, params.AdminPolicy[0].Address, admin) - require.Equal(t, params.AdminPolicy[1].Address, admin) + assert.Len(t, params.AdminPolicy, 2) + assert.Equal(t, params.AdminPolicy[0].PolicyType, types.Policy_Type_group1) + assert.Equal(t, params.AdminPolicy[1].PolicyType, types.Policy_Type_group2) + assert.Equal(t, params.AdminPolicy[0].Address, admin) + assert.Equal(t, params.AdminPolicy[1].Address, admin) } diff --git a/x/observer/migrations/v5/migrate_test.go b/x/observer/migrations/v5/migrate_test.go index d97b3dde69..0ceebf9e03 100644 --- a/x/observer/migrations/v5/migrate_test.go +++ b/x/observer/migrations/v5/migrate_test.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -59,13 +58,13 @@ func TestMigrateObserverParams(t *testing.T) { // set observer params dec42, err := sdk.NewDecFromStr("0.42") - require.NoError(t, err) + assert.NoError(t, err) dec43, err := sdk.NewDecFromStr("0.43") - require.NoError(t, err) + assert.NoError(t, err) dec1000, err := sdk.NewDecFromStr("1000.0") - require.NoError(t, err) + assert.NoError(t, err) dec1001, err := sdk.NewDecFromStr("1001.0") - require.NoError(t, err) + assert.NoError(t, err) params := types.Params{ ObserverParams: []*types.ObserverParams{ { @@ -86,23 +85,23 @@ func TestMigrateObserverParams(t *testing.T) { // perform migration err = v5.MigrateObserverParams(ctx, *k) - require.NoError(t, err) + assert.NoError(t, err) // check chain params newChainParamsList, found := k.GetChainParamsList(ctx) - require.True(t, found) + assert.True(t, found) // unchanged values - require.EqualValues(t, previousChainParamsList.ChainParams[0], newChainParamsList.ChainParams[0]) - require.EqualValues(t, previousChainParamsList.ChainParams[3], newChainParamsList.ChainParams[3]) + assert.EqualValues(t, previousChainParamsList.ChainParams[0], newChainParamsList.ChainParams[0]) + assert.EqualValues(t, previousChainParamsList.ChainParams[3], newChainParamsList.ChainParams[3]) // changed values - require.EqualValues(t, dec42, newChainParamsList.ChainParams[1].BallotThreshold) - require.EqualValues(t, dec1000, newChainParamsList.ChainParams[1].MinObserverDelegation) - require.EqualValues(t, dec43, newChainParamsList.ChainParams[2].BallotThreshold) - require.EqualValues(t, dec1001, newChainParamsList.ChainParams[2].MinObserverDelegation) - require.True(t, newChainParamsList.ChainParams[1].IsSupported) - require.True(t, newChainParamsList.ChainParams[2].IsSupported) + assert.EqualValues(t, dec42, newChainParamsList.ChainParams[1].BallotThreshold) + assert.EqualValues(t, dec1000, newChainParamsList.ChainParams[1].MinObserverDelegation) + assert.EqualValues(t, dec43, newChainParamsList.ChainParams[2].BallotThreshold) + assert.EqualValues(t, dec1001, newChainParamsList.ChainParams[2].MinObserverDelegation) + assert.True(t, newChainParamsList.ChainParams[1].IsSupported) + assert.True(t, newChainParamsList.ChainParams[2].IsSupported) // check remaining values are unchanged previousChainParamsList.ChainParams[1].BallotThreshold = dec42 @@ -111,6 +110,6 @@ func TestMigrateObserverParams(t *testing.T) { previousChainParamsList.ChainParams[2].MinObserverDelegation = dec1001 previousChainParamsList.ChainParams[1].IsSupported = true previousChainParamsList.ChainParams[2].IsSupported = true - require.EqualValues(t, previousChainParamsList.ChainParams[1], newChainParamsList.ChainParams[1]) - require.EqualValues(t, previousChainParamsList.ChainParams[2], newChainParamsList.ChainParams[2]) + assert.EqualValues(t, previousChainParamsList.ChainParams[1], newChainParamsList.ChainParams[1]) + assert.EqualValues(t, previousChainParamsList.ChainParams[2], newChainParamsList.ChainParams[2]) } diff --git a/x/observer/types/chain_params_test.go b/x/observer/types/chain_params_test.go index 0bdc9d814d..3d4d7ce456 100644 --- a/x/observer/types/chain_params_test.go +++ b/x/observer/types/chain_params_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/zeta-chain/zetacore/x/observer/types" . "gopkg.in/check.v1" @@ -13,22 +13,22 @@ func TestChainParamsList_Validate(t *testing.T) { t.Run("should return no error for default list", func(t *testing.T) { list := types.GetDefaultChainParams() err := list.Validate() - require.NoError(t, err) + assert.NoError(t, err) }) t.Run("should return error for invalid chain id", func(t *testing.T) { list := types.GetDefaultChainParams() list.ChainParams[0].ChainId = 999 err := list.Validate() - require.Error(t, err) + assert.Error(t, err) }) t.Run("should return error for duplicated chain ID", func(t *testing.T) { list := types.GetDefaultChainParams() list.ChainParams = append(list.ChainParams, list.ChainParams[0]) err := list.Validate() - require.Error(t, err) - require.Contains(t, err.Error(), "duplicated chain id") + assert.Error(t, err) + assert.Contains(t, err.Error(), "duplicated chain id") }) } @@ -46,8 +46,8 @@ func TestUpdateChainParamsSuiteSuite(t *testing.T) { func TestChainParamsEqual(t *testing.T) { params := types.GetDefaultChainParams() - require.True(t, types.ChainParamsEqual(*params.ChainParams[0], *params.ChainParams[0])) - require.False(t, types.ChainParamsEqual(*params.ChainParams[0], *params.ChainParams[1])) + assert.True(t, types.ChainParamsEqual(*params.ChainParams[0], *params.ChainParams[0])) + assert.False(t, types.ChainParamsEqual(*params.ChainParams[0], *params.ChainParams[1])) } func (s *UpdateChainParamsSuite) SetupTest() { @@ -87,9 +87,9 @@ func (s *UpdateChainParamsSuite) SetupTest() { func (s *UpdateChainParamsSuite) TestValidParams() { err := types.ValidateChainParams(s.evmParams) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) err = types.ValidateChainParams(s.btcParams) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) } func (s *UpdateChainParamsSuite) TestCommonParams() { @@ -101,99 +101,99 @@ func (s *UpdateChainParamsSuite) TestBTCParams() { copy := *s.btcParams copy.WatchUtxoTicker = 0 err := types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) } func (s *UpdateChainParamsSuite) TestCoreContractAddresses() { copy := *s.evmParams copy.ZetaTokenContractAddress = "0x123" err := types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *s.evmParams copy.ZetaTokenContractAddress = "733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *s.evmParams copy.ConnectorContractAddress = "0x123" err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *s.evmParams copy.ConnectorContractAddress = "733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *s.evmParams copy.Erc20CustodyContractAddress = "0x123" err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *s.evmParams copy.Erc20CustodyContractAddress = "733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) } func (s *UpdateChainParamsSuite) Validate(params *types.ChainParams) { copy := *params copy.ConfirmationCount = 0 err := types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *params copy.GasPriceTicker = 0 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy.GasPriceTicker = 300 err = types.ValidateChainParams(©) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) copy.GasPriceTicker = 301 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *params copy.InTxTicker = 0 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy.InTxTicker = 300 err = types.ValidateChainParams(©) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) copy.InTxTicker = 301 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *params copy.OutTxTicker = 0 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy.OutTxTicker = 300 err = types.ValidateChainParams(©) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) copy.OutTxTicker = 301 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *params copy.OutboundTxScheduleInterval = 0 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy.OutboundTxScheduleInterval = 100 err = types.ValidateChainParams(©) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) copy.OutboundTxScheduleInterval = 101 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy = *params copy.OutboundTxScheduleLookahead = 0 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) copy.OutboundTxScheduleLookahead = 500 err = types.ValidateChainParams(©) - require.Nil(s.T(), err) + assert.Nil(s.T(), err) copy.OutboundTxScheduleLookahead = 501 err = types.ValidateChainParams(©) - require.NotNil(s.T(), err) + assert.NotNil(s.T(), err) } diff --git a/x/observer/types/genesis_test.go b/x/observer/types/genesis_test.go index 1ba8212a35..d8ccb8414e 100644 --- a/x/observer/types/genesis_test.go +++ b/x/observer/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -36,9 +36,9 @@ func TestGenesisState_Validate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { - require.NoError(t, err) + assert.NoError(t, err) } else { - require.Error(t, err) + assert.Error(t, err) } }) } diff --git a/x/observer/types/message_add_observer_test.go b/x/observer/types/message_add_observer_test.go index b60ade5dc3..bdc723f759 100644 --- a/x/observer/types/message_add_observer_test.go +++ b/x/observer/types/message_add_observer_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -62,10 +62,10 @@ func TestMsgAddObserver_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/observer/types/message_crosschain_flags.go b/x/observer/types/message_crosschain_flags.go index 58d49cd3d3..54f90e0efb 100644 --- a/x/observer/types/message_crosschain_flags.go +++ b/x/observer/types/message_crosschain_flags.go @@ -68,10 +68,10 @@ func (gpf GasPriceIncreaseFlags) Validate() error { return nil } -// GetRequiredGroup returns the required group policy for the message to execute the message +// GetRequiredGroup returns the assertd group policy for the message to execute the message // Group 1 should only be able to stop or disable functiunalities in case of emergency // this concerns disabling inbound and outbound txs or block header verification -// every other action requires group 2 +// every other action asserts group 2 func (msg *MsgUpdateCrosschainFlags) GetRequiredGroup() Policy_Type { if msg.IsInboundEnabled || msg.IsOutboundEnabled { return Policy_Type_group2 diff --git a/x/observer/types/message_crosschain_flags_test.go b/x/observer/types/message_crosschain_flags_test.go index 199b80c13a..ca2d75597f 100644 --- a/x/observer/types/message_crosschain_flags_test.go +++ b/x/observer/types/message_crosschain_flags_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -56,10 +56,10 @@ func TestMsgUpdateCrosschainFlags_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } @@ -109,10 +109,10 @@ func TestGasPriceIncreaseFlags_Validate(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.gpf.Validate() if tt.errContains != "" { - require.ErrorContains(t, err, tt.errContains) + assert.ErrorContains(t, err, tt.errContains) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } @@ -149,7 +149,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group1, }, { - name: "updating gas price increase flags requires group 2", + name: "updating gas price increase flags asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -168,7 +168,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling inbound requires group 2", + name: "enabling inbound asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: true, @@ -182,7 +182,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling outbound requires group 2", + name: "enabling outbound asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -196,7 +196,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling eth header verification requires group 2", + name: "enabling eth header verification asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -210,7 +210,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling btc header verification requires group 2", + name: "enabling btc header verification asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -227,7 +227,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, tt.msg.GetRequiredGroup()) + assert.Equal(t, tt.want, tt.msg.GetRequiredGroup()) }) } } diff --git a/x/observer/types/message_remove_chain_params_test.go b/x/observer/types/message_remove_chain_params_test.go index 10d5a4c777..acc20ca9dd 100644 --- a/x/observer/types/message_remove_chain_params_test.go +++ b/x/observer/types/message_remove_chain_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -45,10 +45,10 @@ func TestMsgRemoveChainParams_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/observer/types/message_set_ballot_threshold_test.go b/x/observer/types/message_set_ballot_threshold_test.go index 6e797800c1..814dfd5646 100644 --- a/x/observer/types/message_set_ballot_threshold_test.go +++ b/x/observer/types/message_set_ballot_threshold_test.go @@ -25,10 +25,10 @@ package types // t.Run(tt.name, func(t *testing.T) { // err := tt.msg.ValidateBasic() // if tt.err != nil { -// require.ErrorIs(t, err, tt.err) +// assert.ErrorIs(t, err, tt.err) // return // } -// require.NoError(t, err) +// assert.NoError(t, err) // }) // } //} diff --git a/x/observer/types/message_update_chain_params_test.go b/x/observer/types/message_update_chain_params_test.go index 3f3efc4e2f..5c979dda08 100644 --- a/x/observer/types/message_update_chain_params_test.go +++ b/x/observer/types/message_update_chain_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -44,10 +44,10 @@ func TestMsgUpdateChainParams_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/observer/types/message_update_keygen_test.go b/x/observer/types/message_update_keygen_test.go index b7ad69741c..13213b9a98 100644 --- a/x/observer/types/message_update_keygen_test.go +++ b/x/observer/types/message_update_keygen_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -32,10 +32,10 @@ func TestMsgUpdateKeygen_ValidateBasic(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } diff --git a/x/observer/types/message_update_observer_test.go b/x/observer/types/message_update_observer_test.go index 0cff6bd25b..e438f6d9db 100644 --- a/x/observer/types/message_update_observer_test.go +++ b/x/observer/types/message_update_observer_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -79,10 +79,10 @@ func TestNewMsgUpdateObserver(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() if tt.err != nil { - require.ErrorIs(t, err, tt.err) + assert.ErrorIs(t, err, tt.err) return } - require.NoError(t, err) + assert.NoError(t, err) }) } }