Skip to content

Commit

Permalink
feat(wasm-storage): Fix failing test regarding validation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Sep 29, 2023
1 parent 5a0aa81 commit 384457f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 13 additions & 2 deletions x/wasm-storage/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (s *KeeperTestSuite) TestStoreDataRequestWasm() {
regWasmZipped, err := ioutils.GzipIt(regWasm)
s.Require().NoError(err)

oversizedWasm, err := os.ReadFile("test_utils/simple-dr.wasm")
oversizedWasm, err := os.ReadFile("test_utils/oversized.wasm")
s.Require().NoError(err)
oversizedWasmZipped, err := ioutils.GzipIt(oversizedWasm)
s.Require().NoError(err)
Expand Down Expand Up @@ -117,7 +117,7 @@ func (s *KeeperTestSuite) TestStoreOverlayWasm() {
regWasmZipped, err := ioutils.GzipIt(regWasm)
s.Require().NoError(err)

oversizedWasm, err := os.ReadFile("test_utils/simple-dr.wasm")
oversizedWasm, err := os.ReadFile("test_utils/oversized.wasm")
s.Require().NoError(err)
oversizedWasmZipped, err := ioutils.GzipIt(oversizedWasm)
s.Require().NoError(err)
Expand All @@ -144,6 +144,17 @@ func (s *KeeperTestSuite) TestStoreOverlayWasm() {
Hash: hex.EncodeToString(crypto.Keccak256(regWasm)),
},
},
{
name: "invalid wasm type",
input: types.MsgStoreOverlayWasm{
Sender: s.authority,
Wasm: regWasm,
WasmType: types.WasmTypeDataRequest,
},
preRun: func() {},
expErr: true,
expErrMsg: "Overlay Wasm type must be data-request-executor or relayer",
},
{
name: "invalid authority",
input: types.MsgStoreOverlayWasm{
Expand Down
10 changes: 5 additions & 5 deletions x/wasm-storage/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *KeeperTestSuite) TestOverlayWasm() {
input := types.MsgStoreOverlayWasm{
Sender: s.authority,
Wasm: compWasm,
WasmType: types.WasmTypeDataRequest,
WasmType: types.WasmTypeDataRequestExecutor,
}
storedWasm, err := s.msgSrvr.StoreOverlayWasm(s.ctx, &input)
s.Require().NoError(err)
Expand Down Expand Up @@ -91,7 +91,7 @@ func (s *KeeperTestSuite) TestOverlayWasms() {
input := types.MsgStoreOverlayWasm{
Sender: s.authority,
Wasm: compWasm,
WasmType: types.WasmTypeDataRequest,
WasmType: types.WasmTypeRelayer,
}
storedWasm, err := s.msgSrvr.StoreOverlayWasm(s.ctx, &input)
s.Require().NoError(err)
Expand All @@ -102,7 +102,7 @@ func (s *KeeperTestSuite) TestOverlayWasms() {
input2 := types.MsgStoreOverlayWasm{
Sender: s.authority,
Wasm: compWasm2,
WasmType: types.WasmTypeDataRequest,
WasmType: types.WasmTypeRelayer,
}
storedWasm2, err := s.msgSrvr.StoreOverlayWasm(s.ctx, &input2)
s.Require().NoError(err)
Expand All @@ -111,6 +111,6 @@ func (s *KeeperTestSuite) TestOverlayWasms() {
res, err := s.queryClient.OverlayWasms(s.ctx, &req)
s.Require().NoError(err)
s.Require().NotNil(res)
s.Require().Equal(fmt.Sprintf("%s,%s", storedWasm.Hash, "WASM_TYPE_DATA_REQUEST"), res.HashTypePairs[0])
s.Require().Equal(fmt.Sprintf("%s,%s", storedWasm2.Hash, "WASM_TYPE_DATA_REQUEST"), res.HashTypePairs[1])
s.Require().Equal(fmt.Sprintf("%s,%s", storedWasm.Hash, "WASM_TYPE_RELAYER"), res.HashTypePairs[0])
s.Require().Equal(fmt.Sprintf("%s,%s", storedWasm2.Hash, "WASM_TYPE_RELAYER"), res.HashTypePairs[1])
}

0 comments on commit 384457f

Please sign in to comment.