diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index ebc76d72bea..ff93e6685ee 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -171,7 +171,7 @@ fn do_chanmon_claim_value_coop_close(anchors: bool) { user_config.manually_accept_inbound_channels = true; } let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config), Some(user_config)]); - let nodes = create_network(2, &node_cfgs, &node_chanmgrs); + let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000); @@ -282,8 +282,10 @@ fn do_chanmon_claim_value_coop_close(anchors: bool) { connect_blocks(&nodes[0], 2017); // Second call after 2016+ blocks, should archive the monitor nodes[0].chain_monitor.chain_monitor.archive_stale_channel_monitors(vec![funding_outpoint]); + assert!(nodes[0].chain_monitor.chain_monitor.get_and_clear_pending_events().is_empty()); assert_eq!(nodes[0].chain_monitor.chain_monitor.list_monitors().len(), 0); - // failing on test exit while dropping the node + // reset watched_outputs and txn + nodes.get_mut(0).unwrap().chain_source.reset_watched_txn_and_outputs(funding_outpoint, funding_tx.txid(), funding_tx.output[0].script_pubkey.clone()); } #[test] diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 3bab53ccac3..e4c84fc6bc2 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -1388,6 +1388,10 @@ impl TestChainSource { watched_outputs: Mutex::new(new_hash_set()), } } + pub fn reset_watched_txn_and_outputs(&self, outpoint: OutPoint, txid: Txid, script_pubkey: ScriptBuf) { + self.watched_outputs.lock().unwrap().remove(&(outpoint, script_pubkey.clone())); + self.watched_txn.lock().unwrap().remove(&(txid, script_pubkey)); + } } impl UtxoLookup for TestChainSource {