From 03e8a059a85fd56175b4675d14bf9bbff2ad95c4 Mon Sep 17 00:00:00 2001 From: "Jason M. Hasperhoven" Date: Thu, 17 Oct 2024 19:28:31 +0400 Subject: [PATCH] Fix tests --- tools/compiler/tests/test_get_chain_configs.rs | 11 ++++++----- tools/compiler/tests/test_processor.rs | 13 ++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/compiler/tests/test_get_chain_configs.rs b/tools/compiler/tests/test_get_chain_configs.rs index f54e8ff..9e9a453 100644 --- a/tools/compiler/tests/test_get_chain_configs.rs +++ b/tools/compiler/tests/test_get_chain_configs.rs @@ -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); @@ -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( @@ -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( diff --git a/tools/compiler/tests/test_processor.rs b/tools/compiler/tests/test_processor.rs index dc0fe1d..c04d6fc 100644 --- a/tools/compiler/tests/test_processor.rs +++ b/tools/compiler/tests/test_processor.rs @@ -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) -> HashMap { + input.into_iter() + .filter_map(|(key, value)| { + value.parse::().ok().map(|parsed_value| (key, parsed_value)) + }) + .collect() +} + #[test] fn base64_id_extracts_correctly() { let asset_json = r#" @@ -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#" { @@ -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); }