Skip to content

Commit ba2c00b

Browse files
committed
EventHandler for applying NetworkUpdate
PaymentFailed events contain an optional NetworkUpdate describing changes to the NetworkGraph as conveyed by a node along a failed payment path according to BOLT 4. An EventHandler should apply the update to the graph so that future routing decisions can account for it. Implement EventHandler for NetGraphMsgHandler to update NetworkGraph. Previously, NetGraphMsgHandler::handle_htlc_fail_channel_update implemented this behavior.
1 parent eff9a47 commit ba2c00b

File tree

5 files changed

+140
-65
lines changed

5 files changed

+140
-65
lines changed

fuzz/src/full_stack.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,Ig
3838
use lightning::ln::msgs::DecodeError;
3939
use lightning::ln::script::ShutdownScript;
4040
use lightning::routing::router::get_route;
41-
use lightning::routing::network_graph::NetGraphMsgHandler;
41+
use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
4242
use lightning::util::config::UserConfig;
4343
use lightning::util::errors::APIError;
4444
use lightning::util::events::Event;
@@ -378,7 +378,8 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
378378
};
379379
let channelmanager = Arc::new(ChannelManager::new(fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, params));
380380
let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret());
381-
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(genesis_block(network).block_hash(), None, Arc::clone(&logger)));
381+
let network_graph = NetworkGraph::new(genesis_block(network).block_hash());
382+
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger)));
382383

