//! Onion message testing and test utilities live here.
use crate::blinded_path::{BlindedPath, EmptyNodeIdLookUp};
+use crate::blinded_path::message::ForwardNode;
use crate::events::{Event, EventsProvider};
use crate::ln::features::{ChannelFeatures, InitFeatures};
use crate::ln::msgs::{self, DecodeError, OnionMessageHandler};
let test_msg = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
- let blinded_path = BlindedPath::new_for_message(&[nodes[1].node_id], &*nodes[1].entropy_source, &secp_ctx).unwrap();
+ let blinded_path = BlindedPath::new_for_message(&[], nodes[1].node_id, &*nodes[1].entropy_source, &secp_ctx).unwrap();
let destination = Destination::BlindedPath(blinded_path);
nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap();
nodes[1].custom_message_handler.expect_message(TestCustomMessage::Response);
let test_msg = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
- let blinded_path = BlindedPath::new_for_message(&[nodes[3].node_id, nodes[4].node_id], &*nodes[4].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [ForwardNode { node_id: nodes[3].node_id, short_channel_id: None }];
+ let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[4].node_id, &*nodes[4].entropy_source, &secp_ctx).unwrap();
let path = OnionMessagePath {
intermediate_nodes: vec![nodes[1].node_id, nodes[2].node_id],
destination: Destination::BlindedPath(blinded_path),
let test_msg = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
- let blinded_path = BlindedPath::new_for_message(&[nodes[1].node_id, nodes[2].node_id, nodes[3].node_id], &*nodes[3].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [
+ ForwardNode { node_id: nodes[1].node_id, short_channel_id: None },
+ ForwardNode { node_id: nodes[2].node_id, short_channel_id: None },
+ ];
+ let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[3].node_id, &*nodes[3].entropy_source, &secp_ctx).unwrap();
let destination = Destination::BlindedPath(blinded_path);
nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap();
let test_msg = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
- let blinded_path = BlindedPath::new_for_message(&[nodes[0].node_id, nodes[1].node_id, nodes[2].node_id], &*nodes[2].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [
+ ForwardNode { node_id: nodes[0].node_id, short_channel_id: None },
+ ForwardNode { node_id: nodes[1].node_id, short_channel_id: None },
+ ];
+ let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[2].node_id, &*nodes[2].entropy_source, &secp_ctx).unwrap();
let destination = Destination::BlindedPath(blinded_path);
nodes[0].messenger.send_onion_message(test_msg.clone(), destination, None).unwrap();
pass_along_path(&nodes);
// Try with a two-hop blinded path where we are the introduction node.
- let blinded_path = BlindedPath::new_for_message(&[nodes[0].node_id, nodes[1].node_id], &*nodes[1].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [ForwardNode { node_id: nodes[0].node_id, short_channel_id: None }];
+ let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[1].node_id, &*nodes[1].entropy_source, &secp_ctx).unwrap();
let destination = Destination::BlindedPath(blinded_path);
nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap();
nodes[1].custom_message_handler.expect_message(TestCustomMessage::Response);
let test_msg = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
- let mut blinded_path = BlindedPath::new_for_message(&[nodes[1].node_id, nodes[2].node_id], &*nodes[2].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }];
+ let mut blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[2].node_id, &*nodes[2].entropy_source, &secp_ctx).unwrap();
blinded_path.blinded_hops.clear();
let destination = Destination::BlindedPath(blinded_path);
let err = nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap_err();
destination: Destination::Node(nodes[3].node_id),
first_node_addresses: None,
};
- let reply_path = BlindedPath::new_for_message(&[nodes[2].node_id, nodes[1].node_id, nodes[0].node_id], &*nodes[0].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [
+ ForwardNode { node_id: nodes[2].node_id, short_channel_id: None },
+ ForwardNode { node_id: nodes[1].node_id, short_channel_id: None },
+ ];
+ let reply_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[0].node_id, &*nodes[0].entropy_source, &secp_ctx).unwrap();
nodes[0].messenger.send_onion_message_using_path(path, test_msg.clone(), Some(reply_path)).unwrap();
nodes[3].custom_message_handler.expect_message(TestCustomMessage::Request);
pass_along_path(&nodes);
pass_along_path(&nodes);
// Destination::BlindedPath
- let blinded_path = BlindedPath::new_for_message(&[nodes[1].node_id, nodes[2].node_id, nodes[3].node_id], &*nodes[3].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [
+ ForwardNode { node_id: nodes[1].node_id, short_channel_id: None },
+ ForwardNode { node_id: nodes[2].node_id, short_channel_id: None },
+ ];
+ let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[3].node_id, &*nodes[3].entropy_source, &secp_ctx).unwrap();
let destination = Destination::BlindedPath(blinded_path);
- let reply_path = BlindedPath::new_for_message(&[nodes[2].node_id, nodes[1].node_id, nodes[0].node_id], &*nodes[0].entropy_source, &secp_ctx).unwrap();
+ let intermediate_nodes = [
+ ForwardNode { node_id: nodes[2].node_id, short_channel_id: None },
+ ForwardNode { node_id: nodes[1].node_id, short_channel_id: None },
+ ];
+ let reply_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[0].node_id, &*nodes[0].entropy_source, &secp_ctx).unwrap();
nodes[0].messenger.send_onion_message(test_msg, destination, Some(reply_path)).unwrap();
nodes[3].custom_message_handler.expect_message(TestCustomMessage::Request);
let secp_ctx = Secp256k1::new();
add_channel_to_graph(&nodes[0], &nodes[1], &secp_ctx, 42);
+ let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }];
let blinded_path = BlindedPath::new_for_message(
- &[nodes[1].node_id, nodes[2].node_id], &*nodes[0].entropy_source, &secp_ctx
+ &intermediate_nodes, nodes[2].node_id, &*nodes[0].entropy_source, &secp_ctx
).unwrap();
let destination = Destination::BlindedPath(blinded_path);
let secp_ctx = Secp256k1::new();
add_channel_to_graph(&nodes[0], &nodes[1], &secp_ctx, 42);
+ let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }];
let blinded_path = BlindedPath::new_for_message(
- &[nodes[1].node_id, nodes[2].node_id], &*nodes[0].entropy_source, &secp_ctx
+ &intermediate_nodes, nodes[2].node_id, &*nodes[0].entropy_source, &secp_ctx
).unwrap();
let destination = Destination::BlindedPath(blinded_path);
let message = TestCustomMessage::Response;
let secp_ctx = Secp256k1::new();
+ let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }];
let blinded_path = BlindedPath::new_for_message(
- &[nodes[1].node_id, nodes[2].node_id], &*nodes[2].entropy_source, &secp_ctx
+ &intermediate_nodes, nodes[2].node_id, &*nodes[2].entropy_source, &secp_ctx
).unwrap();
let destination = Destination::BlindedPath(blinded_path);