Skip to content

Commit 38a886b

Browse files
committed
f - Revert get_route_and_payment_hash where closer review is needed
1 parent ee1edb0 commit 38a886b

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use ln::channel::{Channel, ChannelError};
2424
use ln::{chan_utils, onion_utils};
2525
use ln::chan_utils::HTLC_SUCCESS_TX_WEIGHT;
2626
use routing::network_graph::{NetworkUpdate, RoutingFees};
27-
use routing::router::{Route, RouteHop, RouteHint, RouteHintHop};
28-
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
27+
use routing::router::{Route, RouteHop, RouteHint, RouteHintHop, get_route};
28+
use ln::features::{ChannelFeatures, InitFeatures, InvoiceFeatures, NodeFeatures};
2929
use ln::msgs;
3030
use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
3131
use util::enforcing_trait_impls::EnforcingSigner;
@@ -3983,8 +3983,9 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) {
39833983
// Now attempt to route a second payment, which should be placed in the holding cell
39843984
let sending_node = if forwarded_htlc { &nodes[0] } else { &nodes[1] };
39853985
let (route, second_payment_hash, _, second_payment_secret) = get_route_and_payment_hash!(sending_node, nodes[2], 100000);
3986-
// TODO: Check why a different payment secret was used
3987-
sending_node.node.send_payment(&route, second_payment_hash, &Some(second_payment_secret)).unwrap();
3986+
// TODO: Why use a different payment secret here?
3987+
let payment_secret = if forwarded_htlc { first_payment_secret } else { second_payment_secret };
3988+
sending_node.node.send_payment(&route, second_payment_hash, &Some(payment_secret)).unwrap();
39883989
if forwarded_htlc {
39893990
check_added_monitors!(nodes[0], 1);
39903991
let payment_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
@@ -7290,9 +7291,10 @@ fn test_check_htlc_underpaying() {
72907291
// Create some initial channels
72917292
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
72927293

7293-
// TODO: Check if this is the correct way to test this.
7294-
let (mut route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
7295-
route.paths[0][0].fee_msat = 10_000;
7294+
// TODO: Replace this with get_route_and_payment_hash.
7295+
let route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph, &nodes[1].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 10_000, TEST_FINAL_CLTV, nodes[0].logger).unwrap();
7296+
let (_, our_payment_hash, _) = get_payment_preimage_hash!(nodes[0]);
7297+
let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(our_payment_hash, Some(100_000), 7200, 0).unwrap();
72967298
nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)).unwrap();
72977299
check_added_monitors!(nodes[0], 1);
72987300

@@ -7690,9 +7692,11 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
76907692

76917693
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000, InitFeatures::known(), InitFeatures::known());
76927694
// Lock HTLC in both directions (using a slightly lower CLTV delay to provide timely RBF bumps)
7693-
let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], vec![], 3_000_000, 50);
7695+
let route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph,
7696+
&nodes[1].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 3_000_000, 50, nodes[0].logger).unwrap();
76947697
let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 3_000_000).0;
7695-
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[0], vec![], 3_000_000, 50);
7698+
let route = get_route(&nodes[1].node.get_our_node_id(), &nodes[1].net_graph_msg_handler.network_graph,
7699+
&nodes[0].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 3_000_000, 50, nodes[0].logger).unwrap();
76967700
send_along_route(&nodes[1], route, &[&nodes[0]], 3_000_000);
76977701

76987702
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan.2);
@@ -7761,9 +7765,10 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
77617765
assert_ne!(node_txn[0].input[0].previous_output, node_txn[2].input[0].previous_output);
77627766
assert_ne!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
77637767

7764-
// TODO: Why does this change?
7765-
assert_eq!(node_txn[0].input[0].previous_output, revoked_htlc_txn[2].input[0].previous_output);
7766-
assert_eq!(node_txn[1].input[0].previous_output, revoked_htlc_txn[0].input[0].previous_output);
7768+
// TODO: Determine why replacing get_route with get_route_and_payment_hash above causes
7769+
// these outputs to match differently.
7770+
assert_eq!(node_txn[0].input[0].previous_output, revoked_htlc_txn[0].input[0].previous_output);
7771+
assert_eq!(node_txn[1].input[0].previous_output, revoked_htlc_txn[2].input[0].previous_output);
77677772

77687773
// node_txn[3] is the local commitment tx broadcast just because (and somewhat in case of
77697774
// reorgs, though its not clear its ever worth broadcasting conflicting txn like this when

0 commit comments

Comments
 (0)