Created
April 26, 2021 18:09
-
-
Save rauljordan/32f723dc0e342fa7f54783f84dd6818f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn check_against_prysm() { | |
let mut tree = DepositDataTree::create(&[], 0, DEPOSIT_TREE_DEPTH); | |
let mut deposit_count = 0; | |
if let Ok(lines) = read_lines("/tmp/temp.txt") { | |
for line in lines { | |
if let Ok(raw_line_string) = line { | |
let deposit_line: Vec<&str> = raw_line_string.split(",").collect(); | |
let deposit_data_root = deposit_line[0]; | |
let deposit_index = deposit_line[1]; | |
let deposit_root = deposit_line[2]; | |
match deposit_data_root.strip_prefix("0x") { | |
Some(stripped) => { | |
let decoded = hex::decode(stripped).expect("Failed to parse hex as bytes"); | |
println!("Inserting deposit with index {}", deposit_index); | |
tree.push_leaf(Hash256::from_slice(&decoded)); | |
let received_root = tree.root(); | |
println!("For deposit index {}, wanted root {}, got {} from tree", deposit_index, deposit_root, received_root); | |
assert_eq!(format!("Ox{}", hex::encode(received_root)), deposit_root); | |
deposit_count += 1; | |
} | |
None => panic!("Something went wrong") | |
} | |
} | |
} | |
} | |
println!("Inserted {} deposits with deposit tree root as 0x{}", deposit_count, hex::encode(tree.root())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment