Skip to content

Commit ac902c4

Browse files
authored
genesis-config: add compatibility tests (#321)
1 parent a919eeb commit ac902c4

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

genesis-config/src/lib.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ impl fmt::Display for GenesisConfig {
270270

271271
#[cfg(all(feature = "serde", test))]
272272
mod tests {
273-
use {super::*, solana_signer::Signer, std::path::PathBuf};
273+
use {
274+
super::*,
275+
solana_signer::Signer,
276+
std::{path::PathBuf, str::FromStr},
277+
};
274278

275279
fn make_tmp_path(name: &str) -> PathBuf {
276280
let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());
@@ -292,6 +296,22 @@ mod tests {
292296
path
293297
}
294298

299+
#[test]
300+
fn cluster_compatibility() {
301+
for cluster in ["devnet", "testnet", "mainnet-beta"] {
302+
let ledger_path = PathBuf::from(format!("tests/fixtures/{cluster}"));
303+
let genesis_config = GenesisConfig::load(&ledger_path).unwrap();
304+
let cluster_type = ClusterType::from_str(cluster).unwrap();
305+
let expected_hash = cluster_type.get_genesis_hash().unwrap();
306+
307+
assert_eq!(
308+
expected_hash,
309+
genesis_config.hash(),
310+
"{cluster} genesis hash mismatch",
311+
);
312+
}
313+
}
314+
295315
#[test]
296316
fn test_genesis_config() {
297317
let faucet_keypair = Keypair::new();
117 KB
Binary file not shown.
129 KB
Binary file not shown.
184 KB
Binary file not shown.

0 commit comments

Comments
 (0)