Skip to content

Commit

Permalink
Add uncompress test
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jul 8, 2022
1 parent 368445c commit f8991bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,23 @@ func TestCreateWithGzippedPayload(t *testing.T) {
require.Equal(t, hackatomWasm, storedCode)
}

func TestCreateWithBrokenGzippedPayload(t *testing.T) {
ctx, keepers := CreateTestInput(t, false, SupportedFeatures)
keeper := keepers.ContractKeeper

deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000))
creator := keepers.Faucet.NewFundedAccount(ctx, deposit...)

wasmCode, err := ioutil.ReadFile("./testdata/broken_crc.gzip")
require.NoError(t, err, "reading gzipped WASM code")

gm := sdk.NewInfiniteGasMeter()
contractID, err := keeper.Create(ctx.WithGasMeter(gm), creator, wasmCode, nil)
require.Error(t, err)
assert.Empty(t, contractID)
assert.GreaterOrEqual(t, gm.GasConsumed(), sdk.Gas(1618464)) // 809232 * 2 (default uncompress costs) = 1618464
}

func TestInstantiate(t *testing.T) {
ctx, keepers := CreateTestInput(t, false, SupportedFeatures)
keeper := keepers.ContractKeeper
Expand Down
Binary file added x/wasm/keeper/testdata/broken_crc.gzip
Binary file not shown.

0 comments on commit f8991bc

Please sign in to comment.