Skip to content

Commit 007c5a7

Browse files
populate_test_db accepts a coinbase param
Allows user to ask for a test db populated with clean coins from coinbases. This is useful for testing the wallet behaviour when some inputs are coinbases.
1 parent a7859d4 commit 007c5a7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/database/memory.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,23 @@ impl ConfigurableDatabase for MemoryDatabase {
486486
/// don't have `test` set.
487487
macro_rules! populate_test_db {
488488
($db:expr, $tx_meta:expr, $current_height:expr$(,)?) => {{
489+
$crate::populate_test_db!($db, $tx_meta, $current_height, (@coinbase false))
490+
}};
491+
($db:expr, $tx_meta:expr, $current_height:expr, (@coinbase $is_coinbase:expr)$(,)?) => {{
489492
use std::str::FromStr;
490493
use $crate::database::BatchOperations;
491494
let mut db = $db;
492495
let tx_meta = $tx_meta;
493496
let current_height: Option<u32> = $current_height;
497+
let input = if $is_coinbase {
498+
vec![$crate::bitcoin::TxIn::default()]
499+
} else {
500+
vec![]
501+
};
494502
let tx = $crate::bitcoin::Transaction {
495503
version: 1,
496504
lock_time: 0,
497-
input: vec![],
505+
input,
498506
output: tx_meta
499507
.output
500508
.iter()

0 commit comments

Comments
 (0)