fix: Compare lowercase component IDs

- This was failing. Make this more lenient so the user can specify component id in the test file in a non-case-sensitive manner.
- Also switched around a wrong token order which was causing a failure (not sure we care about token order but we may in the future? Python didn't care...)
This commit is contained in:
TAMARA LIPOWSKI
2025-09-17 18:20:13 -04:00
committed by Tamara
parent 779c690b6d
commit 0226bda482
3 changed files with 8 additions and 8 deletions

View File

@@ -28,8 +28,8 @@ impl ProtocolComponentExpectation {
pub fn compare(&self, other: &ProtocolComponent, colorize_output: bool) -> Option<String> { pub fn compare(&self, other: &ProtocolComponent, colorize_output: bool) -> Option<String> {
let mut diffs = Vec::new(); let mut diffs = Vec::new();
// Compare id // Compare id (case-insensitive)
if self.id != other.id { if self.id.to_lowercase() != other.id.to_lowercase() {
let diff = self.format_diff("id", &self.id, &other.id, colorize_output); let diff = self.format_diff("id", &self.id, &other.id, colorize_output);
diffs.push(format!("Field 'id' mismatch for {}:\n{}", self.id, diff)); diffs.push(format!("Field 'id' mismatch for {}:\n{}", self.id, diff));
} }

View File

@@ -257,7 +257,7 @@ fn validate_state(
let expected_ids = expected_components let expected_ids = expected_components
.iter() .iter()
.map(|c| c.base.id.clone()) .map(|c| c.base.id.to_lowercase())
.collect::<Vec<String>>(); .collect::<Vec<String>>();
let protocol_states = rt let protocol_states = rt
@@ -274,12 +274,12 @@ fn validate_state(
let components_by_id: HashMap<String, ProtocolComponent> = protocol_components let components_by_id: HashMap<String, ProtocolComponent> = protocol_components
.clone() .clone()
.into_iter() .into_iter()
.map(|c| (c.id.clone(), c)) .map(|c| (c.id.to_lowercase(), c))
.collect(); .collect();
let protocol_states_by_id: HashMap<String, ResponseProtocolState> = protocol_states let protocol_states_by_id: HashMap<String, ResponseProtocolState> = protocol_states
.into_iter() .into_iter()
.map(|s| (s.component_id.clone(), s)) .map(|s| (s.component_id.to_lowercase(), s))
.collect(); .collect();
info!("Found {} protocol components", components_by_id.len()); info!("Found {} protocol components", components_by_id.len());
@@ -290,7 +290,7 @@ fn validate_state(
// Step 1: Validate that all expected components are present on Tycho after indexing // Step 1: Validate that all expected components are present on Tycho after indexing
debug!("Validating {:?} expected components", expected_components.len()); debug!("Validating {:?} expected components", expected_components.len());
for expected_component in expected_components { for expected_component in expected_components {
let component_id = expected_component.base.id.clone(); let component_id = expected_component.base.id.to_lowercase();
let component = components_by_id let component = components_by_id
.get(&component_id) .get(&component_id)
@@ -366,7 +366,7 @@ fn validate_state(
let simulation_component_ids: std::collections::HashSet<String> = expected_components let simulation_component_ids: std::collections::HashSet<String> = expected_components
.iter() .iter()
.filter(|c| !c.skip_simulation) .filter(|c| !c.skip_simulation)
.map(|c| c.base.id.clone()) .map(|c| c.base.id.to_lowercase())
.collect(); .collect();
info!("Components to simulate: {}", simulation_component_ids.len()); info!("Components to simulate: {}", simulation_component_ids.len());

View File

@@ -68,8 +68,8 @@ tests:
expected_components: expected_components:
- id: "0xf91c11BA4220b7a72E1dc5E92f2b48D3fdF62726" - id: "0xf91c11BA4220b7a72E1dc5E92f2b48D3fdF62726"
tokens: tokens:
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
- "0x440017A1b021006d556d7fc06A54c32E42Eb745B" - "0x440017A1b021006d556d7fc06A54c32E42Eb745B"
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
static_attributes: static_attributes:
pool_type: "0x5765696768746564506f6f6c466163746f7279" pool_type: "0x5765696768746564506f6f6c466163746f7279"
manual_updates: "0x01" manual_updates: "0x01"