Skip to content

Commit 31a7294

Browse files
Move get_channel_details helper into router::test_utils
Used incoming commit(s) to test onion message pathfinding
1 parent 5211bfd commit 31a7294

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

lightning/src/routing/router.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,7 @@ mod tests {
19371937
PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RoutingFees,
19381938
DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, MAX_PATH_LENGTH_ESTIMATE};
19391939
use routing::scoring::{ChannelUsage, Score, ProbabilisticScorer, ProbabilisticScoringParameters};
1940-
use routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel};
1941-
use chain::transaction::OutPoint;
1940+
use routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, get_channel_details, id_to_feature_flags, get_nodes, update_channel};
19421941
use chain::keysinterface::KeysInterface;
19431942
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
19441943
use ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
@@ -1948,7 +1947,6 @@ mod tests {
19481947
#[cfg(c_bindings)]
19491948
use util::ser::{Writeable, Writer};
19501949

1951-
use bitcoin::hashes::Hash;
19521950
use bitcoin::network::constants::Network;
19531951
use bitcoin::blockdata::constants::genesis_block;
19541952
use bitcoin::blockdata::script::Builder;
@@ -1965,40 +1963,6 @@ mod tests {
19651963

19661964
use core::convert::TryInto;
19671965

1968-
fn get_channel_details(short_channel_id: Option<u64>, node_id: PublicKey,
1969-
features: InitFeatures, outbound_capacity_msat: u64) -> channelmanager::ChannelDetails {
1970-
channelmanager::ChannelDetails {
1971-
channel_id: [0; 32],
1972-
counterparty: channelmanager::ChannelCounterparty {
1973-
features,
1974-
node_id,
1975-
unspendable_punishment_reserve: 0,
1976-
forwarding_info: None,
1977-
outbound_htlc_minimum_msat: None,
1978-
outbound_htlc_maximum_msat: None,
1979-
},
1980-
funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }),
1981-
channel_type: None,
1982-
short_channel_id,
1983-
outbound_scid_alias: None,
1984-
inbound_scid_alias: None,
1985-
channel_value_satoshis: 0,
1986-
user_channel_id: 0,
1987-
balance_msat: 0,
1988-
outbound_capacity_msat,
1989-
next_outbound_htlc_limit_msat: outbound_capacity_msat,
1990-
inbound_capacity_msat: 42,
1991-
unspendable_punishment_reserve: None,
1992-
confirmations_required: None,
1993-
force_close_spend_delay: None,
1994-
is_outbound: true, is_channel_ready: true,
1995-
is_usable: true, is_public: true,
1996-
inbound_htlc_minimum_msat: None,
1997-
inbound_htlc_maximum_msat: None,
1998-
config: None,
1999-
}
2000-
}
2001-
20021966
#[test]
20031967
fn simple_route_test() {
20041968
let (secp_ctx, network_graph, _, _, logger) = build_graph();

lightning/src/routing/test_utils.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10+
use chain::transaction::OutPoint;
1011
use routing::gossip::{NetworkGraph, P2PGossipSync};
11-
use ln::features::{ChannelFeatures, NodeFeatures};
12+
use ln::channelmanager;
13+
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
1214
use ln::msgs::{UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
1315
NodeAnnouncement, UnsignedNodeAnnouncement, ChannelUpdate, UnsignedChannelUpdate, MAX_VALUE_MSAT};
1416
use util::test_utils;
@@ -27,6 +29,40 @@ use bitcoin::secp256k1::{Secp256k1, All};
2729
use prelude::*;
2830
use sync::{self, Arc};
2931

32+
pub(super) fn get_channel_details(short_channel_id: Option<u64>, node_id: PublicKey,
33+
features: InitFeatures, outbound_capacity_msat: u64) -> channelmanager::ChannelDetails {
34+
channelmanager::ChannelDetails {
35+
channel_id: [0; 32],
36+
counterparty: channelmanager::ChannelCounterparty {
37+
features,
38+
node_id,
39+
unspendable_punishment_reserve: 0,
40+
forwarding_info: None,
41+
outbound_htlc_minimum_msat: None,
42+
outbound_htlc_maximum_msat: None,
43+
},
44+
funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }),
45+
channel_type: None,
46+
short_channel_id,
47+
outbound_scid_alias: None,
48+
inbound_scid_alias: None,
49+
channel_value_satoshis: 0,
50+
user_channel_id: 0,
51+
balance_msat: 0,
52+
outbound_capacity_msat,
53+
next_outbound_htlc_limit_msat: outbound_capacity_msat,
54+
inbound_capacity_msat: 42,
55+
unspendable_punishment_reserve: None,
56+
confirmations_required: None,
57+
force_close_spend_delay: None,
58+
is_outbound: true, is_channel_ready: true,
59+
is_usable: true, is_public: true,
60+
inbound_htlc_minimum_msat: None,
61+
inbound_htlc_maximum_msat: None,
62+
config: None,
63+
}
64+
}
65+
3066
// Using the same keys for LN and BTC ids
3167
pub(super) fn add_channel(
3268
gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,

0 commit comments

Comments
 (0)