none -> 0 for genesis

This commit is contained in:
NikVolf 2016-10-27 14:24:59 +03:00
parent 9fd98e9392
commit a385333d3d
1 changed files with 14 additions and 1 deletions

View File

@ -301,7 +301,7 @@ impl Store for Storage {
if block.hash() == new_best_hash { best_number + 1 }
else { best_number }
},
None => 1,
None => 0,
};
let mut transaction = self.database.transaction();
@ -369,6 +369,19 @@ mod tests {
assert!(Storage::new(path.as_path()).is_ok());
}
#[test]
fn insert_block() {
let path = RandomTempPath::create_dir();
let store = Storage::new(path.as_path()).unwrap();
let block: Block = test_data::block1();
store.insert_block(&block).unwrap();
let loaded_block = store.block(BlockRef::Hash(block.hash())).unwrap();
assert_eq!(loaded_block.hash(), block.hash());
}
#[test]
fn insert_block() {
let path = RandomTempPath::create_dir();