-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc: Add temporary fix and tests for
block_results
serialization (#…
…1061) * Rename kvstore module to common, since it provides common RPC requests Signed-off-by: Thane Thomson <connect@thanethomson.com> * Use the unused config params Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rename quick module to kvstore, since it caters exclusively for the kvstore Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add support for simple query plan for Gaia Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove outdated RPC request/response parsing tests Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove redundant interaction Signed-off-by: Thane Thomson <connect@thanethomson.com> * Enable rustls for wss support Signed-off-by: Thane Thomson <connect@thanethomson.com> * Use defaults if no version, app or app_version is supplied in ResponseInfo over ABCI and RPC Signed-off-by: Thane Thomson <connect@thanethomson.com> * Regenerate protos Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add convenience method to decode RPC requests from strings Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add deserialization workaround for validator updates This introduces a (somewhat hacky, yet temporary) approach to being able to deserialize public keys in validator updates until such time that Tendermint addresses the problem. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add test fixtures generated from local Gaia instance Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add test for outgoing requests Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add test case specifically for #1021 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix test case for #1021 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add changelog entry Signed-off-by: Thane Thomson <connect@thanethomson.com>
- Loading branch information
1 parent
8354fec
commit e562d4d
Showing
81 changed files
with
4,924 additions
and
23,249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- `[tendermint-rpc]` Allow deserialization of public keys from validator updates | ||
from `block_results` endpoint in multiple JSON formats until this is fixed in | ||
Tendermint | ||
([#1021](https://github.com/informalsystems/tendermint-rs/issues/1021)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
use std::fs; | ||
use std::path::PathBuf; | ||
use tendermint_rpc::event::Event; | ||
use tendermint_rpc::{endpoint, Request, Response}; | ||
use walkdir::WalkDir; | ||
|
||
fn find_fixtures(in_out_folder_name: &str) -> Vec<PathBuf> { | ||
WalkDir::new( | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
.join("tests") | ||
.join("gaia_fixtures") | ||
.join(in_out_folder_name), | ||
) | ||
.into_iter() | ||
.filter_map(|e| e.ok()) | ||
.filter(|e| { | ||
e.file_type().is_file() | ||
&& e.path().extension().is_some() | ||
&& e.path().extension().unwrap() == "json" | ||
}) | ||
.map(|e| e.into_path()) | ||
.collect::<Vec<PathBuf>>() | ||
} | ||
|
||
#[test] | ||
fn incoming_fixtures() { | ||
for json_file in find_fixtures("incoming") { | ||
let file_name = json_file | ||
.file_name() | ||
.unwrap() | ||
.to_str() | ||
.unwrap() | ||
.strip_suffix(".json") | ||
.unwrap(); | ||
let content = fs::read_to_string(&json_file).unwrap(); | ||
match file_name { | ||
"abci_info" => { | ||
let r = endpoint::abci_info::Response::from_string(content); | ||
assert!(r.is_ok(), "{:?}", r) | ||
} | ||
"block_at_height_0" => { | ||
assert!(endpoint::block::Response::from_string(content).is_err()) | ||
} | ||
"block_at_height_1" => { | ||
assert!(endpoint::block::Response::from_string(content).is_ok()) | ||
} | ||
"block_at_height_10" => { | ||
assert!(endpoint::block::Response::from_string(content).is_ok()) | ||
} | ||
"block_at_height_4555980" => { | ||
let r = endpoint::block::Response::from_string(content); | ||
assert!(r.is_ok(), "{:?}", r); | ||
} | ||
"block_results_at_height_10" => { | ||
let r = endpoint::block_results::Response::from_string(content); | ||
assert!(r.is_ok(), "block_results_at_height_10: {:?}", r); | ||
} | ||
"block_results_at_height_4555980" => { | ||
let r = endpoint::block_results::Response::from_string(content); | ||
assert!(r.is_ok(), "block_results_at_height_4555980: {:?}", r); | ||
} | ||
"blockchain_from_1_to_10" => { | ||
assert!(endpoint::blockchain::Response::from_string(content).is_ok()) | ||
} | ||
"commit_at_height_10" => { | ||
assert!(endpoint::commit::Response::from_string(content).is_ok()) | ||
} | ||
"consensus_params" => { | ||
assert!(endpoint::consensus_params::Response::from_string(content).is_ok()) | ||
} | ||
"consensus_state" => { | ||
assert!(endpoint::consensus_state::Response::from_string(content).is_ok()) | ||
} | ||
"genesis" => { | ||
assert!(endpoint::genesis::Response::from_string(content).is_ok()) | ||
} | ||
"net_info" => { | ||
assert!(endpoint::net_info::Response::from_string(content).is_ok()) | ||
} | ||
"status" => { | ||
assert!(endpoint::status::Response::from_string(content).is_ok()) | ||
} | ||
"subscribe_newblock" => { | ||
let r = endpoint::subscribe::Response::from_string(content); | ||
assert!(r.is_err(), "{:?}", r); | ||
} | ||
_ => { | ||
if file_name.starts_with("subscribe_newblock_") { | ||
let r = Event::from_string(content); | ||
assert!(r.is_ok(), "failed to parse event {}: {:?}", file_name, r); | ||
} else { | ||
panic!("unhandled incoming fixture: {}", file_name); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn outgoing_fixtures() { | ||
for json_file in find_fixtures("outgoing") { | ||
let file_name = json_file | ||
.file_name() | ||
.unwrap() | ||
.to_str() | ||
.unwrap() | ||
.strip_suffix(".json") | ||
.unwrap(); | ||
let content = fs::read_to_string(&json_file).unwrap(); | ||
match file_name { | ||
"abci_info" => { | ||
let r = endpoint::abci_info::Request::from_string(content); | ||
assert!(r.is_ok(), "{:?}", r) | ||
} | ||
"block_at_height_0" => { | ||
assert!(endpoint::block::Request::from_string(content).is_ok()) | ||
} | ||
"block_at_height_1" => { | ||
assert!(endpoint::block::Request::from_string(content).is_ok()) | ||
} | ||
"block_at_height_10" => { | ||
assert!(endpoint::block::Request::from_string(content).is_ok()) | ||
} | ||
"block_at_height_4555980" => { | ||
assert!(endpoint::block::Request::from_string(content).is_ok()) | ||
} | ||
"block_results_at_height_10" => { | ||
let r = endpoint::block_results::Request::from_string(content); | ||
assert!(r.is_ok(), "block_results_at_height_10: {:?}", r); | ||
} | ||
"block_results_at_height_4555980" => { | ||
let r = endpoint::block_results::Request::from_string(content); | ||
assert!(r.is_ok(), "block_results_at_height_4555980: {:?}", r); | ||
} | ||
"blockchain_from_1_to_10" => { | ||
assert!(endpoint::blockchain::Request::from_string(content).is_ok()) | ||
} | ||
"commit_at_height_10" => { | ||
assert!(endpoint::commit::Request::from_string(content).is_ok()) | ||
} | ||
"consensus_params" => { | ||
assert!(endpoint::consensus_params::Request::from_string(content).is_ok()) | ||
} | ||
"consensus_state" => { | ||
assert!(endpoint::consensus_state::Request::from_string(content).is_ok()) | ||
} | ||
"genesis" => { | ||
assert!(endpoint::genesis::Request::from_string(content).is_ok()) | ||
} | ||
"net_info" => { | ||
assert!(endpoint::net_info::Request::from_string(content).is_ok()) | ||
} | ||
"status" => { | ||
assert!(endpoint::status::Request::from_string(content).is_ok()) | ||
} | ||
"subscribe_newblock" => { | ||
let r = endpoint::subscribe::Request::from_string(content); | ||
assert!(r.is_ok(), "{:?}", r); | ||
} | ||
_ => panic!("unhandled outgoing fixture: {}", file_name), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "279cb095-9064-4620-bcaa-3c9383847575", | ||
"jsonrpc": "2.0", | ||
"result": { | ||
"response": { | ||
"data": "GaiaApp", | ||
"last_block_app_hash": "vMfcSlXF/bB/xdsaQeFALAzVoY6AKqiFwchFz9ZUguc=", | ||
"last_block_height": "154" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"error": { | ||
"code": -32603, | ||
"data": "height must be greater than 0, but got 0", | ||
"message": "Internal error" | ||
}, | ||
"id": "29b5f462-d1cb-4b33-ab23-f0c96aa462b0", | ||
"jsonrpc": "2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"id": "6b12587c-a02b-441b-9350-6a8a5ee6fb3b", | ||
"jsonrpc": "2.0", | ||
"result": { | ||
"block": { | ||
"data": { | ||
"txs": [] | ||
}, | ||
"evidence": { | ||
"evidence": [] | ||
}, | ||
"header": { | ||
"app_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"chain_id": "ibc-0", | ||
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", | ||
"data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"height": "1", | ||
"last_block_id": { | ||
"hash": "", | ||
"parts": { | ||
"hash": "", | ||
"total": 0 | ||
} | ||
}, | ||
"last_commit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"next_validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A", | ||
"proposer_address": "BB22AD764B674CC08753B24175E2FC61B22B1419", | ||
"time": "2021-12-17T20:27:28.966992937Z", | ||
"validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A", | ||
"version": { | ||
"block": "11" | ||
} | ||
}, | ||
"last_commit": { | ||
"block_id": { | ||
"hash": "", | ||
"parts": { | ||
"hash": "", | ||
"total": 0 | ||
} | ||
}, | ||
"height": "0", | ||
"round": 0, | ||
"signatures": [] | ||
} | ||
}, | ||
"block_id": { | ||
"hash": "739127E7942BEF14DFF0C3C9C4A9BF0DF1A97BEFF085153817B8960273830439", | ||
"parts": { | ||
"hash": "AF225F2883AFC75DB7F481E5BDEE396CE9B5787399F8F9876CA980BD026C02D1", | ||
"total": 1 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.