Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
loloicci committed Feb 8, 2024
1 parent 87c95ba commit 2cd7fdf
Show file tree
Hide file tree
Showing 6 changed files with 62,260 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ replace (
// the following version across all dependencies.
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
google.golang.org/grpc => google.golang.org/grpc v1.33.2

github.com/Finschia/wasmvm => ../wasmvm
)
28 changes: 19 additions & 9 deletions x/wasmplus/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
addr1 = addrAcc1.String()
testContract = mustLoad("../wasm/keeper/testdata/hackatom.wasm")
oldContract = mustLoad("../wasm/testdata/escrow_0.7.wasm")
cwa2023004 = mustLoad("testdata/cwa2023004.wasm")
)

type initMsg struct {
Expand Down Expand Up @@ -428,16 +429,25 @@ func TestHandleNonPlusWasmCreate(t *testing.T) {
}

func TestErrorHandleNonPlusWasmCreate(t *testing.T) {
data := setupTest(t)
creator := data.faucet.NewFundedRandomAccount(data.ctx, sdk.NewInt64Coin("denom", 100000))
cases := map[string][]byte {
"simply invalid byte": []byte("invalid WASM contract"),
"CWA-2023-004": cwa2023004,
}

h := data.module.Route().Handler()
for name, code := range cases {
t.Run(name, func(t *testing.T) {
data := setupTest(t)
creator := data.faucet.NewFundedRandomAccount(data.ctx, sdk.NewInt64Coin("denom", 100000))

msg := &wasmtypes.MsgStoreCode{
Sender: creator.String(),
WASMByteCode: []byte("invalid WASM contract"),
}
msg := wasmtypes.MsgStoreCode{
Sender: creator.String(),
WASMByteCode: code,
}

_, err := h(data.ctx, msg)
require.ErrorContains(t, err, "Wasm validation")
h := data.module.Route().Handler()

_, err := h(data.ctx, &msg)
require.ErrorContains(t, err, "Wasm validation")
})
}
}
8 changes: 8 additions & 0 deletions x/wasmplus/testdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# testdata
## burner.wasm
This is not used in the test but is the base contract of cw2024004.wat.

## cwa2023003.wasm
This has 10001 functions.
Which exceeds the limit of numbers of func after CW-2023-004 patch.
This is made from cw2023004.wat and this is based on the burner contract in cosmwasm.
Binary file added x/wasmplus/testdata/burner.wasm
Binary file not shown.
Binary file added x/wasmplus/testdata/cwa2023004.wasm
Binary file not shown.
Loading

0 comments on commit 2cd7fdf

Please sign in to comment.