From 9ea64b47dc4e7a8e12510eff42246f8b21fd08e0 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 8 Jan 2019 17:37:34 +1100 Subject: [PATCH] Add additional block_store test. --- lighthouse/db/src/stores/beacon_block_store.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 73fc9125ba..6477573e8e 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -100,6 +100,22 @@ mod tests { test_crud_for_store!(BeaconBlockStore, DB_COLUMN); + #[test] + fn head_hash_slot_too_low() { + let db = Arc::new(MemoryDB::open()); + let bs = Arc::new(BeaconBlockStore::new(db.clone())); + let mut rng = XorShiftRng::from_seed([42; 16]); + + let mut block = BeaconBlock::random_for_test(&mut rng); + block.slot = 10; + + let block_root = block.canonical_root(); + bs.put(&block_root, &ssz_encode(&block)).unwrap(); + + let result = bs.block_at_slot(&block_root, 11).unwrap(); + assert_eq!(result, None); + } + #[test] fn test_invalid_block_at_slot() { let db = Arc::new(MemoryDB::open());