mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Cleanup db directory after tests (#2752)
* Cleanup db directory after tests * Fix clean output dir windows * Remove behind chain tests
This commit is contained in:
parent
e8c50359e4
commit
606b4652f8
9 changed files with 1041 additions and 973 deletions
|
@ -112,6 +112,8 @@ fn data_files() {
|
||||||
let chain = reload_chain(chain_dir);
|
let chain = reload_chain(chain_dir);
|
||||||
chain.validate(false).unwrap();
|
chain.validate(false).unwrap();
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(chain_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _prepare_block(kc: &ExtKeychain, prev: &BlockHeader, chain: &Chain, diff: u64) -> Block {
|
fn _prepare_block(kc: &ExtKeychain, prev: &BlockHeader, chain: &Chain, diff: u64) -> Block {
|
||||||
|
|
|
@ -59,8 +59,12 @@ fn setup(dir_name: &str, genesis: Block) -> Chain {
|
||||||
fn mine_empty_chain() {
|
fn mine_empty_chain() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
let keychain = keychain::ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
{
|
||||||
mine_some_on_top(".grin", pow::mine_genesis_block().unwrap(), &keychain);
|
mine_some_on_top(".grin", pow::mine_genesis_block().unwrap(), &keychain);
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mine_genesis_reward_chain() {
|
fn mine_genesis_reward_chain() {
|
||||||
|
@ -73,9 +77,10 @@ fn mine_genesis_reward_chain() {
|
||||||
let reward = reward::output(&keychain, &key_id, 0).unwrap();
|
let reward = reward::output(&keychain, &key_id, 0).unwrap();
|
||||||
genesis = genesis.with_reward(reward.0, reward.1);
|
genesis = genesis.with_reward(reward.0, reward.1);
|
||||||
|
|
||||||
|
let tmp_chain_dir = ".grin.tmp";
|
||||||
{
|
{
|
||||||
// setup a tmp chain to hande tx hashsets
|
// setup a tmp chain to hande tx hashsets
|
||||||
let tmp_chain = setup(".grin.tmp", pow::mine_genesis_block().unwrap());
|
let tmp_chain = setup(tmp_chain_dir, pow::mine_genesis_block().unwrap());
|
||||||
tmp_chain.set_txhashset_roots(&mut genesis).unwrap();
|
tmp_chain.set_txhashset_roots(&mut genesis).unwrap();
|
||||||
genesis.header.output_mmr_size = 1;
|
genesis.header.output_mmr_size = 1;
|
||||||
genesis.header.kernel_mmr_size = 1;
|
genesis.header.kernel_mmr_size = 1;
|
||||||
|
@ -91,6 +96,9 @@ fn mine_genesis_reward_chain() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
mine_some_on_top(".grin.genesis", genesis, &keychain);
|
mine_some_on_top(".grin.genesis", genesis, &keychain);
|
||||||
|
// Cleanup chain directories
|
||||||
|
clean_output_dir(tmp_chain_dir);
|
||||||
|
clean_output_dir(".grin.genesis");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mine_some_on_top<K>(dir: &str, genesis: Block, keychain: &K)
|
fn mine_some_on_top<K>(dir: &str, genesis: Block, keychain: &K)
|
||||||
|
@ -157,6 +165,7 @@ where
|
||||||
#[test]
|
#[test]
|
||||||
fn mine_forks() {
|
fn mine_forks() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
|
{
|
||||||
let chain = setup(".grin2", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin2", pow::mine_genesis_block().unwrap());
|
||||||
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
|
||||||
|
@ -196,11 +205,15 @@ fn mine_forks() {
|
||||||
assert_eq!(head.prev_block_h, prev.hash());
|
assert_eq!(head.prev_block_h, prev.hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin2");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mine_losing_fork() {
|
fn mine_losing_fork() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
{
|
||||||
let chain = setup(".grin3", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin3", pow::mine_genesis_block().unwrap());
|
||||||
|
|
||||||
// add a first block we'll be forking from
|
// add a first block we'll be forking from
|
||||||
|
@ -228,6 +241,9 @@ fn mine_losing_fork() {
|
||||||
chain.process_block(b3, chain::Options::SKIP_POW).unwrap();
|
chain.process_block(b3, chain::Options::SKIP_POW).unwrap();
|
||||||
assert_eq!(chain.head_header().unwrap().hash(), b3head.hash());
|
assert_eq!(chain.head_header().unwrap().hash(), b3head.hash());
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin3");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn longer_fork() {
|
fn longer_fork() {
|
||||||
|
@ -237,6 +253,7 @@ fn longer_fork() {
|
||||||
// prepare 2 chains, the 2nd will be have the forked blocks we can
|
// prepare 2 chains, the 2nd will be have the forked blocks we can
|
||||||
// then send back on the 1st
|
// then send back on the 1st
|
||||||
let genesis = pow::mine_genesis_block().unwrap();
|
let genesis = pow::mine_genesis_block().unwrap();
|
||||||
|
{
|
||||||
let chain = setup(".grin4", genesis.clone());
|
let chain = setup(".grin4", genesis.clone());
|
||||||
|
|
||||||
// add blocks to both chains, 20 on the main one, only the first 5
|
// add blocks to both chains, 20 on the main one, only the first 5
|
||||||
|
@ -268,11 +285,15 @@ fn longer_fork() {
|
||||||
assert_eq!(head.height, 12);
|
assert_eq!(head.height, 12);
|
||||||
assert_eq!(head.hash(), new_head.hash());
|
assert_eq!(head.hash(), new_head.hash());
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin4");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn spend_in_fork_and_compact() {
|
fn spend_in_fork_and_compact() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
|
{
|
||||||
let chain = setup(".grin6", pow::mine_genesis_block().unwrap());
|
let chain = setup(".grin6", pow::mine_genesis_block().unwrap());
|
||||||
let prev = chain.head_header().unwrap();
|
let prev = chain.head_header().unwrap();
|
||||||
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
let kc = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
|
@ -395,11 +416,15 @@ fn spend_in_fork_and_compact() {
|
||||||
panic!("Validation error after compacting chain: {:?}", e);
|
panic!("Validation error after compacting chain: {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin6");
|
||||||
|
}
|
||||||
|
|
||||||
/// Test ability to retrieve block headers for a given output
|
/// Test ability to retrieve block headers for a given output
|
||||||
#[test]
|
#[test]
|
||||||
fn output_header_mappings() {
|
fn output_header_mappings() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
|
{
|
||||||
let chain = setup(
|
let chain = setup(
|
||||||
".grin_header_for_output",
|
".grin_header_for_output",
|
||||||
pow::mine_genesis_block().unwrap(),
|
pow::mine_genesis_block().unwrap(),
|
||||||
|
@ -454,6 +479,9 @@ fn output_header_mappings() {
|
||||||
assert_eq!(header_for_output.height, n as u64);
|
assert_eq!(header_for_output.height, n as u64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(".grin_header_for_output");
|
||||||
|
}
|
||||||
|
|
||||||
fn prepare_block<K>(kc: &K, prev: &BlockHeader, chain: &Chain, diff: u64) -> Block
|
fn prepare_block<K>(kc: &K, prev: &BlockHeader, chain: &Chain, diff: u64) -> Block
|
||||||
where
|
where
|
||||||
|
|
|
@ -53,6 +53,8 @@ fn test_various_store_indices() {
|
||||||
|
|
||||||
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
let keychain = ExtKeychain::from_random_seed(false).unwrap();
|
||||||
let key_id = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let key_id = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
|
|
||||||
|
{
|
||||||
let db_env = Arc::new(store::new_env(chain_dir.to_string()));
|
let db_env = Arc::new(store::new_env(chain_dir.to_string()));
|
||||||
|
|
||||||
let chain_store = Arc::new(chain::store::ChainStore::new(db_env).unwrap());
|
let chain_store = Arc::new(chain::store::ChainStore::new(db_env).unwrap());
|
||||||
|
@ -98,3 +100,6 @@ fn test_various_store_indices() {
|
||||||
assert!(chain_store.get_block(&block_hash).is_ok());
|
assert!(chain_store.get_block(&block_hash).is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(chain_dir);
|
||||||
|
}
|
||||||
|
|
|
@ -38,16 +38,18 @@ fn clean_output_dir(dir_name: &str) {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_coinbase_maturity() {
|
fn test_coinbase_maturity() {
|
||||||
let _ = env_logger::init();
|
let _ = env_logger::init();
|
||||||
clean_output_dir(".grin");
|
let chain_dir = ".grin_coinbase";
|
||||||
|
clean_output_dir(chain_dir);
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let genesis_block = pow::mine_genesis_block().unwrap();
|
let genesis_block = pow::mine_genesis_block().unwrap();
|
||||||
|
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
|
|
||||||
let db_env = Arc::new(store::new_env(".grin".to_string()));
|
{
|
||||||
|
let db_env = Arc::new(store::new_env(chain_dir.to_string()));
|
||||||
let chain = chain::Chain::init(
|
let chain = chain::Chain::init(
|
||||||
".grin".to_string(),
|
chain_dir.to_string(),
|
||||||
db_env,
|
db_env,
|
||||||
Arc::new(NoopAdapter {}),
|
Arc::new(NoopAdapter {}),
|
||||||
genesis_block,
|
genesis_block,
|
||||||
|
@ -146,7 +148,8 @@ fn test_coinbase_maturity() {
|
||||||
let pk = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
let pk = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier();
|
||||||
|
|
||||||
let reward = libtx::reward::output(&keychain, &pk, 0).unwrap();
|
let reward = libtx::reward::output(&keychain, &pk, 0).unwrap();
|
||||||
let mut block = core::core::Block::new(&prev, vec![], Difficulty::min(), reward).unwrap();
|
let mut block =
|
||||||
|
core::core::Block::new(&prev, vec![], Difficulty::min(), reward).unwrap();
|
||||||
let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter().unwrap());
|
let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter().unwrap());
|
||||||
block.header.timestamp = prev.timestamp + Duration::seconds(60);
|
block.header.timestamp = prev.timestamp + Duration::seconds(60);
|
||||||
block.header.pow.secondary_scaling = next_header_info.secondary_scaling;
|
block.header.pow.secondary_scaling = next_header_info.secondary_scaling;
|
||||||
|
@ -195,3 +198,6 @@ fn test_coinbase_maturity() {
|
||||||
Err(_) => panic!("we did not expect an error here"),
|
Err(_) => panic!("we did not expect an error here"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(chain_dir);
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ fn test_unexpected_zip() {
|
||||||
|
|
||||||
let db_root = format!(".grin_txhashset_zip");
|
let db_root = format!(".grin_txhashset_zip");
|
||||||
clean_output_dir(&db_root);
|
clean_output_dir(&db_root);
|
||||||
|
{
|
||||||
let db_env = Arc::new(store::new_env(db_root.clone()));
|
let db_env = Arc::new(store::new_env(db_root.clone()));
|
||||||
let chain_store = ChainStore::new(db_env).unwrap();
|
let chain_store = ChainStore::new(db_env).unwrap();
|
||||||
let store = Arc::new(chain_store);
|
let store = Arc::new(chain_store);
|
||||||
|
@ -83,6 +84,9 @@ fn test_unexpected_zip() {
|
||||||
));
|
));
|
||||||
fs::remove_dir_all(Path::new(&db_root).join("txhashset")).unwrap();
|
fs::remove_dir_all(Path::new(&db_root).join("txhashset")).unwrap();
|
||||||
}
|
}
|
||||||
|
// Cleanup chain directory
|
||||||
|
clean_output_dir(&db_root);
|
||||||
|
}
|
||||||
|
|
||||||
fn write_file(db_root: String) {
|
fn write_file(db_root: String) {
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
|
|
|
@ -34,13 +34,15 @@ fn test_transaction_pool_block_building() {
|
||||||
|
|
||||||
let db_root = ".grin_block_building".to_string();
|
let db_root = ".grin_block_building".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
{
|
||||||
let mut chain = ChainAdapter::init(db_root.clone()).unwrap();
|
let mut chain = ChainAdapter::init(db_root.clone()).unwrap();
|
||||||
|
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
|
|
||||||
// Initialize the chain/txhashset with an initial block
|
// Initialize the chain/txhashset with an initial block
|
||||||
// so we have a non-empty UTXO set.
|
// so we have a non-empty UTXO set.
|
||||||
let add_block = |prev_header: BlockHeader, txs: Vec<Transaction>, chain: &mut ChainAdapter| {
|
let add_block =
|
||||||
|
|prev_header: BlockHeader, txs: Vec<Transaction>, chain: &mut ChainAdapter| {
|
||||||
let height = prev_header.height + 1;
|
let height = prev_header.height + 1;
|
||||||
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
||||||
let fee = txs.iter().map(|x| x.fee()).sum();
|
let fee = txs.iter().map(|x| x.fee()).sum();
|
||||||
|
@ -59,7 +61,8 @@ fn test_transaction_pool_block_building() {
|
||||||
|
|
||||||
// Now create tx to spend that first coinbase (now matured).
|
// Now create tx to spend that first coinbase (now matured).
|
||||||
// Provides us with some useful outputs to test with.
|
// Provides us with some useful outputs to test with.
|
||||||
let initial_tx = test_transaction_spending_coinbase(&keychain, &header, vec![10, 20, 30, 40]);
|
let initial_tx =
|
||||||
|
test_transaction_spending_coinbase(&keychain, &header, vec![10, 20, 30, 40]);
|
||||||
|
|
||||||
// Mine that initial tx so we can spend it with multiple txs
|
// Mine that initial tx so we can spend it with multiple txs
|
||||||
let block = add_block(header, vec![initial_tx], &mut chain);
|
let block = add_block(header, vec![initial_tx], &mut chain);
|
||||||
|
@ -118,3 +121,6 @@ fn test_transaction_pool_block_building() {
|
||||||
assert_eq!(write_pool.total_size(), 0);
|
assert_eq!(write_pool.total_size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup db directory
|
||||||
|
clean_output_dir(db_root.clone());
|
||||||
|
}
|
||||||
|
|
|
@ -40,12 +40,14 @@ fn test_block_building_max_weight() {
|
||||||
let db_root = ".grin_block_building_max_weight".to_string();
|
let db_root = ".grin_block_building_max_weight".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
|
||||||
|
{
|
||||||
let mut chain = ChainAdapter::init(db_root.clone()).unwrap();
|
let mut chain = ChainAdapter::init(db_root.clone()).unwrap();
|
||||||
|
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
|
|
||||||
// Convenient was to add a new block to the chain.
|
// Convenient was to add a new block to the chain.
|
||||||
let add_block = |prev_header: BlockHeader, txs: Vec<Transaction>, chain: &mut ChainAdapter| {
|
let add_block =
|
||||||
|
|prev_header: BlockHeader, txs: Vec<Transaction>, chain: &mut ChainAdapter| {
|
||||||
let height = prev_header.height + 1;
|
let height = prev_header.height + 1;
|
||||||
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
||||||
let fee = txs.iter().map(|x| x.fee()).sum();
|
let fee = txs.iter().map(|x| x.fee()).sum();
|
||||||
|
@ -66,7 +68,8 @@ fn test_block_building_max_weight() {
|
||||||
|
|
||||||
// Now create tx to spend that first coinbase (now matured).
|
// Now create tx to spend that first coinbase (now matured).
|
||||||
// Provides us with some useful outputs to test with.
|
// Provides us with some useful outputs to test with.
|
||||||
let initial_tx = test_transaction_spending_coinbase(&keychain, &header, vec![100, 200, 300]);
|
let initial_tx =
|
||||||
|
test_transaction_spending_coinbase(&keychain, &header, vec![100, 200, 300]);
|
||||||
|
|
||||||
// Mine that initial tx so we can spend it with multiple txs
|
// Mine that initial tx so we can spend it with multiple txs
|
||||||
let block = add_block(header, vec![initial_tx], &mut chain);
|
let block = add_block(header, vec![initial_tx], &mut chain);
|
||||||
|
@ -141,3 +144,6 @@ fn test_block_building_max_weight() {
|
||||||
assert_eq!(write_pool.total_size(), 2);
|
assert_eq!(write_pool.total_size(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup db directory
|
||||||
|
clean_output_dir(db_root.clone());
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ fn test_transaction_pool_block_reconciliation() {
|
||||||
|
|
||||||
let db_root = ".grin_block_reconciliation".to_string();
|
let db_root = ".grin_block_reconciliation".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
{
|
||||||
let chain = Arc::new(ChainAdapter::init(db_root.clone()).unwrap());
|
let chain = Arc::new(ChainAdapter::init(db_root.clone()).unwrap());
|
||||||
|
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
|
@ -58,13 +59,15 @@ fn test_transaction_pool_block_reconciliation() {
|
||||||
|
|
||||||
// Now create tx to spend that first coinbase (now matured).
|
// Now create tx to spend that first coinbase (now matured).
|
||||||
// Provides us with some useful outputs to test with.
|
// Provides us with some useful outputs to test with.
|
||||||
let initial_tx = test_transaction_spending_coinbase(&keychain, &header, vec![10, 20, 30, 40]);
|
let initial_tx =
|
||||||
|
test_transaction_spending_coinbase(&keychain, &header, vec![10, 20, 30, 40]);
|
||||||
|
|
||||||
let block = {
|
let block = {
|
||||||
let key_id = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, 2, 0, 0, 0);
|
||||||
let fees = initial_tx.fee();
|
let fees = initial_tx.fee();
|
||||||
let reward = libtx::reward::output(&keychain, &key_id, fees).unwrap();
|
let reward = libtx::reward::output(&keychain, &key_id, fees).unwrap();
|
||||||
let mut block = Block::new(&header, vec![initial_tx], Difficulty::min(), reward).unwrap();
|
let mut block =
|
||||||
|
Block::new(&header, vec![initial_tx], Difficulty::min(), reward).unwrap();
|
||||||
|
|
||||||
// Set the prev_root to the prev hash for testing purposes (no MMR to obtain a root from).
|
// Set the prev_root to the prev hash for testing purposes (no MMR to obtain a root from).
|
||||||
block.header.prev_root = header.hash();
|
block.header.prev_root = header.hash();
|
||||||
|
@ -184,3 +187,6 @@ fn test_transaction_pool_block_reconciliation() {
|
||||||
assert_eq!(write_pool.txpool.entries[3].tx, valid_child_valid);
|
assert_eq!(write_pool.txpool.entries[3].tx, valid_child_valid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup db directory
|
||||||
|
clean_output_dir(db_root.clone());
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ fn test_the_transaction_pool() {
|
||||||
|
|
||||||
let db_root = ".grin_transaction_pool".to_string();
|
let db_root = ".grin_transaction_pool".to_string();
|
||||||
clean_output_dir(db_root.clone());
|
clean_output_dir(db_root.clone());
|
||||||
|
{
|
||||||
let chain = Arc::new(ChainAdapter::init(db_root.clone()).unwrap());
|
let chain = Arc::new(ChainAdapter::init(db_root.clone()).unwrap());
|
||||||
|
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
|
@ -44,7 +45,8 @@ fn test_the_transaction_pool() {
|
||||||
let height = 1;
|
let height = 1;
|
||||||
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
let key_id = ExtKeychain::derive_key_id(1, height as u32, 0, 0, 0);
|
||||||
let reward = libtx::reward::output(&keychain, &key_id, 0).unwrap();
|
let reward = libtx::reward::output(&keychain, &key_id, 0).unwrap();
|
||||||
let block = Block::new(&BlockHeader::default(), vec![], Difficulty::min(), reward).unwrap();
|
let block =
|
||||||
|
Block::new(&BlockHeader::default(), vec![], Difficulty::min(), reward).unwrap();
|
||||||
|
|
||||||
chain.update_db_for_block(&block);
|
chain.update_db_for_block(&block);
|
||||||
|
|
||||||
|
@ -251,3 +253,6 @@ fn test_the_transaction_pool() {
|
||||||
.is_err());
|
.is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cleanup db directory
|
||||||
|
clean_output_dir(db_root.clone());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue