Skip to content

Commit a178a7e

Browse files
committed
f Test fixed unconf_height behavior
1 parent 0fe555b commit a178a7e

File tree

1 file changed

+17
-1
lines changed
  • lightning-background-processor/src

1 file changed

+17
-1
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,11 @@ impl Drop for BackgroundProcessor {
919919

920920
#[cfg(all(feature = "std", test))]
921921
mod tests {
922-
use bitcoin::ScriptBuf;
922+
use bitcoin::{ScriptBuf, Txid};
923923
use bitcoin::blockdata::constants::{genesis_block, ChainHash};
924924
use bitcoin::blockdata::locktime::absolute::LockTime;
925925
use bitcoin::blockdata::transaction::{Transaction, TxOut};
926+
use bitcoin::hashes::Hash;
926927
use bitcoin::network::constants::Network;
927928
use bitcoin::secp256k1::{SecretKey, PublicKey, Secp256k1};
928929
use lightning::chain::{BestBlock, Confirm, chainmonitor, Filter};
@@ -1731,6 +1732,21 @@ mod tests {
17311732
_ => panic!("Unexpected status"),
17321733
}
17331734

1735+
// Check we still see the transaction as confirmed if we unconfirm any untracked
1736+
// transaction. (We previously had a bug that would mark tracked transactions as
1737+
// unconfirmed if any transaction at an unknown block height would be unconfirmed.)
1738+
let unconf_txid = Txid::from_slice(&[0; 32]).unwrap();
1739+
nodes[0].sweeper.transaction_unconfirmed(&unconf_txid);
1740+
1741+
assert_eq!(nodes[0].sweeper.tracked_spendable_outputs().len(), 1);
1742+
let tracked_output = nodes[0].sweeper.tracked_spendable_outputs().first().unwrap().clone();
1743+
match tracked_output.status {
1744+
OutputSpendStatus::PendingThresholdConfirmations { latest_spending_tx, .. } => {
1745+
assert_eq!(sweep_tx_2.txid(), latest_spending_tx.txid());
1746+
}
1747+
_ => panic!("Unexpected status"),
1748+
}
1749+
17341750
// Check we stop tracking the spendable outputs when one of the txs reaches
17351751
// ANTI_REORG_DELAY confirmations.
17361752
confirm_transaction_depth(&mut nodes[0], &sweep_tx_0, ANTI_REORG_DELAY);

0 commit comments

Comments
 (0)