Skip to content

Commit 7548cc1

Browse files
committed
f Test SpendingDelay
1 parent 257876f commit 7548cc1

File tree

1 file changed

+16
-2
lines changed
  • lightning-background-processor/src

1 file changed

+16
-2
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ mod tests {
948948
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_KEY,
949949
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
950950
SCORER_PERSISTENCE_PRIMARY_NAMESPACE, SCORER_PERSISTENCE_SECONDARY_NAMESPACE, SCORER_PERSISTENCE_KEY};
951-
use lightning::util::sweep::{OutputSweeper, OutputSpendStatus};
951+
use lightning::util::sweep::{OutputSweeper, OutputSpendStatus, SpendingDelay};
952952
use lightning_persister::fs_store::FilesystemStore;
953953
use std::collections::VecDeque;
954954
use std::{fs, env};
@@ -1664,11 +1664,25 @@ mod tests {
16641664
.expect("Events not handled within deadline");
16651665
match event {
16661666
Event::SpendableOutputs { outputs, channel_id } => {
1667-
nodes[0].sweeper.track_spendable_outputs(outputs, channel_id, false);
1667+
nodes[0].sweeper.track_spendable_outputs(outputs, channel_id, false, Some(SpendingDelay::Relative { num_blocks: 3 }));
16681668
},
16691669
_ => panic!("Unexpected event: {:?}", event),
16701670
}
16711671

1672+
// Check we don't generate an initial sweeping tx until we reach the required height.
1673+
assert_eq!(nodes[0].sweeper.tracked_spendable_outputs().len(), 1);
1674+
let tracked_output = nodes[0].sweeper.tracked_spendable_outputs().first().unwrap().clone();
1675+
let sweep_tx_0 = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
1676+
assert!(!tracked_output.is_spent_in(&sweep_tx_0));
1677+
match tracked_output.status {
1678+
OutputSpendStatus::PendingInitialBroadcast { delayed_until_height } => {
1679+
assert_eq!(delayed_until_height, Some(153));
1680+
}
1681+
_ => panic!("Unexpected status"),
1682+
}
1683+
1684+
advance_chain(&mut nodes[0], 3);
1685+
16721686
// Check we generate an initial sweeping tx.
16731687
assert_eq!(nodes[0].sweeper.tracked_spendable_outputs().len(), 1);
16741688
let tracked_output = nodes[0].sweeper.tracked_spendable_outputs().first().unwrap().clone();

0 commit comments

Comments
 (0)