Skip to content

Commit 1fda14d

Browse files
authored
imp!: allow failure expectations when using chain.SendMsgs (#4018)
1 parent dbfb293 commit 1fda14d

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

testing/chain.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,13 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) {
332332
chain.Coordinator.UpdateTimeForChain(chain)
333333

334334
_, r, err := simapp.SignAndDeliver(
335-
chain.TB,
336335
chain.TxConfig,
337336
chain.App.GetBaseApp(),
338337
msgs,
339338
chain.ChainID,
340339
[]uint64{chain.SenderAccount.GetAccountNumber()},
341340
[]uint64{chain.SenderAccount.GetSequence()},
342-
true, chain.SenderPrivKey,
341+
chain.SenderPrivKey,
343342
)
344343
if err != nil {
345344
return nil, err

testing/simapp/test_helpers.go

+5-15
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,9 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba
151151
//
152152
// CONTRACT: BeginBlock must be called before this function.
153153
func SignAndDeliver(
154-
tb testing.TB, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg,
155-
chainID string, accNums, accSeqs []uint64, expPass bool, priv ...cryptotypes.PrivKey,
154+
txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg,
155+
chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey,
156156
) (sdk.GasInfo, *sdk.Result, error) {
157-
tb.Helper()
158157
tx, err := simtestutil.GenSignedMockTx(
159158
rand.New(rand.NewSource(time.Now().UnixNano())),
160159
txCfg,
@@ -166,18 +165,9 @@ func SignAndDeliver(
166165
accSeqs,
167166
priv...,
168167
)
169-
require.NoError(tb, err)
170-
171-
// Simulate a sending a transaction
172-
gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx)
173-
174-
if expPass {
175-
require.NoError(tb, err)
176-
require.NotNil(tb, res)
177-
} else {
178-
require.Error(tb, err)
179-
require.Nil(tb, res)
168+
if err != nil {
169+
return sdk.GasInfo{}, nil, err
180170
}
181171

182-
return gInfo, res, err
172+
return app.SimDeliver(txCfg.TxEncoder(), tx)
183173
}

0 commit comments

Comments
 (0)