@@ -87,3 +87,68 @@ pub struct CodeInfoResponse {
8787
8888#[ cfg( feature = "cosmwasm_1_2" ) ]
8989impl QueryResponseType for CodeInfoResponse { }
90+
91+ #[ cfg( test) ]
92+ mod tests {
93+ use super :: * ;
94+ use crate :: to_binary;
95+
96+ #[ test]
97+ fn wasm_query_contract_info_serialization ( ) {
98+ let query = WasmQuery :: ContractInfo {
99+ contract_addr : "aabbccdd456" . into ( ) ,
100+ } ;
101+ let json = to_binary ( & query) . unwrap ( ) ;
102+ assert_eq ! (
103+ String :: from_utf8_lossy( & json) ,
104+ r#"{"contract_info":{"contract_addr":"aabbccdd456"}}"# ,
105+ ) ;
106+ }
107+
108+ #[ test]
109+ #[ cfg( feature = "cosmwasm_1_2" ) ]
110+ fn wasm_query_code_info_serialization ( ) {
111+ let query = WasmQuery :: CodeInfo { code_id : 70 } ;
112+ let json = to_binary ( & query) . unwrap ( ) ;
113+ assert_eq ! (
114+ String :: from_utf8_lossy( & json) ,
115+ r#"{"code_info":{"code_id":70}}"# ,
116+ ) ;
117+ }
118+
119+ #[ test]
120+ fn contract_info_response_serialization ( ) {
121+ let response = ContractInfoResponse {
122+ code_id : 67 ,
123+ creator : "jane" . to_string ( ) ,
124+ admin : Some ( "king" . to_string ( ) ) ,
125+ pinned : true ,
126+ ibc_port : Some ( "wasm.123" . to_string ( ) ) ,
127+ } ;
128+ let json = to_binary ( & response) . unwrap ( ) ;
129+ assert_eq ! (
130+ String :: from_utf8_lossy( & json) ,
131+ r#"{"code_id":67,"creator":"jane","admin":"king","pinned":true,"ibc_port":"wasm.123"}"# ,
132+ ) ;
133+ }
134+
135+ #[ test]
136+ #[ cfg( feature = "cosmwasm_1_2" ) ]
137+ fn code_info_response_serialization ( ) {
138+ use crate :: HexBinary ;
139+
140+ let response = CodeInfoResponse {
141+ code_id : 67 ,
142+ creator : "jane" . to_string ( ) ,
143+ checksum : HexBinary :: from_hex (
144+ "f7bb7b18fb01bbf425cf4ed2cd4b7fb26a019a7fc75a4dc87e8a0b768c501f00" ,
145+ )
146+ . unwrap ( ) ,
147+ } ;
148+ let json = to_binary ( & response) . unwrap ( ) ;
149+ assert_eq ! (
150+ String :: from_utf8_lossy( & json) ,
151+ r#"{"code_id":67,"creator":"jane","checksum":"f7bb7b18fb01bbf425cf4ed2cd4b7fb26a019a7fc75a4dc87e8a0b768c501f00"}"# ,
152+ ) ;
153+ }
154+ }
0 commit comments