Skip to content

Commit ec10cf9

Browse files
committed
Add test fixtures generated from local Gaia instance
Signed-off-by: Thane Thomson <[email protected]>
1 parent 5d166e3 commit ec10cf9

33 files changed

+2878
-0
lines changed

rpc/tests/gaia_fixtures.rs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
use std::fs;
2+
use std::path::PathBuf;
3+
use tendermint_rpc::event::Event;
4+
use tendermint_rpc::{endpoint, Response};
5+
use walkdir::WalkDir;
6+
7+
fn find_fixtures(in_out_folder_name: &str) -> Vec<PathBuf> {
8+
WalkDir::new(
9+
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
10+
.join("tests")
11+
.join("gaia_fixtures")
12+
.join(in_out_folder_name),
13+
)
14+
.into_iter()
15+
.filter_map(|e| e.ok())
16+
.filter(|e| {
17+
e.file_type().is_file()
18+
&& e.path().extension().is_some()
19+
&& e.path().extension().unwrap() == "json"
20+
})
21+
.map(|e| e.into_path())
22+
.collect::<Vec<PathBuf>>()
23+
}
24+
25+
#[test]
26+
fn incoming_fixtures() {
27+
for json_file in find_fixtures("incoming") {
28+
let file_name = json_file
29+
.file_name()
30+
.unwrap()
31+
.to_str()
32+
.unwrap()
33+
.strip_suffix(".json")
34+
.unwrap();
35+
let content = fs::read_to_string(&json_file).unwrap();
36+
match file_name {
37+
"abci_info" => {
38+
let r = endpoint::abci_info::Response::from_string(content);
39+
assert!(r.is_ok(), "{:?}", r)
40+
}
41+
"block_at_height_0" => {
42+
assert!(endpoint::block::Response::from_string(content).is_err())
43+
}
44+
"block_at_height_1" => {
45+
assert!(endpoint::block::Response::from_string(content).is_ok())
46+
}
47+
"block_at_height_10" => {
48+
assert!(endpoint::block::Response::from_string(content).is_ok())
49+
}
50+
"block_results_at_height_10" => {
51+
let r = endpoint::block_results::Response::from_string(content);
52+
assert!(r.is_ok(), "block_results_at_height_10: {:?}", r);
53+
}
54+
"blockchain_from_1_to_10" => {
55+
assert!(endpoint::blockchain::Response::from_string(content).is_ok())
56+
}
57+
"commit_at_height_10" => {
58+
assert!(endpoint::commit::Response::from_string(content).is_ok())
59+
}
60+
"consensus_params" => {
61+
assert!(endpoint::consensus_params::Response::from_string(content).is_ok())
62+
}
63+
"consensus_state" => {
64+
assert!(endpoint::consensus_state::Response::from_string(content).is_ok())
65+
}
66+
"genesis" => {
67+
assert!(endpoint::genesis::Response::from_string(content).is_ok())
68+
}
69+
"net_info" => {
70+
assert!(endpoint::net_info::Response::from_string(content).is_ok())
71+
}
72+
"status" => {
73+
assert!(endpoint::status::Response::from_string(content).is_ok())
74+
}
75+
"subscribe_newblock" => {
76+
let r = endpoint::subscribe::Response::from_string(content);
77+
assert!(r.is_err(), "{:?}", r);
78+
}
79+
_ => {
80+
if file_name.starts_with("subscribe_newblock_") {
81+
let r = Event::from_string(content);
82+
assert!(r.is_ok(), "failed to parse event {}: {:?}", file_name, r);
83+
} else {
84+
panic!("unhandled incoming fixture: {}", file_name);
85+
}
86+
}
87+
}
88+
}
89+
}
90+
91+
#[test]
92+
fn outgoing_fixtures() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"id": "279cb095-9064-4620-bcaa-3c9383847575",
3+
"jsonrpc": "2.0",
4+
"result": {
5+
"response": {
6+
"data": "GaiaApp",
7+
"last_block_app_hash": "vMfcSlXF/bB/xdsaQeFALAzVoY6AKqiFwchFz9ZUguc=",
8+
"last_block_height": "154"
9+
}
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"error": {
3+
"code": -32603,
4+
"data": "height must be greater than 0, but got 0",
5+
"message": "Internal error"
6+
},
7+
"id": "29b5f462-d1cb-4b33-ab23-f0c96aa462b0",
8+
"jsonrpc": "2.0"
9+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"id": "6b12587c-a02b-441b-9350-6a8a5ee6fb3b",
3+
"jsonrpc": "2.0",
4+
"result": {
5+
"block": {
6+
"data": {
7+
"txs": []
8+
},
9+
"evidence": {
10+
"evidence": []
11+
},
12+
"header": {
13+
"app_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
14+
"chain_id": "ibc-0",
15+
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
16+
"data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
17+
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
18+
"height": "1",
19+
"last_block_id": {
20+
"hash": "",
21+
"parts": {
22+
"hash": "",
23+
"total": 0
24+
}
25+
},
26+
"last_commit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
27+
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
28+
"next_validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A",
29+
"proposer_address": "BB22AD764B674CC08753B24175E2FC61B22B1419",
30+
"time": "2021-12-17T20:27:28.966992937Z",
31+
"validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A",
32+
"version": {
33+
"block": "11"
34+
}
35+
},
36+
"last_commit": {
37+
"block_id": {
38+
"hash": "",
39+
"parts": {
40+
"hash": "",
41+
"total": 0
42+
}
43+
},
44+
"height": "0",
45+
"round": 0,
46+
"signatures": []
47+
}
48+
},
49+
"block_id": {
50+
"hash": "739127E7942BEF14DFF0C3C9C4A9BF0DF1A97BEFF085153817B8960273830439",
51+
"parts": {
52+
"hash": "AF225F2883AFC75DB7F481E5BDEE396CE9B5787399F8F9876CA980BD026C02D1",
53+
"total": 1
54+
}
55+
}
56+
}
57+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"id": "9ba09d2c-3d72-4a7f-8e12-eae2496a65fa",
3+
"jsonrpc": "2.0",
4+
"result": {
5+
"block": {
6+
"data": {
7+
"txs": []
8+
},
9+
"evidence": {
10+
"evidence": []
11+
},
12+
"header": {
13+
"app_hash": "A7139E6F28A9506629C60E3FDFD1A325E99177A4A3C8FA131732B6170C113C8E",
14+
"chain_id": "ibc-0",
15+
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
16+
"data_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
17+
"evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
18+
"height": "10",
19+
"last_block_id": {
20+
"hash": "CD0A81D2658C56FD65587E4502E4BC89955002B5B89F986C7D63A5AF184FBC92",
21+
"parts": {
22+
"hash": "6E41BBA804019240A672F9AC6625BAA6D40B3887D6F6BE3E64CF54D93F021B76",
23+
"total": 1
24+
}
25+
},
26+
"last_commit_hash": "3A9BEC015F1A923C17EF81007945F552AD4E35DDA445AFA91296564DCB748357",
27+
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
28+
"next_validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A",
29+
"proposer_address": "BB22AD764B674CC08753B24175E2FC61B22B1419",
30+
"time": "2021-12-17T20:27:47.875954829Z",
31+
"validators_hash": "0A6CA9001DB07E985DF9043045B392588DF7C1C720E30EBAEFDC8A848C551D6A",
32+
"version": {
33+
"block": "11"
34+
}
35+
},
36+
"last_commit": {
37+
"block_id": {
38+
"hash": "CD0A81D2658C56FD65587E4502E4BC89955002B5B89F986C7D63A5AF184FBC92",
39+
"parts": {
40+
"hash": "6E41BBA804019240A672F9AC6625BAA6D40B3887D6F6BE3E64CF54D93F021B76",
41+
"total": 1
42+
}
43+
},
44+
"height": "9",
45+
"round": 0,
46+
"signatures": [
47+
{
48+
"block_id_flag": 2,
49+
"signature": "d1qUrZd0jrJRGDnI3I69LXTTHh2HBLHY8U5r4YFwy7Zn+kdo30Xs0eAdhmpt7kUG/XZSr1zwyLTneRXPipn9DQ==",
50+
"timestamp": "2021-12-17T20:27:47.875954829Z",
51+
"validator_address": "BB22AD764B674CC08753B24175E2FC61B22B1419"
52+
}
53+
]
54+
}
55+
},
56+
"block_id": {
57+
"hash": "EB917FF229E0987637F20EDB8114CAC3F967D843C5CC480969D64D7A368F077F",
58+
"parts": {
59+
"hash": "ABFFFBEDF37CB50B0F5617D2A85110B838EA2B3E3E56CCA1E09A27DCD5BBF769",
60+
"total": 1
61+
}
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)