Skip to content

Commit d917edf

Browse files
committed
Start tracking chain_sync_monitor_persistences in TestPersister
It is helpful to assert that chain-sync did trigger a monitor persist.
1 parent b183367 commit d917edf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lightning/src/util/test_utils.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,16 @@ pub struct TestPersister {
531531
///
532532
/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
533533
pub offchain_monitor_updates: Mutex<HashMap<OutPoint, HashSet<u64>>>,
534+
/// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
535+
/// monitor's funding outpoint here.
536+
pub chain_sync_monitor_persistences: Mutex<VecDeque<OutPoint>>
534537
}
535538
impl TestPersister {
536539
pub fn new() -> Self {
537540
Self {
538541
update_rets: Mutex::new(VecDeque::new()),
539542
offchain_monitor_updates: Mutex::new(new_hash_map()),
543+
chain_sync_monitor_persistences: Mutex::new(VecDeque::new())
540544
}
541545
}
542546

@@ -559,15 +563,18 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> chainmonitor::Persist<Signer> for
559563
ret = update_ret;
560564
}
561565

562-
if let Some(update) = update {
566+
if let Some(update) = update {
563567
self.offchain_monitor_updates.lock().unwrap().entry(funding_txo).or_insert(new_hash_set()).insert(update.update_id);
568+
} else {
569+
self.chain_sync_monitor_persistences.lock().unwrap().push_back(funding_txo);
564570
}
565571
ret
566572
}
567573

568574
fn archive_persisted_channel(&self, funding_txo: OutPoint) {
569-
// remove the channel from the offchain_monitor_updates map
575+
// remove the channel from the offchain_monitor_updates and chain_sync_monitor_persistences.
570576
self.offchain_monitor_updates.lock().unwrap().remove(&funding_txo);
577+
self.chain_sync_monitor_persistences.lock().unwrap().retain(|x| x != &funding_txo);
571578
}
572579
}
573580

0 commit comments

Comments
 (0)