Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMHasperhoven committed Oct 17, 2024
1 parent 395e2ef commit 03e8a05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 6 additions & 5 deletions tools/compiler/tests/test_get_chain_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ fn test_get_chain_configs_reads_configs_correctly() {
"ibcConnections": [],
"validators": [],
"nativeAssets": [],
"canonicalNumeraires": []
"canonicalNumeraires": [],
"priorityScoresByBase": {},
})
.to_string();
create_test_config_file(temp_input_dir.path(), "test-chain-1.json", &config_content);
Expand All @@ -47,8 +48,8 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() {
"ibcConnections": [],
"validators": [],
"nativeAssets": [],
"canonicalNumeraires": []

"canonicalNumeraires": [],
"priorityScoresByBase": {},
})
.to_string();
create_test_config_file(
Expand All @@ -65,8 +66,8 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() {
"ibcConnections": [],
"validators": [],
"nativeAssets": [],
"canonicalNumeraires": []

"canonicalNumeraires": [],
"priorityScoresByBase": {},
})
.to_string();
create_test_config_file(
Expand Down
13 changes: 12 additions & 1 deletion tools/compiler/tests/test_processor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
use std::collections::HashMap;
use penumbra_asset::asset::Metadata;
use penumbra_registry::parser::IbcInput;
use penumbra_registry::processor::{base64_id, transport_metadata_along_channel};

fn convert_to_u64_map(input: HashMap<String, String>) -> HashMap<String, u64> {
input.into_iter()
.filter_map(|(key, value)| {
value.parse::<u64>().ok().map(|parsed_value| (key, parsed_value))
})
.collect()
}

#[test]
fn base64_id_extracts_correctly() {
let asset_json = r#"
Expand Down Expand Up @@ -57,7 +66,9 @@ fn test_transport_metadata_along_channel() {
"transfer/channel-123/ugm": "7"
}
"#;

let priority_scores_by_base_json = serde_json::from_str(priority_scores_by_base).unwrap();
let priority_scores_by_base_json_parsed = convert_to_u64_map(priority_scores_by_base_json);

let output_json = r#"
{
Expand All @@ -82,7 +93,7 @@ fn test_transport_metadata_along_channel() {
let output_metadata = serde_json::from_str(output_json).unwrap();

let result =
transport_metadata_along_channel(&ibc_data, input_metadata, &priority_scores_by_base_json)
transport_metadata_along_channel(&ibc_data, input_metadata, &priority_scores_by_base_json_parsed)
.unwrap();
assert_eq!(result, output_metadata);
}

0 comments on commit 03e8a05

Please sign in to comment.