Skip to content

Commit

Permalink
Exhaustive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Nov 19, 2023
1 parent bf08693 commit 37f8f8d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions crates/db-utils/src/leveldb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,24 @@ mod db_test {
use leveldb::{database::Database, options::Options};
use std::path::PathBuf;

const TEST_BLOCK_NO: u64 = 4_061_224;
const BEDROCK_TRANSITION: u64 = 4_061_224;
const FULL_PRUNE_DEPTH: u64 = 90_000;

#[test]
#[ignore]
fn sanity_read_header() {
fn sanity_read_headers() {
let mut db_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
db_path.push("testdata/bedrock/geth/chaindata");

let options = Options::new();
let database: Database<DBKey> = Database::open(db_path.as_path(), options).unwrap();
let reader = GethDBReader::new(database);

dbg!(reader.header_by_number(TEST_BLOCK_NO).unwrap());
for i in BEDROCK_TRANSITION - FULL_PRUNE_DEPTH - 1..=BEDROCK_TRANSITION {
if let Err(e) = reader.header_by_number(i) {
panic!("Error reading header @ block # {}: {}", i, e);
}
}
}

#[test]
Expand All @@ -189,7 +194,12 @@ mod db_test {
let database: Database<DBKey> = Database::open(db_path.as_path(), options).unwrap();
let reader = GethDBReader::new(database);

dbg!(reader.block_by_number(TEST_BLOCK_NO).unwrap());
// TODO: We need to make a patch for legacy deposits, there's no signature in those.
for i in BEDROCK_TRANSITION - FULL_PRUNE_DEPTH - 1..=BEDROCK_TRANSITION {
if let Err(e) = reader.block_by_number(i) {
panic!("Error reading block # {}: {}", i, e);
}
}
}

#[test]
Expand All @@ -202,6 +212,10 @@ mod db_test {
let database: Database<DBKey> = Database::open(db_path.as_path(), options).unwrap();
let reader = GethDBReader::new(database);

dbg!(reader.receipts_by_number(TEST_BLOCK_NO).unwrap());
for i in BEDROCK_TRANSITION - FULL_PRUNE_DEPTH - 1..=BEDROCK_TRANSITION {
if let Err(e) = reader.receipts_by_number(i) {
panic!("Error reading receipts in block # {}: {}", i, e);
}
}
}
}

0 comments on commit 37f8f8d

Please sign in to comment.