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

RPC: Update hash to 32 byte value. #14

Merged
merged 1 commit into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/abci/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl<'de> Deserialize<'de> for Code {
where
E: serde::de::Error,
{
match val.parse::<u32>() {
Ok(val) => self.visit_u32(val),
match val.parse::<u64>() {
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For better readability.
This is related to a previous PR #13
In either cases visit_u64 method is called, so thought it would be better if it is explicit in the code.

Ok(val) => self.visit_u64(val),
Err(_) => Err(E::custom("failed to parse integer")),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/abci/transaction/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use subtle::{self, ConstantTimeEq};
use subtle_encoding::hex;

/// Size of a transaction hash in bytes
pub const LENGTH: usize = 20;
pub const LENGTH: usize = 32;
Copy link
Member

Choose a reason for hiding this comment

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

I introduced HASH_SIZE in https://github.com/interchainio/tendermint-rs/blob/master/src/merkle.rs#L6 ... we'll need to de-duplicate eventually but for now it's fine ....


/// Trannsaction hashes
#[derive(Copy, Clone, Hash)]
Expand Down
8 changes: 4 additions & 4 deletions tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod endpoints {

assert_eq!(
&response.hash.to_string(),
"E39AAB7A537ABAA237831742DCE1117F187C3C52"
"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
);
}

Expand All @@ -127,7 +127,7 @@ mod endpoints {

assert_eq!(
&response.hash.to_string(),
"0D33F2F03A5234F38706E43004489E061AC40A2E"
"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
);
}

Expand All @@ -142,7 +142,7 @@ mod endpoints {

assert_eq!(
&response.hash.to_string(),
"0D33F2F03A5234F38706E43004489E061AC40A2E"
"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
);
}

Expand All @@ -155,7 +155,7 @@ mod endpoints {

assert_eq!(
&response.hash.to_string(),
"75CA0F856A4DA078FC4911580360E70CEFB2EBEE"
"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
Copy link
Member

Choose a reason for hiding this comment

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

Do the values of these not matter at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, these tests only check that parsing work correctly, and do not test the actual correctness of the hash.
Also, the hash is of the sent transaction and not of the response right?

Copy link
Member

Choose a reason for hiding this comment

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

Also, the hash is of the sent transaction and not of the response right?

That's right

);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/support/rpc/broadcast_tx_async.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"jsonrpc": "2.0",
"id": "",
"result": {
"hash": "E39AAB7A537ABAA237831742DCE1117F187C3C52",
"hash": "88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589",
"log": "",
"data": "",
"code": "0"
Expand Down
2 changes: 1 addition & 1 deletion tests/support/rpc/broadcast_tx_commit.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "",
"result": {
"height": "26682",
"hash": "75CA0F856A4DA078FC4911580360E70CEFB2EBEE",
"hash": "88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589",
"deliver_tx": {
"log": "",
"data": "",
Expand Down
2 changes: 1 addition & 1 deletion tests/support/rpc/broadcast_tx_sync.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"code": "0",
"data": "",
"log": "",
"hash": "0D33F2F03A5234F38706E43004489E061AC40A2E"
"hash": "88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
}
}
2 changes: 1 addition & 1 deletion tests/support/rpc/broadcast_tx_sync_int.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"code": 0,
"data": "",
"log": "",
"hash": "0D33F2F03A5234F38706E43004489E061AC40A2E"
"hash": "88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
}
}