- check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed, [nodes[0].node.get_our_node_id()], 100000);
-}
-
-#[test]
-fn test_reject_funding_before_inbound_channel_accepted() {
- // This tests that when `UserConfig::manually_accept_inbound_channels` is set to true, inbound
- // channels must to be manually accepted through `ChannelManager::accept_inbound_channel` by
- // the node operator before the counterparty sends a `FundingCreated` message. If a
- // `FundingCreated` message is received before the channel is accepted, it should be rejected
- // and the channel should be closed.
- let mut manually_accept_conf = UserConfig::default();
- manually_accept_conf.manually_accept_inbound_channels = true;
- let chanmon_cfgs = create_chanmon_cfgs(2);
- let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
- let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(manually_accept_conf.clone())]);
- let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
-
- nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, Some(manually_accept_conf)).unwrap();
- let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
- let temp_channel_id = res.temporary_channel_id;
-
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &res);
-
- // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in the `msg_events`.
- assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
-
- // Clear the `Event::OpenChannelRequest` event without responding to the request.
- nodes[1].node.get_and_clear_pending_events();
-
- // Get the `AcceptChannel` message of `nodes[1]` without calling
- // `ChannelManager::accept_inbound_channel`, which generates a
- // `MessageSendEvent::SendAcceptChannel` event. The message is passed to `nodes[0]`
- // `handle_accept_channel`, which is required in order for `create_funding_transaction` to
- // succeed when `nodes[0]` is passed to it.
- let accept_chan_msg = {
- let mut node_1_per_peer_lock;
- let mut node_1_peer_state_lock;
- let channel = get_inbound_v1_channel_ref!(&nodes[1], nodes[0], node_1_per_peer_lock, node_1_peer_state_lock, temp_channel_id);
- channel.get_accept_channel_message()
- };
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_chan_msg);
-
- let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
-
- nodes[0].node.funding_transaction_generated(&temporary_channel_id, &nodes[1].node.get_our_node_id(), tx.clone()).unwrap();
- let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
-
- // The `funding_created_msg` should be rejected by `nodes[1]` as it hasn't accepted the channel
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);