From 61a88d98a927692abc5d57441d8857ae0ddc42c7 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Sun, 21 Jul 2024 11:10:33 +0800 Subject: [PATCH] test: added more test case --- e2e/interchaintestv8/wasm_msg_test.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/e2e/interchaintestv8/wasm_msg_test.go b/e2e/interchaintestv8/wasm_msg_test.go index 388119d..59a1fff 100644 --- a/e2e/interchaintestv8/wasm_msg_test.go +++ b/e2e/interchaintestv8/wasm_msg_test.go @@ -365,7 +365,6 @@ func (s *WasmTestSuite) TestSendWasmQueries() { })) s.Require().True(s.Run("WasmQuery::{ContractInfo, Raw}", func() { - // Execute the contract: executeMsg := cwicacontroller.ExecuteMsg{ SendCosmosMsgs: &cwicacontroller.ExecuteMsg_SendCosmosMsgs{ Queries: []cwicacontroller.QueryRequest_for_Empty{ @@ -379,14 +378,12 @@ func (s *WasmTestSuite) TestSendWasmQueries() { ContractAddr: s.CounterContract.Address, }, }}, - { - Wasm: &cwicacontroller.QueryRequest_for_Empty_Wasm{ - Raw: &cwicacontroller.WasmQuery_Raw{ - ContractAddr: s.CounterContract.Address, - Key: cwicacontroller.Binary(toBase64("state")), - }, + {Wasm: &cwicacontroller.QueryRequest_for_Empty_Wasm{ + Raw: &cwicacontroller.WasmQuery_Raw{ + ContractAddr: s.CounterContract.Address, + Key: cwicacontroller.Binary(toBase64("state")), }, - }, + }}, }, }, } @@ -410,13 +407,23 @@ func (s *WasmTestSuite) TestSendWasmQueries() { s.Require().Len(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses, 2) icaAddress := s.IcaContractToAddrMap[s.Contract.Address] + // ContractInfo query: s.Require().NotNil(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo) s.Require().Equal(icaAddress, *callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo.Admin) s.Require().Equal(icaAddress, callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo.Creator) s.Require().Equal(int(s.CounterCodeID), callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo.CodeId) s.Require().False(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo.Pinned) s.Require().Nil(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[0].Wasm.ContractInfo.IbcPort) - // TODO: add assertion for raw query + // Raw query: + type CounterState struct { + Count int `json:"count"` + Owner string `json:"owner"` + } + expState := CounterState{Count: 0, Owner: icaAddress} + s.Require().NotNil(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[1].Wasm.RawContractState) + var state CounterState + s.Require().NoError(json.Unmarshal(callbackCounter.Success[2].OnAcknowledgementPacketCallback.QueryResult.Success.Responses[1].Wasm.RawContractState.Unwrap(), &state)) + s.Require().Equal(expState, state) })) })) }