Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,35 @@ mod tests {
SignetSystemConstants::try_from_genesis(&genesis).unwrap();
}
}

/// Guards against drift between the hardcoded `SignetSystemConstants`
/// statics in `signet-constants` and the bundled genesis JSON files in
/// this crate. The two are parallel definitions of the same config; if
/// they diverge silently, downstream consumers can see different values
/// depending on whether they go through `::mainnet()` or
/// `try_from_genesis`. This test catches the mismatch at CI time.
#[test]
fn static_matches_genesis() {
let cases: &[(KnownChains, SignetSystemConstants)] = &[
(KnownChains::Mainnet, SignetSystemConstants::mainnet()),
(KnownChains::Parmigiana, SignetSystemConstants::parmigiana()),
(KnownChains::Gouda, SignetSystemConstants::gouda()),
#[allow(deprecated)]
(KnownChains::Pecorino, SignetSystemConstants::pecorino()),
(KnownChains::Test, SignetSystemConstants::test()),
];

for (chain, from_static) in cases {
let genesis = GenesisSpec::from(*chain)
.load_genesis()
.expect("load genesis")
.rollup;
let from_genesis = SignetSystemConstants::try_from_genesis(&genesis)
.expect("deserialize signetConstants");
assert_eq!(
from_static, &from_genesis,
"{chain:?}: hardcoded static disagrees with bundled genesis JSON",
);
}
}
}
Loading