From 674ceafb6f26b51e809f7fee5dcfcdb1bd4100d1 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Thu, 28 Nov 2019 12:44:00 -0800 Subject: [PATCH] Use base64 serializer/deserializer for abci_query response key and value --- tendermint/src/rpc/endpoint/abci_query.rs | 16 ++++++++++++---- tendermint/tests/integration.rs | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tendermint/src/rpc/endpoint/abci_query.rs b/tendermint/src/rpc/endpoint/abci_query.rs index 218fee6bf..2995948bc 100644 --- a/tendermint/src/rpc/endpoint/abci_query.rs +++ b/tendermint/src/rpc/endpoint/abci_query.rs @@ -78,12 +78,20 @@ pub struct AbciQuery { pub index: i64, /// Key - // TODO(tarcieri): parse to Vec? - pub key: Option, + #[serde( + default, + serialize_with = "serializers::serialize_option_base64", + deserialize_with = "serializers::parse_option_base64" + )] + pub key: Option>, /// Value - // TODO(tarcieri): parse to Vec? - pub value: Option, + #[serde( + default, + serialize_with = "serializers::serialize_option_base64", + deserialize_with = "serializers::parse_option_base64" + )] + pub value: Option>, /// Proof (if requested) pub proof: Option, diff --git a/tendermint/tests/integration.rs b/tendermint/tests/integration.rs index 1367239d4..d5a83b47f 100644 --- a/tendermint/tests/integration.rs +++ b/tendermint/tests/integration.rs @@ -33,7 +33,7 @@ mod rpc { let abci_query = localhost_rpc_client() .abci_query(Some(key), vec![], None, false) .unwrap(); - assert_eq!(abci_query.key.as_ref().unwrap(), ""); + assert_eq!(abci_query.key.as_ref().unwrap(), &Vec::::new()); assert_eq!(abci_query.value.as_ref(), None); }