383384
let peers = RefCell::new([false; 256]);
384385
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {

lightning/src/ln/functional_test_utils.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
243243
network_graph_ser.write(&mut w).unwrap();
244244
let network_graph_deser = <NetworkGraph>::read(&mut io::Cursor::new(&w.0)).unwrap();
245245
assert!(network_graph_deser == self.net_graph_msg_handler.network_graph);
246-
let net_graph_msg_handler = NetGraphMsgHandler::from_net_graph(
247-
Some(self.chain_source), self.logger, network_graph_deser
246+
let net_graph_msg_handler = NetGraphMsgHandler::new(
247+
network_graph_deser, Some(self.chain_source), self.logger
248248
);
249249
let mut chan_progress = 0;
250250
loop {
@@ -1440,7 +1440,8 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
14401440
let connect_style = Rc::new(RefCell::new(ConnectStyle::FullBlockViaListen));
14411441

14421442
for i in 0..node_count {
1443-
let net_graph_msg_handler = NetGraphMsgHandler::new(cfgs[i].chain_source.genesis_hash, None, cfgs[i].logger);
1443+
let network_graph = NetworkGraph::new(cfgs[i].chain_source.genesis_hash);
1444+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, cfgs[i].logger);
14441445
nodes.push(Node{ chain_source: cfgs[i].chain_source,
14451446
tx_broadcaster: cfgs[i].tx_broadcaster, chain_monitor: &cfgs[i].chain_monitor,
14461447
keys_manager: &cfgs[i].keys_manager, node: &chan_mgrs[i], net_graph_msg_handler,

lightning/src/routing/network_graph.rs

Lines changed: 112 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, Reply
2929
use ln::msgs;
3030
use util::ser::{Writeable, Readable, Writer};
3131
use util::logger::{Logger, Level};
32-
use util::events::{MessageSendEvent, MessageSendEventsProvider};
32+
use util::events::{Event, EventHandler, MessageSendEvent, MessageSendEventsProvider};
3333
use util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
3434

3535
use io;
@@ -110,12 +110,28 @@ impl_writeable_tlv_based_enum_upgradable!(NetworkUpdate,
110110
},
111111
);
112112

113+
impl<C: Deref, L: Deref> EventHandler for NetGraphMsgHandler<C, L>
114+
where C::Target: chain::Access, L::Target: Logger {
115+
fn handle_event(&self, event: &Event) {
116+
if let Event::PaymentFailed { payment_hash: _, rejected_by_dest: _, network_update, .. } = event {
117+
if let Some(network_update) = network_update {
118+
self.handle_network_update(network_update);
119+
}
120+
}
121+
}
122+
}
123+
113124
/// Receives and validates network updates from peers,
114125
/// stores authentic and relevant data as a network graph.
115126
/// This network graph is then used for routing payments.
116127
/// Provides interface to help with initial routing sync by
117128
/// serving historical announcements.
118-
pub struct NetGraphMsgHandler<C: Deref, L: Deref> where C::Target: chain::Access, L::Target: Logger {
129+
///
130+
/// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentFailed`] to the
131+
/// [`NetworkGraph`].
132+
pub struct NetGraphMsgHandler<C: Deref, L: Deref>
133+
where C::Target: chain::Access, L::Target: Logger
134+
{
119135
secp_ctx: Secp256k1<secp256k1::VerifyOnly>,
120136
/// Representation of the payment channel network
121137
pub network_graph: NetworkGraph,
@@ -125,26 +141,15 @@ pub struct NetGraphMsgHandler<C: Deref, L: Deref> where C::Target: chain::Access
125141
logger: L,
126142
}
127143

128-
impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
144+
impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L>
145+
where C::Target: chain::Access, L::Target: Logger
146+
{
129147
/// Creates a new tracker of the actual state of the network of channels and nodes,
130-
/// assuming a fresh network graph.
148+
/// assuming an existing Network Graph.
131149
/// Chain monitor is used to make sure announced channels exist on-chain,
132150
/// channel data is correct, and that the announcement is signed with
133151
/// channel owners' keys.
134-
pub fn new(genesis_hash: BlockHash, chain_access: Option<C>, logger: L) -> Self {
135-
NetGraphMsgHandler {
136-
secp_ctx: Secp256k1::verification_only(),
137-
network_graph: NetworkGraph::new(genesis_hash),
138-
full_syncs_requested: AtomicUsize::new(0),
139-
chain_access,
140-
pending_events: Mutex::new(vec![]),
141-
logger,
142-
}
143-
}
144-
145-
/// Creates a new tracker of the actual state of the network of channels and nodes,
146-
/// assuming an existing Network Graph.
147-
pub fn from_net_graph(chain_access: Option<C>, logger: L, network_graph: NetworkGraph) -> Self {
152+
pub fn new(network_graph: NetworkGraph, chain_access: Option<C>, logger: L) -> Self {
148153
NetGraphMsgHandler {
149154
secp_ctx: Secp256k1::verification_only(),
150155
network_graph,
@@ -173,6 +178,29 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
173178
false
174179
}
175180
}
181+
182+
/// Applies changes to the [`NetworkGraph`] from the given update.
183+
fn handle_network_update(&self, update: &NetworkUpdate) {
184+
match *update {
185+
NetworkUpdate::ChannelUpdateMessage { ref msg } => {
186+
let short_channel_id = msg.contents.short_channel_id;
187+
let is_enabled = msg.contents.flags & (1 << 1) != (1 << 1);
188+
let status = if is_enabled { "enabled" } else { "disabled" };
189+
log_debug!(self.logger, "Updating channel with channel_update from a payment failure. Channel {} is {}.", short_channel_id, status);
190+
let _ = self.network_graph.update_channel(msg, &self.secp_ctx);
191+
},
192+
NetworkUpdate::ChannelClosed { short_channel_id, is_permanent } => {
193+
let action = if is_permanent { "Removing" } else { "Disabling" };
194+
log_debug!(self.logger, "{} channel graph entry for {} due to a payment failure.", action, short_channel_id);
195+
self.network_graph.close_channel_from_update(short_channel_id, is_permanent);
196+
},
197+
NetworkUpdate::NodeFailure { ref node_id, is_permanent } => {
198+
let action = if is_permanent { "Removing" } else { "Disabling" };
199+
log_debug!(self.logger, "{} node graph entry for {} due to a payment failure.", action, node_id);
200+
self.network_graph.fail_node(node_id, is_permanent);
201+
},
202+
}
203+
}
176204
}
177205

178206
macro_rules! secp_verify_sig {
@@ -184,7 +212,9 @@ macro_rules! secp_verify_sig {
184212
};
185213
}
186214

187-
impl<C: Deref , L: Deref > RoutingMessageHandler for NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
215+
impl<C: Deref, L: Deref> RoutingMessageHandler for NetGraphMsgHandler<C, L>
216+
where C::Target: chain::Access, L::Target: Logger
217+
{
188218
fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
189219
self.network_graph.update_node_from_announcement(msg, &self.secp_ctx)?;
190220
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
@@ -1116,15 +1146,16 @@ impl ReadOnlyNetworkGraph<'_> {
11161146
#[cfg(test)]
11171147
mod tests {
11181148
use chain;
1149+
use ln::PaymentHash;
11191150
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
1120-
use routing::network_graph::{NetGraphMsgHandler, NetworkGraph, MAX_EXCESS_BYTES_FOR_RELAY};
1151+
use routing::network_graph::{NetGraphMsgHandler, NetworkGraph, NetworkUpdate, MAX_EXCESS_BYTES_FOR_RELAY};
11211152
use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
11221153
UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
11231154
ReplyChannelRange, ReplyShortChannelIdsEnd, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
11241155
use util::test_utils;
11251156
use util::logger::Logger;
11261157
use util::ser::{Readable, Writeable};
1127-
use util::events::{MessageSendEvent, MessageSendEventsProvider};
1158+
use util::events::{Event, EventHandler, MessageSendEvent, MessageSendEventsProvider};
11281159
use util::scid_utils::scid_from_parts;
11291160

11301161
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
@@ -1148,7 +1179,8 @@ mod tests {
11481179
let secp_ctx = Secp256k1::new();
11491180
let logger = Arc::new(test_utils::TestLogger::new());
11501181
let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
1151-
let net_graph_msg_handler = NetGraphMsgHandler::new(genesis_hash, None, Arc::clone(&logger));
1182+
let network_graph = NetworkGraph::new(genesis_hash);
1183+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger));
11521184
(secp_ctx, net_graph_msg_handler)
11531185
}
11541186

@@ -1309,7 +1341,8 @@ mod tests {
13091341
};
13101342

13111343
// Test if the UTXO lookups were not supported
1312-
let mut net_graph_msg_handler = NetGraphMsgHandler::new(genesis_block(Network::Testnet).header.block_hash(), None, Arc::clone(&logger));
1344+
let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
1345+
let mut net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger));
13131346
match net_graph_msg_handler.handle_channel_announcement(&valid_announcement) {
13141347
Ok(res) => assert!(res),
13151348
_ => panic!()
@@ -1333,7 +1366,8 @@ mod tests {
13331366
// Test if an associated transaction were not on-chain (or not confirmed).
13341367
let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
13351368
*chain_source.utxo_ret.lock().unwrap() = Err(chain::AccessError::UnknownTx);
1336-
net_graph_msg_handler = NetGraphMsgHandler::new(chain_source.clone().genesis_hash, Some(chain_source.clone()), Arc::clone(&logger));
1369+
let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
1370+
net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, Some(chain_source.clone()), Arc::clone(&logger));
13371371
unsigned_announcement.short_channel_id += 1;
13381372

13391373
msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
@@ -1457,7 +1491,8 @@ mod tests {
14571491
let secp_ctx = Secp256k1::new();
14581492
let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::new());
14591493
let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
1460-
let net_graph_msg_handler = NetGraphMsgHandler::new(genesis_block(Network::Testnet).header.block_hash(), Some(chain_source.clone()), Arc::clone(&logger));
1494+
let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
1495+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, Some(chain_source.clone()), Arc::clone(&logger));
14611496

14621497
let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
14631498
let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
@@ -1621,8 +1656,14 @@ mod tests {
16211656
}
16221657

16231658
#[test]
1624-
fn handling_htlc_fail_channel_update() {
1625-
let (secp_ctx, net_graph_msg_handler) = create_net_graph_msg_handler();
1659+
fn handling_network_update() {
1660+
let logger = test_utils::TestLogger::new();
1661+
let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
1662+
let genesis_hash = genesis_block(Network::Testnet).header.block_hash();
1663+
let network_graph = NetworkGraph::new(genesis_hash);
1664+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, Some(chain_source.clone()), &logger);
1665+
let secp_ctx = Secp256k1::new();
1666+
16261667
let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
16271668
let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
16281669
let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
@@ -1632,11 +1673,11 @@ mod tests {
16321673

16331674
let short_channel_id = 0;
16341675
let chain_hash = genesis_block(Network::Testnet).header.block_hash();
1676+
let network_graph = &net_graph_msg_handler.network_graph;
16351677

16361678
{
16371679
// There is no nodes in the table at the beginning.
1638-
let network = &net_graph_msg_handler.network_graph;
1639-
assert_eq!(network.read_only().nodes().len(), 0);
1680+
assert_eq!(network_graph.read_only().nodes().len(), 0);
16401681
}
16411682

16421683
{
@@ -1660,10 +1701,9 @@ mod tests {
16601701
bitcoin_signature_2: secp_ctx.sign(&msghash, node_2_btckey),
16611702
contents: unsigned_announcement.clone(),
16621703
};
1663-
match net_graph_msg_handler.handle_channel_announcement(&valid_channel_announcement) {
1664-
Ok(_) => (),
1665-
Err(_) => panic!()
1666-
};
1704+
let chain_source: Option<&test_utils::TestChainSource> = None;
1705+
assert!(network_graph.update_channel_from_announcement(&valid_channel_announcement, &chain_source, &secp_ctx).is_ok());
1706+
assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
16671707

16681708
let unsigned_channel_update = UnsignedChannelUpdate {
16691709
chain_hash,
@@ -1683,44 +1723,65 @@ mod tests {
16831723
contents: unsigned_channel_update.clone()
16841724
};
16851725

1686-
match net_graph_msg_handler.handle_channel_update(&valid_channel_update) {
1687-
Ok(res) => assert!(res),
1688-
_ => panic!()
1689-
};
1726+
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
1727+
1728+
net_graph_msg_handler.handle_event(&Event::PaymentFailed {
1729+
payment_hash: PaymentHash([0; 32]),
1730+
rejected_by_dest: false,
1731+
network_update: Some(NetworkUpdate::ChannelUpdateMessage {
1732+
msg: valid_channel_update,
1733+
}),
1734+
error_code: None,
1735+
error_data: None,
1736+
});
1737+
1738+
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
16901739
}
16911740

16921741
// Non-permanent closing just disables a channel
16931742
{
1694-
let network = &net_graph_msg_handler.network_graph;
1695-
match network.read_only().channels().get(&short_channel_id) {
1743+
match network_graph.read_only().channels().get(&short_channel_id) {
16961744
None => panic!(),
16971745
Some(channel_info) => {
1698-
assert!(channel_info.one_to_two.is_some());
1746+
assert!(channel_info.one_to_two.as_ref().unwrap().enabled);
16991747
}
17001748
};
1701-
}
17021749

1703-
net_graph_msg_handler.network_graph.close_channel_from_update(short_channel_id, false);
1750+
net_graph_msg_handler.handle_event(&Event::PaymentFailed {
1751+
payment_hash: PaymentHash([0; 32]),
1752+
rejected_by_dest: false,
1753+
network_update: Some(NetworkUpdate::ChannelClosed {
1754+
short_channel_id,
1755+
is_permanent: false,
1756+
}),
1757+
error_code: None,
1758+
error_data: None,
1759+
});
17041760

1705-
// Non-permanent closing just disables a channel
1706-
{
1707-
let network = &net_graph_msg_handler.network_graph;
1708-
match network.read_only().channels().get(&short_channel_id) {
1761+
match network_graph.read_only().channels().get(&short_channel_id) {
17091762
None => panic!(),
17101763
Some(channel_info) => {
17111764
assert!(!channel_info.one_to_two.as_ref().unwrap().enabled);
17121765
}
17131766
};
17141767
}
17151768

1716-
net_graph_msg_handler.network_graph.close_channel_from_update(short_channel_id, true);
1717-
17181769
// Permanent closing deletes a channel
17191770
{
1720-
let network = &net_graph_msg_handler.network_graph;
1721-
assert_eq!(network.read_only().channels().len(), 0);
1771+
net_graph_msg_handler.handle_event(&Event::PaymentFailed {
1772+
payment_hash: PaymentHash([0; 32]),
1773+
rejected_by_dest: false,
1774+
network_update: Some(NetworkUpdate::ChannelClosed {
1775+
short_channel_id,
1776+
is_permanent: true,
1777+
}),
1778+
error_code: None,
1779+
error_data: None,
1780+
});
1781+
1782+
assert_eq!(network_graph.read_only().channels().len(), 0);
17221783
// Nodes are also deleted because there are no associated channels anymore
1723-
assert_eq!(network.read_only().nodes().len(), 0);
1784+
assert_eq!(network_graph.read_only().nodes().len(), 0);
17241785
}
17251786
// TODO: Test NetworkUpdate::NodeFailure, which is not implemented yet.
17261787
}

lightning/src/routing/router.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,10 @@ mod tests {
12961296
}
12971297

12981298
// Using the same keys for LN and BTC ids
1299-
fn add_channel(net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>, secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey,
1300-
node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64) {
1299+
fn add_channel(
1300+
net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
1301+
secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
1302+
) {
13011303
let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
13021304
let node_id_2 = PublicKey::from_secret_key(&secp_ctx, node_2_privkey);
13031305

@@ -1326,7 +1328,10 @@ mod tests {
13261328
};
13271329
}
13281330

1329-
fn update_channel(net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>, secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate) {
1331+
fn update_channel(
1332+
net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
1333+
secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
1334+
) {
13301335
let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
13311336
let valid_channel_update = ChannelUpdate {
13321337
signature: secp_ctx.sign(&msghash, node_privkey),
@@ -1339,8 +1344,10 @@ mod tests {
13391344
};
13401345
}
13411346

1342-
fn add_or_update_node(net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>, secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey,
1343-
features: NodeFeatures, timestamp: u32) {
1347+
fn add_or_update_node(
1348+
net_graph_msg_handler: &NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
1349+
secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
1350+
) {
13441351
let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
13451352
let unsigned_announcement = UnsignedNodeAnnouncement {
13461353
features,
@@ -1396,7 +1403,8 @@ mod tests {
13961403
let secp_ctx = Secp256k1::new();
13971404
let logger = Arc::new(test_utils::TestLogger::new());
13981405
let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
1399-
let net_graph_msg_handler = NetGraphMsgHandler::new(genesis_block(Network::Testnet).header.block_hash(), None, Arc::clone(&logger));
1406+
let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
1407+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger));
14001408
// Build network from our_id to node6:
14011409
//
14021410
// -1(1)2- node0 -1(3)2-
@@ -3947,7 +3955,8 @@ mod tests {
39473955
// "previous hop" being set to node 3, creating a loop in the path.
39483956
let secp_ctx = Secp256k1::new();
39493957
let logger = Arc::new(test_utils::TestLogger::new());
3950-
let net_graph_msg_handler = NetGraphMsgHandler::new(genesis_block(Network::Testnet).header.block_hash(), None, Arc::clone(&logger));
3958+
let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
3959+
let net_graph_msg_handler = NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger));
39513960
let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
39523961

39533962
add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);

0 commit comments

Comments
 (0)