Skip to content

Commit

Permalink
Add testcase to uncompress spec
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Aug 26, 2022
1 parent e110d4b commit 4c40d1e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions x/wasm/keeper/gas_register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ func TestFromWasmVMGasConversion(t *testing.T) {

func TestUncompressCosts(t *testing.T) {
specs := map[string]struct {
lenIn int
exp sdk.Gas
lenIn int
exp sdk.Gas
expPanic bool
}{
"0": {
exp: 0,
Expand All @@ -453,9 +454,17 @@ func TestUncompressCosts(t *testing.T) {
lenIn: types.MaxWasmSize,
exp: 122880,
},
"invalid len": {
lenIn: -1,
expPanic: true,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
if spec.expPanic {
assert.Panics(t, func() { NewDefaultWasmGasRegister().UncompressCosts(spec.lenIn) })
return
}
got := NewDefaultWasmGasRegister().UncompressCosts(spec.lenIn)
assert.Equal(t, spec.exp, got)
})
Expand Down

0 comments on commit 4c40d1e

Please sign in to comment.