Skip to content

Commit

Permalink
rpc: add test against fixture from Osmosis
Browse files Browse the repository at this point in the history
The response has been obtained from Osmosis, and has some fields
that e.g. Gaia fixtures did not have non-trivial values for.
  • Loading branch information
mzabaluev committed Jul 14, 2023
1 parent d436765 commit 8f81d55
Show file tree
Hide file tree
Showing 2 changed files with 8,971 additions and 0 deletions.
46 changes: 46 additions & 0 deletions rpc/tests/osmosis_fixtures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use std::{fs, path::PathBuf};

use tendermint_rpc::{endpoint, 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("osmosis_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 {
"block_results_at_height_10499831" => {
let r = endpoint::block_results::v0_34::DialectResponse::from_string(content);
assert!(r.is_ok(), "block_results_at_height_10499831: {r:?}");
},
_ => {
panic!("unhandled incoming fixture: {file_name}");
},
}
}
}
Loading

0 comments on commit 8f81d55

Please sign in to comment.