Skip to content

Commit 1912d8d

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 737df0f commit 1912d8d

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
@@ -545,12 +545,16 @@ pub struct TestPersister {
545545
///
546546
/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
547547
pub offchain_monitor_updates: Mutex<HashMap<OutPoint, HashSet<u64>>>,
548+
/// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
549+
/// monitor's funding outpoint here.
550+
pub chain_sync_monitor_persistences: Mutex<VecDeque<OutPoint>>
548551
}
549552
impl TestPersister {
550553
pub fn new() -> Self {
551554
Self {
552555
update_rets: Mutex::new(VecDeque::new()),
553556
offchain_monitor_updates: Mutex::new(new_hash_map()),
557+
chain_sync_monitor_persistences: Mutex::new(VecDeque::new())
554558
}
555559
}
556560

@@ -573,15 +577,18 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> chainmonitor::Persist<Signer> for
573577
ret = update_ret;
574578
}
575579

576-
if let Some(update) = update {
580+
if let Some(update) = update {
577581
self.offchain_monitor_updates.lock().unwrap().entry(funding_txo).or_insert(new_hash_set()).insert(update.update_id);
582+
} else {
583+
self.chain_sync_monitor_persistences.lock().unwrap().push_back(funding_txo);
578584
}
579585
ret
580586
}
581587

582588
fn archive_persisted_channel(&self, funding_txo: OutPoint) {
583-
// remove the channel from the offchain_monitor_updates map
589+
// remove the channel from the offchain_monitor_updates and chain_sync_monitor_persistences.
584590
self.offchain_monitor_updates.lock().unwrap().remove(&funding_txo);
591+
self.chain_sync_monitor_persistences.lock().unwrap().retain(|x| x != &funding_txo);
585592
}
586593
}
587594

0 commit comments

Comments
 (0)