Fix submessage tests

This commit is contained in:
Ethan Frey
2022-02-23 21:42:38 +01:00
parent 8f75ad1faf
commit 30bb2900c7
2 changed files with 7 additions and 3 deletions

View File

@@ -167,6 +167,10 @@ func logError(ctx sdk.Context, msg string, err error) {
}
func redactError(err error) string {
// FIXME: do we want to hardcode some constant string mappings here as well?
// Or better document them? (SDK error string may change on a patch release to fix wording)
// sdk/11 is out of gas
// sdk/5 is insufficient funds (on bank send)
codespace, code, _ := sdkerrors.ABCIInfo(err, false)
return fmt.Sprintf("Error: %s/%d", codespace, code)
}

View File

@@ -254,7 +254,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
msg: invalidBankSend,
subMsgError: true,
// uses less gas than the send tokens (cost of bank transfer)
resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("insufficient funds")},
resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("sdk/5")},
},
"out of gas panic with no gas limit": {
submsgID: 7,
@@ -275,7 +275,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(79000, 79040), assertErrorString("insufficient funds")},
resultAssertions: []assertion{assertGasUsed(77500, 77600), assertErrorString("sdk/5")},
},
"out of gas caught with gas limit": {
submsgID: 17,
@@ -283,7 +283,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+80000), assertErrorString("out of gas")},
resultAssertions: []assertion{assertGasUsed(subGasLimit+72000, subGasLimit+73000), assertErrorString("sdk/11")},
},
"instantiate contract gets address in data and events": {
submsgID: 21,