@@ -56,14 +56,14 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, ctx sdk.Context
5656
5757func TestGasCostOnQuery (t * testing.T ) {
5858 const (
59- GasNoWork uint64 = 63_987
60- GasNoWorkDiscounted uint64 = 5_968
61- // Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256
62- GasWork50 uint64 = 64_234 // this is a little shy of 50k gas - to keep an eye on the limit
63- GasWork50Discounted uint64 = 6_207
64-
65- GasReturnUnhashed uint64 = 89
66- GasReturnHashed uint64 = 86
59+ GasNoWork uint64 = 63_988
60+ GasWork50 uint64 = 64_236
61+ // should be discounted exactly by the difference between normal instance cost and discounted instance cost
62+ GasNoWorkDiscounted uint64 = GasNoWork - ( types . DefaultInstanceCost - types . DefaultInstanceCostDiscount )
63+ GasWork50Discounted uint64 = GasWork50 - ( types . DefaultInstanceCost - types . DefaultInstanceCostDiscount )
64+
65+ GasReturnUnhashed uint64 = 72
66+ GasReturnHashed uint64 = 60
6767 )
6868
6969 cases := map [string ]struct {
@@ -214,12 +214,16 @@ func TestLimitRecursiveQueryGas(t *testing.T) {
214214
215215 const (
216216 // Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256
217- GasWork2k uint64 = 76_817 // = SetupContractCost + x // we have 6x gas used in cpu than in the instance
217+ GasWork2k uint64 = 76818 // = SetupContractCost + x // we have 6x gas used in cpu than in the instance
218218
219- GasWork2kDiscounted uint64 = 18_264 + 432
219+ // should be discounted exactly by the difference between normal instance cost and discounted instance cost
220+ GasWork2kDiscounted uint64 = GasWork2k - (types .DefaultInstanceCost - types .DefaultInstanceCostDiscount )
220221
221222 // This is overhead for calling into a sub-contract
222- GasReturnHashed uint64 = 48 + 132
223+ GasReturnHashed uint64 = 62
224+
225+ // lots of additional gas for long error message
226+ GasError uint64 = 3396
223227 )
224228
225229 cases := map [string ]struct {
@@ -268,8 +272,8 @@ func TestLimitRecursiveQueryGas(t *testing.T) {
268272 },
269273 expectQueriesFromContract : 10 ,
270274 expectOutOfGas : false ,
271- expectError : "query wasm contract failed" , // Error we get from the contract instance doing the failing query, not wasmd
272- expectedGas : GasWork2k + GasReturnHashed + 9 * (GasWork2kDiscounted + GasReturnHashed ) + 3279 , // lots of additional gas for long error message
275+ expectError : "query wasm contract failed" , // Error we get from the contract instance doing the failing query, not wasmd
276+ expectedGas : GasWork2k + GasReturnHashed + 9 * (GasWork2kDiscounted + GasReturnHashed ) + GasError ,
273277 },
274278 }
275279
0 commit comments