Skip to content

Commit 5ce0d7e

Browse files
committed
Added tests for genesis chain loading
1 parent 9e6df48 commit 5ce0d7e

File tree

1 file changed

+36
-0
lines changed
  • crates/taiko/chainspec/src

1 file changed

+36
-0
lines changed

crates/taiko/chainspec/src/lib.rs

+36
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,39 @@ impl From<Genesis> for TaikoChainSpec {
387387
}
388388
}
389389
}
390+
391+
#[cfg(test)]
392+
mod tests {
393+
use super::*;
394+
395+
#[test]
396+
fn test_genesis() {
397+
let load_genesis = |chain: Chain| {
398+
let alloc_str = match chain {
399+
CHAIN_MAINNET => {
400+
include_str!("../res/genesis/mainnet.json")
401+
}
402+
CHAIN_INTERNAL_TESTNET => {
403+
include_str!("../res/genesis/internal_l2a.json")
404+
}
405+
CHAIN_KATLA_TESTNET => include_str!("../res/genesis/katla.json"),
406+
CHAIN_HEKLA_TESTNET => include_str!("../res/genesis/hekla.json"),
407+
CHAIN_PERCONF_DEVNET => include_str!("../res/genesis/preconf_devnet.json"),
408+
_ => panic!("Invalid chain"),
409+
};
410+
let _alloc: BTreeMap<Address, TaikoGenesisAccount> =
411+
serde_json::from_str(alloc_str).expect("Invalid alloc json");
412+
println!("Genesis: {_alloc:?}");
413+
};
414+
415+
for chain in [
416+
CHAIN_MAINNET,
417+
CHAIN_INTERNAL_TESTNET,
418+
CHAIN_KATLA_TESTNET,
419+
CHAIN_HEKLA_TESTNET,
420+
CHAIN_PERCONF_DEVNET,
421+
] {
422+
load_genesis(chain);
423+
}
424+
}
425+
}

0 commit comments

Comments
 (0)