Adjust gas prices in tests

This commit is contained in:
Ethan Frey
2021-10-07 12:26:25 +02:00
parent e5dc6fe583
commit e878842136
2 changed files with 16 additions and 15 deletions

View File

@@ -3,6 +3,9 @@ package keeper
import (
"encoding/json"
"errors"
"math"
"testing"
"github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting"
"github.com/CosmWasm/wasmd/x/wasm/types"
wasmvm "github.com/CosmWasm/wasmvm"
@@ -10,8 +13,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"math"
"testing"
)
func TestOnOpenChannel(t *testing.T) {
@@ -398,7 +399,7 @@ func TestOnRecvPacket(t *testing.T) {
},
"submessage reply can overwrite ack data": {
contractAddr: example.Contract,
expContractGas: myContractGas + 10 + DefaultInstanceCost + 3707,
expContractGas: myContractGas + 10 + 3707,
contractResp: &wasmvmtypes.IBCReceiveResponse{
Acknowledgement: []byte("myAck"),
Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyAlways, Msg: wasmvmtypes.CosmosMsg{Bank: &wasmvmtypes.BankMsg{}}}},

View File

@@ -3,11 +3,12 @@ package keeper
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"io/ioutil"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
@@ -243,17 +244,16 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
resultAssertions []assertion
}{
"send tokens": {
submsgID: 5,
msg: validBankSend,
// note we charge another 40k for the reply call
resultAssertions: []assertion{assertReturnedEvents(1), assertGasUsed(116000, 121000)},
submsgID: 5,
msg: validBankSend,
resultAssertions: []assertion{assertReturnedEvents(1), assertGasUsed(76000, 81000)},
},
"not enough tokens": {
submsgID: 6,
msg: invalidBankSend,
subMsgError: true,
// uses less gas than the send tokens (cost of bank transfer)
resultAssertions: []assertion{assertGasUsed(97000, 99000), assertErrorString("insufficient funds")},
resultAssertions: []assertion{assertGasUsed(57000, 59000), assertErrorString("insufficient funds")},
},
"out of gas panic with no gas limit": {
submsgID: 7,
@@ -265,24 +265,24 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
submsgID: 15,
msg: validBankSend,
gasLimit: &subGasLimit,
// uses same gas as call without limit
resultAssertions: []assertion{assertReturnedEvents(1), assertGasUsed(116000, 121000)},
// uses same gas as call without limit (note we do not charge the 40k on reply)
resultAssertions: []assertion{assertReturnedEvents(1), assertGasUsed(76000, 81000)},
},
"not enough tokens with limit": {
submsgID: 16,
msg: invalidBankSend,
subMsgError: true,
gasLimit: &subGasLimit,
// uses same gas as call without limit
resultAssertions: []assertion{assertGasUsed(97000, 99000), assertErrorString("insufficient funds")},
// uses same gas as call without limit (note we do not charge the 40k on reply)
resultAssertions: []assertion{assertGasUsed(57000, 59000), assertErrorString("insufficient funds")},
},
"out of gas caught with gas limit": {
submsgID: 17,
msg: infiniteLoop,
subMsgError: true,
gasLimit: &subGasLimit,
// uses all the subGasLimit, plus the 92k or so for the main contract
resultAssertions: []assertion{assertGasUsed(subGasLimit+92000, subGasLimit+94000), assertErrorString("out of gas")},
// uses all the subGasLimit, plus the 52k or so for the main contract
resultAssertions: []assertion{assertGasUsed(subGasLimit+52000, subGasLimit+54000), assertErrorString("out of gas")},
},
"instantiate contract gets address in data and events": {
submsgID: 21,