Skip to content

Commit deef3a8

Browse files
committed
unit tests
1 parent 9a87865 commit deef3a8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

consensus/types/src/core/config_and_preset.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,25 @@ mod test {
190190
serde_yaml::from_reader(reader).expect("error while deserializing");
191191
assert_eq!(ConfigAndPreset::Gloas(from), yamlconfig);
192192
}
193+
194+
// This is not exhaustive, but it can be extended as new fields are added to the spec.
195+
#[test]
196+
fn test_required_spec_fields_exist() {
197+
let mainnet_spec = ChainSpec::mainnet();
198+
let config = ConfigAndPreset::from_chain_spec::<MainnetEthSpec>(&mainnet_spec);
199+
let json = serde_json::to_value(&config).expect("should serialize");
200+
let obj = json.as_object().expect("should be an object");
201+
let required_fields = [
202+
"SLOT_DURATION_MS",
203+
"PROPOSER_REORG_CUTOFF_BPS",
204+
"ATTESTATION_DUE_BPS",
205+
"AGGREGATE_DUE_BPS",
206+
"CONTRIBUTION_DUE_BPS",
207+
"SYNC_MESSAGE_DUE_BPS",
208+
];
209+
for field in required_fields {
210+
assert!(obj.contains_key(field), "Missing required field: {}", field);
211+
}
212+
}
193213
}
214+

0 commit comments

Comments
 (0)