@@ -10983,3 +10983,36 @@ fn test_funding_and_commitment_tx_confirm_same_block() {
1098310983 do_test_funding_and_commitment_tx_confirm_same_block(false);
1098410984 do_test_funding_and_commitment_tx_confirm_same_block(true);
1098510985}
10986+
10987+ #[test]
10988+ fn test_accept_inbound_channel_errors_queued() {
10989+ // For manually accepted inbound channels, tests that a close error is correctly handled
10990+ // and the channel fails for the initiator.
10991+ let mut config0 = test_default_channel_config();
10992+ let mut config1 = config0.clone();
10993+ config1.channel_handshake_limits.their_to_self_delay = 1000;
10994+ config1.manually_accept_inbound_channels = true;
10995+ config0.channel_handshake_config.our_to_self_delay = 2000;
10996+
10997+ let chanmon_cfgs = create_chanmon_cfgs(2);
10998+ let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
10999+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config0), Some(config1)]);
11000+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
11001+
11002+ nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
11003+ let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
11004+
11005+ nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
11006+ let events = nodes[1].node.get_and_clear_pending_events();
11007+ match events[0] {
11008+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
11009+ match nodes[1].node.accept_inbound_channel(&temporary_channel_id, &nodes[0].node.get_our_node_id(), 23) {
11010+ Err(APIError::ChannelUnavailable { err: _ }) => (),
11011+ _ => panic!(),
11012+ }
11013+ }
11014+ _ => panic!("Unexpected event"),
11015+ }
11016+ assert_eq!(get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id()).channel_id,
11017+ open_channel_msg.common_fields.temporary_channel_id);
11018+ }
0 commit comments