Fix test setup and assertions
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
|
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -347,7 +349,7 @@ func TestDispatchSubmessages(t *testing.T) {
|
|||||||
em := sdk.NewEventManager()
|
em := sdk.NewEventManager()
|
||||||
ctx := sdk.Context{}.WithMultiStore(&mockStore).
|
ctx := sdk.Context{}.WithMultiStore(&mockStore).
|
||||||
WithGasMeter(sdk.NewGasMeter(100)).
|
WithGasMeter(sdk.NewGasMeter(100)).
|
||||||
WithEventManager(em)
|
WithEventManager(em).WithLogger(log.TestingLogger())
|
||||||
d := NewMessageDispatcher(spec.msgHandler, spec.replyer)
|
d := NewMessageDispatcher(spec.msgHandler, spec.replyer)
|
||||||
gotData, gotErr := d.DispatchSubmessages(ctx, RandomAccountAddress(t), "any_port", spec.msgs)
|
gotData, gotErr := d.DispatchSubmessages(ctx, RandomAccountAddress(t), "any_port", spec.msgs)
|
||||||
if spec.expErr {
|
if spec.expErr {
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
|||||||
msg: invalidBankSend,
|
msg: invalidBankSend,
|
||||||
subMsgError: true,
|
subMsgError: true,
|
||||||
// uses less gas than the send tokens (cost of bank transfer)
|
// uses less gas than the send tokens (cost of bank transfer)
|
||||||
resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("sdk/5")},
|
resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("codespace: sdk, code: 5")},
|
||||||
},
|
},
|
||||||
"out of gas panic with no gas limit": {
|
"out of gas panic with no gas limit": {
|
||||||
submsgID: 7,
|
submsgID: 7,
|
||||||
@@ -275,7 +275,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
|||||||
subMsgError: true,
|
subMsgError: true,
|
||||||
gasLimit: &subGasLimit,
|
gasLimit: &subGasLimit,
|
||||||
// uses same gas as call without limit (note we do not charge the 40k on reply)
|
// uses same gas as call without limit (note we do not charge the 40k on reply)
|
||||||
resultAssertions: []assertion{assertGasUsed(77500, 77600), assertErrorString("sdk/5")},
|
resultAssertions: []assertion{assertGasUsed(77800, 77900), assertErrorString("codespace: sdk, code: 5")},
|
||||||
},
|
},
|
||||||
"out of gas caught with gas limit": {
|
"out of gas caught with gas limit": {
|
||||||
submsgID: 17,
|
submsgID: 17,
|
||||||
@@ -283,7 +283,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
|||||||
subMsgError: true,
|
subMsgError: true,
|
||||||
gasLimit: &subGasLimit,
|
gasLimit: &subGasLimit,
|
||||||
// uses all the subGasLimit, plus the 52k or so for the main contract
|
// uses all the subGasLimit, plus the 52k or so for the main contract
|
||||||
resultAssertions: []assertion{assertGasUsed(subGasLimit+72000, subGasLimit+73000), assertErrorString("sdk/11")},
|
resultAssertions: []assertion{assertGasUsed(subGasLimit+73000, subGasLimit+74000), assertErrorString("codespace: sdk, code: 11")},
|
||||||
},
|
},
|
||||||
"instantiate contract gets address in data and events": {
|
"instantiate contract gets address in data and events": {
|
||||||
submsgID: 21,
|
submsgID: 21,
|
||||||
|
|||||||
Reference in New Issue
Block a user