Adapt tests to gas value changes
This commit is contained in:
@@ -1861,7 +1861,7 @@ func TestPinnedContractLoops(t *testing.T) {
|
||||
},
|
||||
}, 0, nil
|
||||
}
|
||||
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(20000))
|
||||
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(30_000))
|
||||
require.PanicsWithValue(t, storetypes.ErrorOutOfGas{Descriptor: "ReadFlat"}, func() {
|
||||
_, err := k.execute(ctx, example.Contract, RandomAccountAddress(t), anyMsg, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -419,7 +419,7 @@ func TestOnRecvPacket(t *testing.T) {
|
||||
},
|
||||
"submessage reply can overwrite ack data": {
|
||||
contractAddr: example.Contract,
|
||||
expContractGas: myContractGas + storageCosts,
|
||||
expContractGas: types.DefaultInstanceCostDiscount + myContractGas + storageCosts,
|
||||
contractResp: &wasmvmtypes.IBCReceiveResult{
|
||||
Ok: &wasmvmtypes.IBCReceiveResponse{
|
||||
Acknowledgement: []byte("myAck"),
|
||||
|
||||
@@ -243,14 +243,14 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
||||
"send tokens": {
|
||||
submsgID: 5,
|
||||
msg: validBankSend,
|
||||
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(105000, 106000)},
|
||||
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(107_000, 108_000)},
|
||||
},
|
||||
"not enough tokens": {
|
||||
submsgID: 6,
|
||||
msg: invalidBankSend,
|
||||
subMsgError: true,
|
||||
// uses less gas than the send tokens (cost of bank transfer)
|
||||
resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("codespace: sdk, code: 5")},
|
||||
resultAssertions: []assertion{assertGasUsed(78_000, 81_000), assertErrorString("codespace: sdk, code: 5")},
|
||||
},
|
||||
"out of gas panic with no gas limit": {
|
||||
submsgID: 7,
|
||||
@@ -263,7 +263,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
||||
msg: validBankSend,
|
||||
gasLimit: &subGasLimit,
|
||||
// uses same gas as call without limit (note we do not charge the 40k on reply)
|
||||
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(105000, 106000)},
|
||||
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(107_000, 108_000)},
|
||||
},
|
||||
"not enough tokens with limit": {
|
||||
submsgID: 16,
|
||||
@@ -271,7 +271,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
||||
subMsgError: true,
|
||||
gasLimit: &subGasLimit,
|
||||
// uses same gas as call without limit (note we do not charge the 40k on reply)
|
||||
resultAssertions: []assertion{assertGasUsed(77700, 77800), assertErrorString("codespace: sdk, code: 5")},
|
||||
resultAssertions: []assertion{assertGasUsed(79_700, 79_800), assertErrorString("codespace: sdk, code: 5")},
|
||||
},
|
||||
"out of gas caught with gas limit": {
|
||||
submsgID: 17,
|
||||
@@ -279,7 +279,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
|
||||
subMsgError: true,
|
||||
gasLimit: &subGasLimit,
|
||||
// uses all the subGasLimit, plus the 52k or so for the main contract
|
||||
resultAssertions: []assertion{assertGasUsed(subGasLimit+73000, subGasLimit+74000), assertErrorString("codespace: sdk, code: 11")},
|
||||
resultAssertions: []assertion{assertGasUsed(subGasLimit+75_000, subGasLimit+76_000), assertErrorString("codespace: sdk, code: 11")},
|
||||
},
|
||||
"instantiate contract gets address in data and events": {
|
||||
submsgID: 21,
|
||||
|
||||
@@ -60,19 +60,19 @@ func TestSetupContractCost(t *testing.T) {
|
||||
srcLen: 1,
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: DefaultContractMessageDataCost,
|
||||
exp: DefaultInstanceCostDiscount + DefaultContractMessageDataCost,
|
||||
},
|
||||
"big msg - pinned": {
|
||||
srcLen: math.MaxUint32,
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: DefaultContractMessageDataCost * math.MaxUint32,
|
||||
exp: DefaultInstanceCostDiscount + DefaultContractMessageDataCost*math.MaxUint32,
|
||||
},
|
||||
"empty msg - pinned": {
|
||||
srcLen: 0,
|
||||
pinned: true,
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: storetypes.Gas(0),
|
||||
exp: DefaultInstanceCostDiscount,
|
||||
},
|
||||
"small msg - unpinned": {
|
||||
srcLen: 1,
|
||||
@@ -89,7 +89,6 @@ func TestSetupContractCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost,
|
||||
},
|
||||
|
||||
"negative len": {
|
||||
srcLen: -1,
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
@@ -118,7 +117,7 @@ func TestReplyCost(t *testing.T) {
|
||||
exp storetypes.Gas
|
||||
expPanic bool
|
||||
}{
|
||||
"subcall response with events and data - pinned": {
|
||||
"submessage reply with events and data - pinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -131,9 +130,9 @@ func TestReplyCost(t *testing.T) {
|
||||
},
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost + DefaultContractMessageDataCost, // 3 == len("foo")
|
||||
exp: DefaultInstanceCostDiscount + 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost + DefaultContractMessageDataCost, // 3 == len("foo")
|
||||
},
|
||||
"subcall response with events - pinned": {
|
||||
"submessage reply with events - pinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -145,9 +144,9 @@ func TestReplyCost(t *testing.T) {
|
||||
},
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost, // 3 == len("foo")
|
||||
exp: DefaultInstanceCostDiscount + 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost, // 3 == len("foo")
|
||||
},
|
||||
"subcall response with events exceeds free tier- pinned": {
|
||||
"submessage reply with events exceeds free tier - pinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -159,9 +158,9 @@ func TestReplyCost(t *testing.T) {
|
||||
},
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: (3+6)*DefaultEventAttributeDataCost + DefaultPerAttributeCost, // 3 == len("foo"), 6 == len("myData")
|
||||
exp: DefaultInstanceCostDiscount + (3+6)*DefaultEventAttributeDataCost + DefaultPerAttributeCost, // 3 == len("foo"), 6 == len("myData")
|
||||
},
|
||||
"subcall response error - pinned": {
|
||||
"submessage reply error - pinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Err: "foo",
|
||||
@@ -169,9 +168,9 @@ func TestReplyCost(t *testing.T) {
|
||||
},
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
pinned: true,
|
||||
exp: 3 * DefaultContractMessageDataCost,
|
||||
exp: DefaultInstanceCostDiscount + 3*DefaultContractMessageDataCost,
|
||||
},
|
||||
"subcall response with events and data - unpinned": {
|
||||
"submessage reply with events and data - unpinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -185,7 +184,7 @@ func TestReplyCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost + 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost + DefaultContractMessageDataCost,
|
||||
},
|
||||
"subcall response with events - unpinned": {
|
||||
"submessage reply with events - unpinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -198,7 +197,7 @@ func TestReplyCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost + 3*DefaultEventAttributeDataCost + DefaultPerAttributeCost,
|
||||
},
|
||||
"subcall response with events exceeds free tier- unpinned": {
|
||||
"submessage reply with events exceeds free tier - unpinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -211,7 +210,7 @@ func TestReplyCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost + (3+6)*DefaultEventAttributeDataCost + DefaultPerAttributeCost, // 3 == len("foo"), 6 == len("myData")
|
||||
},
|
||||
"subcall response error - unpinned": {
|
||||
"submessage reply error - unpinned": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Err: "foo",
|
||||
@@ -220,7 +219,7 @@ func TestReplyCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost + 3*DefaultContractMessageDataCost,
|
||||
},
|
||||
"subcall response with empty events": {
|
||||
"submessage reply with empty events": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{
|
||||
@@ -231,7 +230,7 @@ func TestReplyCost(t *testing.T) {
|
||||
srcConfig: DefaultGasRegisterConfig(),
|
||||
exp: DefaultInstanceCost,
|
||||
},
|
||||
"subcall response with events unset": {
|
||||
"submessage reply with events unset": {
|
||||
src: wasmvmtypes.Reply{
|
||||
Result: wasmvmtypes.SubMsgResult{
|
||||
Ok: &wasmvmtypes.SubMsgResponse{},
|
||||
|
||||
Reference in New Issue
Block a user