use super::*; use alloy_primitives::U256; use serde::Deserialize; use std::marker::PhantomData; use types::DataColumnSubnetId; #[derive(Debug, Clone, Deserialize)] #[serde(bound = "E: EthSpec", deny_unknown_fields)] pub struct GetCustodyColumns { pub node_id: String, pub custody_subnet_count: u64, pub result: Vec, #[serde(skip)] _phantom: PhantomData, } impl LoadCase for GetCustodyColumns { fn load_from_dir(path: &Path, _fork_name: ForkName) -> Result { decode::yaml_decode_file(path.join("meta.yaml").as_path()) } } impl Case for GetCustodyColumns { fn is_enabled_for_fork(_fork_name: ForkName) -> bool { false } fn is_enabled_for_feature(feature_name: FeatureName) -> bool { feature_name == FeatureName::Eip7594 } fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> { let spec = E::default_spec(); let node_id = U256::from_str_radix(&self.node_id, 10) .map_err(|e| Error::FailedToParseTest(format!("{e:?}")))?; let raw_node_id = node_id.to_be_bytes::<32>(); let computed = DataColumnSubnetId::compute_custody_columns::( raw_node_id, self.custody_subnet_count, &spec, ) .expect("should compute custody columns") .collect::>(); let expected = &self.result; if computed == *expected { Ok(()) } else { Err(Error::NotEqual(format!( "Got {computed:?}\nExpected {expected:?}" ))) } } }