-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test for DYDX fixtures * Fix test * Fix comment * Add Changelog
- Loading branch information
Showing
5 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
.changelog/unreleased/bug-fixes/1415-fix-optional-event-type.md
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,3 @@ | ||
- `[tendermint-abci]` Add serde default for Event.type since it has omitempty in the Go | ||
implementation. | ||
([\#1416](https://github.com/informalsystems/tendermint-rs/pull/1416)) |
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,49 @@ | ||
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("dydx_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 { | ||
// NOTE: for the purpose of the test I manually emptied `validator_updates` from the | ||
// block_results, which has another unrelated issue deserializing the Secp256K1 public | ||
// key | ||
"block_results_at_height_12791634" => { | ||
let r = endpoint::block_results::Response::from_string(content); | ||
assert!(r.is_ok(), "block_results_at_height_12791634: {r:?}"); | ||
}, | ||
_ => { | ||
panic!("unhandled incoming fixture: {file_name}"); | ||
}, | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
rpc/tests/dydx_fixtures/incoming/block_results_at_height_12791634.json
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,61 @@ | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": -1, | ||
"result": { | ||
"height": "12791634", | ||
"txs_results": [ | ||
{ | ||
"code": 0, | ||
"data": "ChAIgICAAhD///////////8BEg4IoI0GEgQIgMYKGICAQBoJCgdlZDI1NTE5IgA=", | ||
"log": "", | ||
"info": "", | ||
"gas_wanted": "0", | ||
"gas_used": "0", | ||
"events": [], | ||
"codespace": "" | ||
} | ||
], | ||
"finalize_block_events": [ | ||
{ | ||
"attributes": [ | ||
{ | ||
"key": "", | ||
"value": "\n0/dydxprotocol.clob.MsgProposedOperationsResponse", | ||
"index": false | ||
} | ||
] | ||
}, | ||
{ | ||
"attributes": [ | ||
{ | ||
"key": "", | ||
"value": "\n2/dydxprotocol.bridge.MsgAcknowledgeBridgesResponse", | ||
"index": false | ||
} | ||
] | ||
}, | ||
{ | ||
"attributes": [ | ||
{ | ||
"key": "", | ||
"value": "\n3/dydxprotocol.perpetuals.MsgAddPremiumVotesResponse", | ||
"index": false | ||
} | ||
] | ||
}, | ||
{ | ||
"attributes": [ | ||
{ | ||
"key": "", | ||
"value": "\n2/dydxprotocol.prices.MsgUpdateMarketPricesResponse", | ||
"index": false | ||
} | ||
] | ||
} | ||
], | ||
"validator_updates": [ | ||
], | ||
"consensus_param_updates": null, | ||
"app_hash": null | ||
} | ||
} |
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