From 1fda14dd18b24e08a750edb2e3eae8d1465fe2f9 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 5 Jul 2023 18:11:02 +0200 Subject: [PATCH] imp!: allow failure expectations when using chain.SendMsgs (#4018) --- testing/chain.go | 3 +-- testing/simapp/test_helpers.go | 20 +++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/testing/chain.go b/testing/chain.go index 9f38cf86f86..39a45650ad9 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -332,14 +332,13 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { chain.Coordinator.UpdateTimeForChain(chain) _, r, err := simapp.SignAndDeliver( - chain.TB, chain.TxConfig, chain.App.GetBaseApp(), msgs, chain.ChainID, []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{chain.SenderAccount.GetSequence()}, - true, chain.SenderPrivKey, + chain.SenderPrivKey, ) if err != nil { return nil, err diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index c9b97885422..b14a1c1fa68 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -151,10 +151,9 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba // // CONTRACT: BeginBlock must be called before this function. func SignAndDeliver( - tb testing.TB, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, - chainID string, accNums, accSeqs []uint64, expPass bool, priv ...cryptotypes.PrivKey, + txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, + chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - tb.Helper() tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), txCfg, @@ -166,18 +165,9 @@ func SignAndDeliver( accSeqs, priv..., ) - require.NoError(tb, err) - - // Simulate a sending a transaction - gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx) - - if expPass { - require.NoError(tb, err) - require.NotNil(tb, res) - } else { - require.Error(tb, err) - require.Nil(tb, res) + if err != nil { + return sdk.GasInfo{}, nil, err } - return gInfo, res, err + return app.SimDeliver(txCfg.TxEncoder(), tx) }