From 1fabc7e0ab133f27a0453a7d2d52a6339705d603 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 23 Jan 2019 09:32:32 +1100 Subject: [PATCH] Add Hash to beacon_block_store errors --- beacon_node/db/src/stores/beacon_block_store.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/beacon_node/db/src/stores/beacon_block_store.rs b/beacon_node/db/src/stores/beacon_block_store.rs index 6477573e8..3ec558c93 100644 --- a/beacon_node/db/src/stores/beacon_block_store.rs +++ b/beacon_node/db/src/stores/beacon_block_store.rs @@ -6,8 +6,8 @@ use types::{readers::BeaconBlockReader, BeaconBlock, Hash256}; #[derive(Clone, Debug, PartialEq)] pub enum BeaconBlockAtSlotError { - UnknownBeaconBlock, - InvalidBeaconBlock, + UnknownBeaconBlock(Hash256), + InvalidBeaconBlock(Hash256), DBError(String), } @@ -73,7 +73,7 @@ impl BeaconBlockStore { current_hash = block_reader.parent_root(); } } else { - break Err(BeaconBlockAtSlotError::UnknownBeaconBlock); + break Err(BeaconBlockAtSlotError::UnknownBeaconBlock(current_hash)); } } } @@ -145,7 +145,7 @@ mod tests { db.put(DB_COLUMN, hash, ssz).unwrap(); assert_eq!( store.block_at_slot(other_hash, 42), - Err(BeaconBlockAtSlotError::UnknownBeaconBlock) + Err(BeaconBlockAtSlotError::UnknownBeaconBlock(*other_hash)) ); } @@ -243,7 +243,11 @@ mod tests { let ssz = bs.block_at_slot(&hashes[4], 6).unwrap(); assert_eq!(ssz, None); - let ssz = bs.block_at_slot(&Hash256::from("unknown".as_bytes()), 2); - assert_eq!(ssz, Err(BeaconBlockAtSlotError::UnknownBeaconBlock)); + let bad_hash = &Hash256::from("unknown".as_bytes()); + let ssz = bs.block_at_slot(bad_hash, 2); + assert_eq!( + ssz, + Err(BeaconBlockAtSlotError::UnknownBeaconBlock(*bad_hash)) + ); } }