Skip to content

Commit afa3249

Browse files
committed
f no-std test
1 parent 1e8a6a3 commit afa3249

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

lightning/src/routing/gossip.rs

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,57 +2438,59 @@ mod tests {
24382438
// Nodes are also deleted because there are no associated channels anymore
24392439
assert_eq!(network_graph.read_only().nodes().len(), 0);
24402440

2441-
// Get a new network graph since we don't want to track removed nodes in this test
2442-
let network_graph = NetworkGraph::new(genesis_hash, &logger);
2441+
#[cfg(feature = "std")]
2442+
{
2443+
// Get a new network graph since we don't want to track removed nodes in this test
2444+
let network_graph = NetworkGraph::new(genesis_hash, &logger);
24432445

2444-
// Announce a channel to test permanent node failure
2445-
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
2446-
let short_channel_id = valid_channel_announcement.contents.short_channel_id;
2447-
let chain_source: Option<&test_utils::TestChainSource> = None;
2448-
assert!(network_graph.update_channel_from_announcement(&valid_channel_announcement, &chain_source).is_ok());
2449-
assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
2446+
// Announce a channel to test permanent node failure
2447+
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
2448+
let short_channel_id = valid_channel_announcement.contents.short_channel_id;
2449+
let chain_source: Option<&test_utils::TestChainSource> = None;
2450+
assert!(network_graph.update_channel_from_announcement(&valid_channel_announcement, &chain_source).is_ok());
2451+
assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
24502452

2451-
// Non-permanent node failure does not delete any nodes or channels
2452-
network_graph.handle_event(&Event::PaymentPathFailed {
2453-
payment_id: None,
2454-
payment_hash: PaymentHash([0; 32]),
2455-
rejected_by_dest: false,
2456-
all_paths_failed: true,
2457-
path: vec![],
2458-
network_update: Some(NetworkUpdate::NodeFailure {
2459-
node_id: node_2_id,
2460-
is_permanent: false,
2461-
}),
2462-
short_channel_id: None,
2463-
retry: None,
2464-
error_code: None,
2465-
error_data: None,
2466-
});
2453+
// Non-permanent node failure does not delete any nodes or channels
2454+
network_graph.handle_event(&Event::PaymentPathFailed {
2455+
payment_id: None,
2456+
payment_hash: PaymentHash([0; 32]),
2457+
rejected_by_dest: false,
2458+
all_paths_failed: true,
2459+
path: vec![],
2460+
network_update: Some(NetworkUpdate::NodeFailure {
2461+
node_id: node_2_id,
2462+
is_permanent: false,
2463+
}),
2464+
short_channel_id: None,
2465+
retry: None,
2466+
error_code: None,
2467+
error_data: None,
2468+
});
24672469

2468-
assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
2469-
assert!(network_graph.read_only().nodes().get(&NodeId::from_pubkey(&node_2_id)).is_some());
2470+
assert!(network_graph.read_only().channels().get(&short_channel_id).is_some());
2471+
assert!(network_graph.read_only().nodes().get(&NodeId::from_pubkey(&node_2_id)).is_some());
24702472

2471-
// Permanent node failure deletes node and its channels
2472-
network_graph.handle_event(&Event::PaymentPathFailed {
2473-
payment_id: None,
2474-
payment_hash: PaymentHash([0; 32]),
2475-
rejected_by_dest: false,
2476-
all_paths_failed: true,
2477-
path: vec![],
2478-
network_update: Some(NetworkUpdate::NodeFailure {
2479-
node_id: node_2_id,
2480-
is_permanent: true,
2481-
}),
2482-
short_channel_id: None,
2483-
retry: None,
2484-
error_code: None,
2485-
error_data: None,
2486-
});
2473+
// Permanent node failure deletes node and its channels
2474+
network_graph.handle_event(&Event::PaymentPathFailed {
2475+
payment_id: None,
2476+
payment_hash: PaymentHash([0; 32]),
2477+
rejected_by_dest: false,
2478+
all_paths_failed: true,
2479+
path: vec![],
2480+
network_update: Some(NetworkUpdate::NodeFailure {
2481+
node_id: node_2_id,
2482+
is_permanent: true,
2483+
}),
2484+
short_channel_id: None,
2485+
retry: None,
2486+
error_code: None,
2487+
error_data: None,
2488+
});
24872489

2488-
println!("{:?}", network_graph.read_only().nodes());
2489-
assert_eq!(network_graph.read_only().nodes().len(), 0);
2490-
// Channels are also deleted because the associated node has been deleted
2491-
assert_eq!(network_graph.read_only().channels().len(), 0);
2490+
assert_eq!(network_graph.read_only().nodes().len(), 0);
2491+
// Channels are also deleted because the associated node has been deleted
2492+
assert_eq!(network_graph.read_only().channels().len(), 0);
2493+
}
24922494
}
24932495

24942496
#[test]

0 commit comments

Comments
 (0)