Skip to content

Commit

Permalink
test: added more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Jul 21, 2024
1 parent 78f122f commit 61a88d9
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions e2e/interchaintestv8/wasm_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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")),
},
},
}},
},
},
}
Expand All @@ -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)
}))
}))
}
Expand Down

0 comments on commit 61a88d9

Please sign in to comment.