Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AbciQuery to support error response. #71

Closed

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Nov 19, 2019

For example:

{"response": {"code": 1, "log": "account lookup failed: account not found", "info": "", "index": "0", "key": null, "value": null, "proof": null, "height ": "0", "codespace": ""}}


/// Proof (if requested)
pub proof: Option<Proof>,

/// Block height
pub height: block::Height,
#[serde(default, deserialize_with = "serializers::parse_height_option")]
pub height: Option<block::Height>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these are only optional now as they are None in case of an error response.

#[test]
fn parse_query_responses() {
let error_rsp = r#"{"response": {"code": 1, "log": "account lookup failed: account not found", "info": "", "index": "0", "key": null, "value": null, "proof": null, "height": "0", "codespace": ""}}"#;
let success_rsp = r#"{"response": {"value": "some value"}}"#;
Copy link
Member

@liamsi liamsi Nov 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't a successful response also include code etc and not only value? Let me double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems it depends solely on the abci app's implementation, and since it's protobuf, every field is optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to update our fixtures in the rpc to contain both JSON files, the happy path and the error case:
https://docs.tendermint.com/master/rpc/#/ABCI/abci_query

@yihuang
Copy link
Contributor Author

yihuang commented May 1, 2020

It's fixed in current master, closing now.

@yihuang yihuang closed this May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants