- {
- let mut network = router.network_map.write().unwrap();
-
- network.nodes.insert(node1.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(1, zero_hash.clone()), NetworkMap::get_key(3, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 100,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(1)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(1, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(1)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: false,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node1.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node2.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(2, zero_hash.clone()), NetworkMap::get_key(4, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(2)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(2, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(2)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node2.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node8.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(12, zero_hash.clone()), NetworkMap::get_key(13, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(8)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(12, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(12)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node8.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node3.clone(), NodeInfo {
- channels: vec!(
- NetworkMap::get_key(3, zero_hash.clone()),
- NetworkMap::get_key(4, zero_hash.clone()),
- NetworkMap::get_key(13, zero_hash.clone()),
- NetworkMap::get_key(5, zero_hash.clone()),
- NetworkMap::get_key(6, zero_hash.clone()),
- NetworkMap::get_key(7, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(3)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(3, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(3)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node1.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (3 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (3 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 100,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(4, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(4)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node2.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (4 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 1000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (4 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(13, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(13)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node8.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (13 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 2000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (13 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node4.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(5, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(4)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(5, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(5)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (5 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 100,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node4.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (5 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node5.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(6, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(5)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(6, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(6)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (6 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node5.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (6 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(11, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(11)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node5.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (11 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node4.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (11 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node6.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(7, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(6)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(7, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(7)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (7 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 1000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node6.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (7 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- }
-
- { // Simple route to 3 via 2
- let route = router.get_route(&node3, None, &Vec::new(), 100, 42).unwrap();
- assert_eq!(route.paths[0].len(), 2);
-
- assert_eq!(route.paths[0][0].pubkey, node2);
- assert_eq!(route.paths[0][0].short_channel_id, 2);
- assert_eq!(route.paths[0][0].fee_msat, 100);
- assert_eq!(route.paths[0][0].cltv_expiry_delta, (4 << 8) | 1);
- assert_eq!(route.paths[0][0].node_features.le_flags(), &id_to_feature_flags!(2));
- assert_eq!(route.paths[0][0].channel_features.le_flags(), &id_to_feature_flags!(2));
-
- assert_eq!(route.paths[0][1].pubkey, node3);
- assert_eq!(route.paths[0][1].short_channel_id, 4);
- assert_eq!(route.paths[0][1].fee_msat, 100);
- assert_eq!(route.paths[0][1].cltv_expiry_delta, 42);
- assert_eq!(route.paths[0][1].node_features.le_flags(), &id_to_feature_flags!(3));
- assert_eq!(route.paths[0][1].channel_features.le_flags(), &id_to_feature_flags!(4));
- }
-
- { // Disable channels 4 and 12 by requiring unknown feature bits
- let mut network = router.network_map.write().unwrap();
- network.channels.get_mut(&NetworkMap::get_key(4, zero_hash.clone())).unwrap().features.set_required_unknown_bits();
- network.channels.get_mut(&NetworkMap::get_key(12, zero_hash.clone())).unwrap().features.set_required_unknown_bits();
- }