let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, InitFeatures::known(), InitFeatures::known());
mine_transaction(&nodes[1], &tx);
nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id()));
+ assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
mine_transaction(&nodes[0], &tx);
- let (funding_locked, _) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]);
- let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &funding_locked);
+ let as_msg_events = nodes[0].node.get_and_clear_pending_msg_events();
+ assert_eq!(as_msg_events.len(), 2);
+ let as_funding_locked = if let MessageSendEvent::SendFundingLocked { ref node_id, ref msg } = as_msg_events[0] {
+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
+ msg.clone()
+ } else { panic!("Unexpected event"); };
+ if let MessageSendEvent::SendChannelUpdate { ref node_id, msg: _ } = as_msg_events[1] {
+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
+ } else { panic!("Unexpected event"); }
+
+ nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &as_funding_locked);
+ let bs_msg_events = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(bs_msg_events.len(), 1);
+ if let MessageSendEvent::SendChannelUpdate { ref node_id, msg: _ } = bs_msg_events[0] {
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ } else { panic!("Unexpected event"); }
+
+ send_payment(&nodes[0], &[&nodes[1]], 100_000);
+
+ // After 6 confirmations, as required by the spec, we'll send announcement_signatures and
+ // broadcast the channel_announcement (but not before exactly 6 confirmations).
+ connect_blocks(&nodes[0], 4);
+ assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
+ connect_blocks(&nodes[0], 1);
+ nodes[1].node.handle_announcement_signatures(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendAnnouncementSignatures, nodes[1].node.get_our_node_id()));
+ assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
+
+ connect_blocks(&nodes[1], 5);
+ let bs_announce_events = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(bs_announce_events.len(), 2);
+ let bs_announcement_sigs = if let MessageSendEvent::SendAnnouncementSignatures { ref node_id, ref msg } = bs_announce_events[0] {
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ msg.clone()
+ } else { panic!("Unexpected event"); };
+ let (bs_announcement, bs_update) = if let MessageSendEvent::BroadcastChannelAnnouncement { ref msg, ref update_msg } = bs_announce_events[1] {
+ (msg.clone(), update_msg.clone())
+ } else { panic!("Unexpected event"); };
+
+ nodes[0].node.handle_announcement_signatures(&nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
+ let as_announce_events = nodes[0].node.get_and_clear_pending_msg_events();
+ assert_eq!(as_announce_events.len(), 1);
+ let (announcement, as_update) = if let MessageSendEvent::BroadcastChannelAnnouncement { ref msg, ref update_msg } = as_announce_events[0] {
+ (msg.clone(), update_msg.clone())
+ } else { panic!("Unexpected event"); };
+ assert_eq!(announcement, bs_announcement);
for node in nodes {
assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
}
// Re-deliver nodes[0]'s funding_locked, which nodes[1] can safely ignore. It currently
- // generates a duplicative announcement_signatures
+ // generates a duplicative private channel_update
nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &as_funding_locked);
let events_5 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_5.len(), 1);
match events_5[0] {
- MessageSendEvent::SendAnnouncementSignatures { ref node_id, ref msg } => {
+ MessageSendEvent::SendChannelUpdate { ref node_id, msg: _ } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- assert_eq!(*msg, bs_announcement_sigs);
},
_ => panic!("Unexpected event {:?}", events_5[0]),
};
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
//Force duplicate channel ids
for node in nodes.iter() {
- *node.keys_manager.override_channel_id_priv.lock().unwrap() = Some([0; 32]);
+ *node.keys_manager.override_random_bytes.lock().unwrap() = Some([0; 32]);
}
// BOLT #2 spec: Sending node must ensure temporary_channel_id is unique from any other channel ID with the same peer.
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), channel_value_satoshis, push_msat, 42, None).unwrap();
let node0_to_1_send_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &node0_to_1_send_open_channel);
+ get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
//Create a second channel with a channel_id collision
- assert!(nodes[0].node.create_channel(nodes[0].node.get_our_node_id(), channel_value_satoshis, push_msat, 42, None).is_err());
+ assert!(nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), channel_value_satoshis, push_msat, 42, None).is_err());
}
#[test]
// Create some initial channels
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
- let scorer = test_utils::TestScorer::with_fixed_penalty(0);
+ let scorer = test_utils::TestScorer::with_penalty(0);
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id()).with_features(InvoiceFeatures::known());
let route = get_route(&nodes[0].node.get_our_node_id(), &payment_params, nodes[0].network_graph, None, 10_000, TEST_FINAL_CLTV, nodes[0].logger, &scorer).unwrap();
let (_, our_payment_hash, _) = get_payment_preimage_hash!(nodes[0]);
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000, InitFeatures::known(), InitFeatures::known());
// Lock HTLC in both directions (using a slightly lower CLTV delay to provide timely RBF bumps)
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id()).with_features(InvoiceFeatures::known());
- let scorer = test_utils::TestScorer::with_fixed_penalty(0);
+ let scorer = test_utils::TestScorer::with_penalty(0);
let route = get_route(&nodes[0].node.get_our_node_id(), &payment_params, &nodes[0].network_graph, None,
3_000_000, 50, nodes[0].logger, &scorer).unwrap();
let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 3_000_000).0;
}
}
+#[test]
+fn test_pending_claimed_htlc_no_balance_underflow() {
+ // Tests that if we have a pending outbound HTLC as well as a claimed-but-not-fully-removed
+ // HTLC we will not underflow when we call `Channel::get_balance_msat()`.
+ 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, None]);
+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
+ create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 0, InitFeatures::known(), InitFeatures::known());
+
+ let payment_preimage = route_payment(&nodes[0], &[&nodes[1]], 1_010_000).0;
+ nodes[1].node.claim_funds(payment_preimage);
+ check_added_monitors!(nodes[1], 1);
+ let fulfill_ev = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
+
+ nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &fulfill_ev.update_fulfill_htlcs[0]);
+ expect_payment_sent_without_paths!(nodes[0], payment_preimage);
+ nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &fulfill_ev.commitment_signed);
+ check_added_monitors!(nodes[0], 1);
+ let (_raa, _cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
+
+ // At this point nodes[1] has received 1,010k msat (10k msat more than their reserve) and can
+ // send an HTLC back (though it will go in the holding cell). Send an HTLC back and check we
+ // can get our balance.
+
+ // Get a route from nodes[1] to nodes[0] by getting a route going the other way and then flip
+ // the public key of the only hop. This works around ChannelDetails not showing the
+ // almost-claimed HTLC as available balance.
+ let (mut route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 10_000);
+ route.payment_params = None; // This is all wrong, but unnecessary
+ route.paths[0][0].pubkey = nodes[0].node.get_our_node_id();
+ let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[0]);
+ nodes[1].node.send_payment(&route, payment_hash_2, &Some(payment_secret_2)).unwrap();
+
+ assert_eq!(nodes[1].node.list_channels()[0].balance_msat, 1_000_000);
+}
+
#[test]
fn test_channel_conf_timeout() {
// Tests that, for inbound channels, we give up on them if the funding transaction does not
assert_eq!(res.htlc_minimum_msat, 1);
}
+#[test]
+fn test_manually_accept_inbound_channel_request() {
+ 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());
+
+ nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &res);
+
+ // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
+ // accepting the inbound channel request.
+ assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
+
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ nodes[1].node.accept_inbound_channel(&temporary_channel_id).unwrap();
+ }
+ _ => panic!("Unexpected event"),
+ }
+
+ let accept_msg_ev = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(accept_msg_ev.len(), 1);
+
+ match accept_msg_ev[0] {
+ MessageSendEvent::SendAcceptChannel { ref node_id, .. } => {
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ }
+ _ => panic!("Unexpected event"),
+ }
+}
+
+#[test]
+fn test_manually_reject_inbound_channel_request() {
+ 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());
+
+ nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &res);
+
+ // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
+ // rejecting the inbound channel request.
+ assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
+
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ nodes[1].node.force_close_channel(&temporary_channel_id).unwrap();
+ }
+ _ => panic!("Unexpected event"),
+ }
+
+ let close_msg_ev = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(close_msg_ev.len(), 1);
+
+ match close_msg_ev[0] {
+ MessageSendEvent::HandleError { ref node_id, .. } => {
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ }
+ _ => panic!("Unexpected event"),
+ }
+ check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed);
+}
+
+#[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(), InitFeatures::known(), &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 mut lock;
+ let channel = get_channel_ref!(&nodes[1], lock, temp_channel_id);
+ let accept_chan_msg = channel.get_accept_channel_message();
+ nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), InitFeatures::known(), &accept_chan_msg);
+ }
+
+ let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], 100000, 42);
+
+ nodes[0].node.funding_transaction_generated(&temporary_channel_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);
+
+ let close_msg_ev = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(close_msg_ev.len(), 1);
+
+ let expected_err = "FundingCreated message received before the channel was accepted";
+ match close_msg_ev[0] {
+ MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg }, ref node_id, } => {
+ assert_eq!(msg.channel_id, temp_channel_id);
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ assert_eq!(msg.data, expected_err);
+ }
+ _ => panic!("Unexpected event"),
+ }
+
+ check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: expected_err.to_string() });
+}
+
+#[test]
+fn test_can_not_accept_inbound_channel_twice() {
+ 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());
+
+ nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &res);
+
+ // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
+ // accepting the inbound channel request.
+ assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
+
+ let events = nodes[1].node.get_and_clear_pending_events();
+ match events[0] {
+ Event::OpenChannelRequest { temporary_channel_id, .. } => {
+ nodes[1].node.accept_inbound_channel(&temporary_channel_id).unwrap();
+ let api_res = nodes[1].node.accept_inbound_channel(&temporary_channel_id);
+ match api_res {
+ Err(APIError::APIMisuseError { err }) => {
+ assert_eq!(err, "The channel isn't currently awaiting to be accepted.");
+ },
+ Ok(_) => panic!("Channel shouldn't be possible to be accepted twice"),
+ Err(_) => panic!("Unexpected Error"),
+ }
+ }
+ _ => panic!("Unexpected event"),
+ }
+
+ // Ensure that the channel wasn't closed after attempting to accept it twice.
+ let accept_msg_ev = nodes[1].node.get_and_clear_pending_msg_events();
+ assert_eq!(accept_msg_ev.len(), 1);
+
+ match accept_msg_ev[0] {
+ MessageSendEvent::SendAcceptChannel { ref node_id, .. } => {
+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
+ }
+ _ => panic!("Unexpected event"),
+ }
+}
+
+#[test]
+fn test_can_not_accept_unknown_inbound_channel() {
+ let chanmon_cfg = create_chanmon_cfgs(1);
+ let node_cfg = create_node_cfgs(1, &chanmon_cfg);
+ let node_chanmgr = create_node_chanmgrs(1, &node_cfg, &[None]);
+ let node = create_network(1, &node_cfg, &node_chanmgr)[0].node;
+
+ let unknown_channel_id = [0; 32];
+ let api_res = node.accept_inbound_channel(&unknown_channel_id);
+ match api_res {
+ Err(APIError::ChannelUnavailable { err }) => {
+ assert_eq!(err, "Can't accept a channel that doesn't exist");
+ },
+ Ok(_) => panic!("It shouldn't be possible to accept an unkown channel"),
+ Err(_) => panic!("Unexpected Error"),
+ }
+}
+
#[test]
fn test_simple_mpp() {
// Simple test of sending a multi-path payment.
claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage_2);
}
+#[test]
+fn test_dup_htlc_second_fail_panic() {
+ // Previously, if we received two HTLCs back-to-back, where the second overran the expected
+ // value for the payment, we'd fail back both HTLCs after generating a `PaymentReceived` event.
+ // Then, if the user failed the second payment, they'd hit a "tried to fail an already failed
+ // HTLC" debug panic. This tests for this behavior, checking that only one HTLC is auto-failed.
+ 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, None]);
+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
+
+ let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, InitFeatures::known(), InitFeatures::known());
+
+ let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id())
+ .with_features(InvoiceFeatures::known());
+ let scorer = test_utils::TestScorer::with_penalty(0);
+ let route = get_route(
+ &nodes[0].node.get_our_node_id(), &payment_params, &nodes[0].network_graph,
+ Some(&nodes[0].node.list_usable_channels().iter().collect::<Vec<_>>()),
+ 10_000, TEST_FINAL_CLTV, nodes[0].logger, &scorer).unwrap();
+
+ let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(&nodes[1]);
+
+ {
+ nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)).unwrap();
+ check_added_monitors!(nodes[0], 1);
+ let mut events = nodes[0].node.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 1);
+ let mut payment_event = SendEvent::from_event(events.pop().unwrap());
+ nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
+ }
+ expect_pending_htlcs_forwardable!(nodes[1]);
+ expect_payment_received!(nodes[1], our_payment_hash, our_payment_secret, 10_000);
+
+ {
+ nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)).unwrap();
+ check_added_monitors!(nodes[0], 1);
+ let mut events = nodes[0].node.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 1);
+ let mut payment_event = SendEvent::from_event(events.pop().unwrap());
+ nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
+ // At this point, nodes[1] would notice it has too much value for the payment. It will
+ // assume the second is a privacy attack (no longer particularly relevant
+ // post-payment_secrets) and fail back the new HTLC. Previously, it'd also have failed back
+ // the first HTLC delivered above.
+ }
+
+ // Now we go fail back the first HTLC from the user end.
+ expect_pending_htlcs_forwardable_ignore!(nodes[1]);
+ nodes[1].node.process_pending_htlc_forwards();
+ nodes[1].node.fail_htlc_backwards(&our_payment_hash);
+
+ expect_pending_htlcs_forwardable_ignore!(nodes[1]);
+ nodes[1].node.process_pending_htlc_forwards();
+
+ check_added_monitors!(nodes[1], 1);
+ let fail_updates_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
+ assert_eq!(fail_updates_1.update_fail_htlcs.len(), 2);
+
+ nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[1]);
+ commitment_signed_dance!(nodes[0], nodes[1], fail_updates_1.commitment_signed, false);
+
+ let failure_events = nodes[0].node.get_and_clear_pending_events();
+ assert_eq!(failure_events.len(), 2);
+ if let Event::PaymentPathFailed { .. } = failure_events[0] {} else { panic!(); }
+ if let Event::PaymentPathFailed { .. } = failure_events[1] {} else { panic!(); }
+}
+
#[test]
fn test_keysend_payments_to_public_node() {
let chanmon_cfgs = create_chanmon_cfgs(2);
final_value_msat: 10000,
final_cltv_expiry_delta: 40,
};
- let scorer = test_utils::TestScorer::with_fixed_penalty(0);
+ let scorer = test_utils::TestScorer::with_penalty(0);
let route = find_route(&payer_pubkey, &route_params, network_graph, None, nodes[0].logger, &scorer).unwrap();
let test_preimage = PaymentPreimage([42; 32]);
};
let network_graph = nodes[0].network_graph;
let first_hops = nodes[0].node.list_usable_channels();
- let scorer = test_utils::TestScorer::with_fixed_penalty(0);
+ let scorer = test_utils::TestScorer::with_penalty(0);
let route = find_route(
&payer_pubkey, &route_params, network_graph, Some(&first_hops.iter().collect::<Vec<_>>()),
nodes[0].logger, &scorer