test: fix populate_test_db conf calculation

populate_test_db would previously give back a transaction with N + 1
confirmations when you asked for N.

This commit also fixes test_spend_coinbase, which would improperly
ask for a transaction with 0 confirmations instead of 1.
This commit is contained in:
Daniela Brozzoni 2022-07-01 10:56:48 +02:00
parent 1d9fdd01fa
commit 98748906f6
No known key found for this signature in database
GPG Key ID: 7DE4F1FDCED0AB87
2 changed files with 8 additions and 5 deletions

View File

@ -512,10 +512,13 @@ macro_rules! populate_test_db {
}; };
let txid = tx.txid(); let txid = tx.txid();
let confirmation_time = tx_meta.min_confirmations.map(|conf| $crate::BlockTime { let confirmation_time = tx_meta
height: current_height.unwrap().checked_sub(conf as u32).unwrap(), .min_confirmations
timestamp: 0, .and_then(|v| if v == 0 { None } else { Some(v) })
}); .map(|conf| $crate::BlockTime {
height: current_height.unwrap().checked_sub(conf as u32).unwrap() + 1,
timestamp: 0,
});
let tx_details = $crate::TransactionDetails { let tx_details = $crate::TransactionDetails {
transaction: Some(tx.clone()), transaction: Some(tx.clone()),

View File

@ -4723,7 +4723,7 @@ pub(crate) mod test {
crate::populate_test_db!( crate::populate_test_db!(
wallet.database.borrow_mut(), wallet.database.borrow_mut(),
testutils! (@tx ( (@external descriptors, 0) => 25_000 ) (@confirmations 0)), testutils! (@tx ( (@external descriptors, 0) => 25_000 ) (@confirmations 1)),
Some(confirmation_time), Some(confirmation_time),
(@coinbase true) (@coinbase true)
); );