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 0c575d6
Show file tree
Hide file tree
Showing 7 changed files with 71,248 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
)
31 changes: 22 additions & 9 deletions x/wasmplus/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"testing"
_ "embed"

"github.com/dvsekhvalnov/jose2go/base64url"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -70,6 +71,9 @@ 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 +432,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 0c575d6

Please sign in to comment.