Skip to content

Commit

Permalink
Use base64 serializer/deserializer for abci_query response key and value
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Dec 2, 2019
1 parent 2ced6c7 commit 4bf5605
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions tendermint/src/rpc/endpoint/abci_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ pub struct AbciQuery {
pub index: i64,

/// Key
// TODO(tarcieri): parse to Vec<u8>?
pub key: Option<String>,
#[serde(
default,
serialize_with = "serializers::serialize_option_base64",
deserialize_with = "serializers::parse_option_base64"
)]
pub key: Option<Vec<u8>>,

/// Value
// TODO(tarcieri): parse to Vec<u8>?
pub value: Option<String>,
#[serde(
default,
serialize_with = "serializers::serialize_option_base64",
deserialize_with = "serializers::parse_option_base64"
)]
pub value: Option<Vec<u8>>,

/// Proof (if requested)
pub proof: Option<Proof>,
Expand Down
2 changes: 1 addition & 1 deletion tendermint/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u8>::new());
assert_eq!(abci_query.value.as_ref(), None);
}

Expand Down

0 comments on commit 4bf5605

Please sign in to comment.