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

Errors parsing the response or Client RPC #10

Closed
amanusk opened this issue Aug 12, 2019 · 1 comment
Closed

Errors parsing the response or Client RPC #10

amanusk opened this issue Aug 12, 2019 · 1 comment

Comments

@amanusk
Copy link
Contributor

amanusk commented Aug 12, 2019

I am trying to use the client RPC to interact with the basic abci-cli kvstore application.
I have run tendermint node and abci-cli kvstore from two terminals.
RPC calls with curl as in the examples here all work as expected.

To try and broadcast a transaction from rust I use the following code:

use tendermint::rpc::Client;

fn main() {
    let client = Client::new(&"tcp://127.0.0.1:26657".parse().unwrap()).unwrap();

    let j = "abcd";

    let tx = tendermint::abci::transaction::Transaction::new(j.as_bytes().to_owned());
    let response = client.broadcast_tx_sync(tx).unwrap();
    println!("{:?}", response);
}

I am getting the error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: ParseError, message: "Parse error. Invalid JSON", data: Some("invalid type: integer `0`, expected a string at line 5 column 13") }', src/libcore/result.rs:1084:5

When calling curl 'localhost:26657/abci_query?path=""&data="abcd"&prove=false' afterwards, I do get a response where I can see that abcd was indeed stored successfully, so the problem is with parsing the response on the client side.

From some poking around it seems that this has to do with the Code field in the response, perhaps it should be "0" and not 0.

Any help solving this is appreciated. Is this a problem of the RPC documentation?

@amanusk amanusk changed the title Trouble parsing the response Errors parsing the response or Client RPC Aug 12, 2019
@tarcieri
Copy link
Contributor

@amanusk it's possible the Tendermint RPC API changed to return an integer here rather than a string. If so the code parser needs to be modified... ideally to accept both.

amanusk added a commit to amanusk/tendermint-rs that referenced this issue Aug 14, 2019
amanusk added a commit to amanusk/tendermint-rs that referenced this issue Aug 14, 2019
Addresses issue informalsystems#10
Added tests for both cases

Signed-off-by: amanusk <amanusk@protonmail.com>
amanusk added a commit to amanusk/tendermint-rs that referenced this issue Aug 14, 2019
Addresses issue informalsystems#10
Added tests for both cases

Signed-off-by: amanusk <amanusk@protonmail.com>
@amanusk amanusk closed this as completed Aug 15, 2019
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

No branches or pull requests

2 participants