Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jan 27, 2025
1 parent 49fb167 commit e563aa8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x/wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ func TestQuerySmartContractPanics(t *testing.T) {
CodeID: 1,
Created: types.NewAbsoluteTxPosition(ctx),
})
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(types.DefaultInstanceCost)).WithLogger(log.NewTestLogger(t))
gasLimit := types.DefaultInstanceCost + 5000

specs := map[string]struct {
doInContract func()
expErr *errorsmod.Error
}{
"out of gas": {
doInContract: func() {
ctx.GasMeter().ConsumeGas(ctx.GasMeter().Limit()+1, "test - consume more than limit")
ctx.GasMeter().ConsumeGas(gasLimit+1, "test - consume more than limit")
},
expErr: sdkErrors.ErrOutOfGas,
},
Expand All @@ -199,6 +199,9 @@ func TestQuerySmartContractPanics(t *testing.T) {
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
// reset gas meter
ctx = ctx.WithGasMeter(storetypes.NewGasMeter(gasLimit)).WithLogger(log.NewTestLogger(t))

keepers.WasmKeeper.wasmVM = &wasmtesting.MockWasmEngine{QueryFn: func(checksum wasmvm.Checksum, env wasmvmtypes.Env, queryMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.QueryResult, uint64, error) {
spec.doInContract()
return &wasmvmtypes.QueryResult{}, 0, nil
Expand Down

0 comments on commit e563aa8

Please sign in to comment.