use self::core::core::hash::Hashed;
use epic_core as core;
use epic_util as util;
mod chain_test_helper;
use self::chain_test_helper::{clean_output_dir, mine_chain};
#[test]
fn test_store_indices() {
util::init_test_logger();
let chain_dir = ".epic_idx_1";
clean_output_dir(chain_dir);
let chain = mine_chain(chain_dir, 4);
assert_eq!(chain.head().unwrap().height, 3);
assert_eq!(chain.head_header().unwrap().height, 3);
let block_header = chain.get_header_by_height(3).unwrap();
let block_hash = block_header.hash();
assert_eq!(block_hash, chain.head().unwrap().last_block_h);
{
assert_eq!(chain.get_block(&block_hash).unwrap().hash(), block_hash);
assert!(chain.get_block_sums(&block_hash).is_ok());
{
let store = chain.store();
let batch = store.batch().unwrap();
assert!(batch.delete_block(&block_hash).is_ok());
assert!(batch.get_block(&block_hash).is_err());
}
assert!(chain.get_block(&block_hash).is_ok());
}
clean_output_dir(chain_dir);
}