message: Test serialisation of WasmQuery::ContractInfo/CodeInfo, Contract/CodeInfoResponse
diff: @@ -87,3 +87,68 @@ pub struct CodeInfoResponse {
  #[cfg(feature = "cosmwasm_1_2")]
  impl QueryResponseType for CodeInfoResponse {}
  +
  +#[cfg(test)]
  +mod tests {
  + use super::*;
  + use crate::to_binary;
  +
  + #[test]
  + fn wasm_query_contract_info_serialization() {
  + let query = WasmQuery::ContractInfo {
  + contract_addr: "aabbccdd456".into(),
  + };
  + let json = to_binary(&query).unwrap();
  + assert_eq!(
  + String::from_utf8_lossy(&json),
  + r#"{"contract_info":{"contract_addr":"aabbccdd456"}}"#,
  + );
  + }
  +
  + #[test]
  + #[cfg(feature = "cosmwasm_1_2")]
  + fn wasm_query_code_info_serialization() {
  + let query = WasmQuery::CodeInfo { code_id: 70 };
  + let json = to_binary(&query).unwrap();
  + assert_eq!(
  + String::from_utf8_lossy(&json),
  + r#"{"code_info":{"code_id":70}}"#,
  + );
  + }
  +
  + #[test]
  + fn contract_info_response_serialization() {
  + let response = ContractInfoResponse {
  + code_id: 67,
  + creator: "jane".to_string(),
  + admin: Some("king".to_string()),
  + pinned: true,
  + ibc_port: Some("wasm.123".to_string()),
  + };
  + let json = to_binary(&response).unwrap();
  + assert_eq!(
  + String::from_utf8_lossy(&json),
  + r#"{"code_id":67,"creator":"jane","admin":"king","pinned":true,"ibc_port":"wasm.123"}"#,
  + );
  + }
  +
  + #[test]
  + #[cfg(feature = "cosmwasm_1_2")]
  + fn code_info_response_serialization() {
  + use crate::HexBinary;
  +
  + let response = CodeInfoResponse {
  + code_id: 67,
  + creator: "jane".to_string(),
  + checksum: HexBinary::from_hex(
  + "f7bb7b18fb01bbf425cf4ed2cd4b7fb26a019a7fc75a4dc87e8a0b768c501f00",
  + )
  + .unwrap(),
  + };
  + let json = to_binary(&response).unwrap();
  + assert_eq!(
  + String::from_utf8_lossy(&json),
  + r#"{"code_id":67,"creator":"jane","checksum":"f7bb7b18fb01bbf425cf4ed2cd4b7fb26a019a7fc75a4dc87e8a0b768c501f00"}"#,
  + );
  + }
  +}
  