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 from_str serializer #1322

Merged
merged 1 commit into from
Jul 5, 2023
Merged

Conversation

noot
Copy link
Contributor

@noot noot commented Jul 4, 2023

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Added entry in .changelog/

This fixes the from_str serialization. I discovered this while trying to serialize and deserialize the response type for broadcast_tx_commit while making a mock tendermint server; the gas_wanted field and a few others were serialized as integers, but were decoded as a string, causing an error invalid type: integer 0, expected a string at line 1 column 98. Display formats the integer without quotes, but we wanted with quotes.

Before:

"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"check_tx\":{\"code\":0,\"data\":[],\"log\":\"\",\"info\":\"\",\"gas_wanted\":0,\"gas_used\":0,\"events\":[],\"codespace\":\"\",\"sender\":\"\",\"priority\":0,\"mempool_error\":\"\"},\"deliver_tx\":{\"code\":0,\"data\":[],\"log\":\"\",\"info\":\"\",\"gas_wanted\":0,\"gas_used\":0,\"events\":[],\"codespace\":\"\"},\"hash\":\"\",\"height\":\"1\"},\"error\":null}"

After:

"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"check_tx\":{\"code\":0,\"data\":null,\"log\":\"\",\"info\":\"\",\"gas_wanted\":\"0\",\"gas_used\":\"0\",\"events\":[],\"codespace\":\"\",\"sender\":\"\",\"priority\":\"0\",\"mempool_error\":\"\"},\"deliver_tx\":{\"code\":0,\"data\":null,\"log\":\"\",\"info\":\"\",\"gas_wanted\":\"0\",\"gas_used\":\"0\",\"events\":[],\"codespace\":\"\"},\"hash\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"height\":\"1\"},\"error\":null}"

Also made rpc::Wrapper::new_with_id public because I'm using it externally.

@codecov-commenter
Copy link

Codecov Report

Merging #1322 (8563a74) into main (52f3d8d) will increase coverage by 0.6%.
The diff coverage is 100.0%.

❗ Current head 8563a74 differs from pull request most recent head 889f4cf. Consider uploading reports for the commit 889f4cf to get more accurate results

@@           Coverage Diff           @@
##            main   #1322     +/-   ##
=======================================
+ Coverage   59.8%   60.4%   +0.6%     
=======================================
  Files        283     284      +1     
  Lines      26895   26596    -299     
=======================================
- Hits       16092   16083      -9     
+ Misses     10803   10513    -290     
Impacted Files Coverage Δ
rpc/src/response.rs 59.5% <ø> (ø)
proto/src/serializers/from_str.rs 100.0% <100.0%> (ø)

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@thanethomson thanethomson merged commit 9854a66 into informalsystems:main Jul 5, 2023
22 checks passed
@thanethomson
Copy link
Contributor

Thanks @noot!

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.

3 participants