mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
Dump chain to JSON file
This commit is contained in:
@@ -15,4 +15,6 @@ fn it_can_produce_blocks() {
|
||||
let dump = rig.chain_dump().expect("Chain dump failed.");
|
||||
|
||||
assert_eq!(dump.len(), blocks + 1); // + 1 for genesis block.
|
||||
|
||||
rig.dump_to_file("/tmp/chaindump.json".to_string(), &dump);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ use db::{
|
||||
stores::{BeaconBlockStore, BeaconStateStore},
|
||||
MemoryDB,
|
||||
};
|
||||
use serde_json::Result as SerdeResult;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use types::{ChainSpec, Keypair, Validator};
|
||||
|
||||
@@ -87,4 +90,10 @@ impl TestRig {
|
||||
pub fn chain_dump(&self) -> Result<Vec<SlotDump>, DumpError> {
|
||||
self.beacon_chain.chain_dump()
|
||||
}
|
||||
|
||||
pub fn dump_to_file(&self, filename: String, chain_dump: &Vec<SlotDump>) {
|
||||
let json = serde_json::to_string(chain_dump).unwrap();
|
||||
let mut file = File::create(filename).unwrap();
|
||||
file.write_all(json.as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user