Skip to content

Commit 257049d

Browse files
committed
Add test util to handle bump HTLC events
1 parent 55215d0 commit 257049d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::sign::EntropySource;
1515
use crate::chain::channelmonitor::ChannelMonitor;
1616
use crate::chain::transaction::OutPoint;
1717
use crate::events::{ClaimedHTLC, ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, PaymentFailureReason};
18-
use crate::events::bump_transaction::{BumpTransactionEventHandler, Wallet, WalletSource};
18+
use crate::events::bump_transaction::{BumpTransactionEvent, BumpTransactionEventHandler, Wallet, WalletSource};
1919
use crate::ln::{ChannelId, PaymentPreimage, PaymentHash, PaymentSecret};
2020
use crate::ln::channelmanager::{AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, RecipientOnionFields, PaymentId, MIN_CLTV_EXPIRY_DELTA};
2121
use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate};
@@ -1504,6 +1504,21 @@ macro_rules! check_closed_event {
15041504
}
15051505
}
15061506

1507+
pub fn handle_bump_htlc_event(node: &Node, count: usize) {
1508+
let events = node.chain_monitor.chain_monitor.get_and_clear_pending_events();
1509+
assert_eq!(events.len(), count);
1510+
for event in events {
1511+
match event {
1512+
Event::BumpTransaction(bump_event) => {
1513+
if let BumpTransactionEvent::HTLCResolution { .. } = &bump_event {}
1514+
else { panic!(); }
1515+
node.bump_tx_handler.handle_event(&bump_event);
1516+
},
1517+
_ => panic!(),
1518+
}
1519+
}
1520+
}
1521+
15071522
pub fn close_channel<'a, 'b, 'c>(outbound_node: &Node<'a, 'b, 'c>, inbound_node: &Node<'a, 'b, 'c>, channel_id: &ChannelId, funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, Transaction) {
15081523
let (node_a, broadcaster_a, struct_a) = if close_inbound_first { (&inbound_node.node, &inbound_node.tx_broadcaster, inbound_node) } else { (&outbound_node.node, &outbound_node.tx_broadcaster, outbound_node) };
15091524
let (node_b, broadcaster_b, struct_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster, outbound_node) } else { (&inbound_node.node, &inbound_node.tx_broadcaster, inbound_node) };

lightning/src/ln/monitor_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ fn do_test_anchors_monitor_fixes_counterparty_payment_script_on_reload(confirm_c
24032403
).unwrap();
24042404
check_spends!(spend_tx, &commitment_tx);
24052405
} else {
2406-
test_spendable_output(&nodes[1], &commitment_tx);
2406+
test_spendable_output(&nodes[1], &commitment_tx, false);
24072407
}
24082408
}
24092409

0 commit comments

Comments
 (0)