@@ -12557,6 +12557,39 @@ mod tests {
12557
12557
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
12558
12558
}
12559
12559
12560
+ #[test]
12561
+ fn test_accept_inbound_channel_errors_queued() {
12562
+ // For manually accepted inbound channels, tests that a close error is correctly handled
12563
+ // and the channel fails for the initiator.
12564
+ let mut config0 = test_default_channel_config();
12565
+ let mut config1 = config0.clone();
12566
+ config1.channel_handshake_limits.their_to_self_delay = 1000;
12567
+ config1.manually_accept_inbound_channels = true;
12568
+ config0.channel_handshake_config.our_to_self_delay = 2000;
12569
+
12570
+ let chanmon_cfgs = create_chanmon_cfgs(2);
12571
+ let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
12572
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config0), Some(config1)]);
12573
+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
12574
+
12575
+ nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
12576
+ let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
12577
+
12578
+ nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
12579
+ let events = nodes[1].node.get_and_clear_pending_events();
12580
+ match events[0] {
12581
+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
12582
+ match nodes[1].node.accept_inbound_channel(&temporary_channel_id, &nodes[0].node.get_our_node_id(), 23) {
12583
+ Err(APIError::ChannelUnavailable { err: _ }) => (),
12584
+ _ => panic!(),
12585
+ }
12586
+ }
12587
+ _ => panic!("Unexpected event"),
12588
+ }
12589
+ assert_eq!(get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id()).channel_id,
12590
+ open_channel_msg.common_fields.temporary_channel_id);
12591
+ }
12592
+
12560
12593
#[test]
12561
12594
fn test_update_channel_config() {
12562
12595
let chanmon_cfg = create_chanmon_cfgs(2);
0 commit comments