let nodes = create_nodes(2);
let test_msg = TestCustomMessage::Response;
- let path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::Node(nodes[1].node_id),
- first_node_addresses: None,
- };
- nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).unwrap();
+ let destination = Destination::Node(nodes[1].node_id);
+ nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap();
nodes[1].custom_message_handler.expect_message(TestCustomMessage::Response);
pass_along_path(&nodes);
}
destination: Destination::Node(nodes[2].node_id),
first_node_addresses: None,
};
+
nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).unwrap();
nodes[2].custom_message_handler.expect_message(TestCustomMessage::Response);
pass_along_path(&nodes);
let secp_ctx = Secp256k1::new();
let blinded_path = BlindedPath::new_for_message(&[nodes[1].node_id], &*nodes[1].entropy_source, &secp_ctx).unwrap();
- let path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
- nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).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);
pass_along_path(&nodes);
}
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 path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
+ let destination = Destination::BlindedPath(blinded_path);
- nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).unwrap();
+ nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap();
nodes[3].custom_message_handler.expect_message(TestCustomMessage::Response);
pass_along_path(&nodes);
}
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 path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
+ let destination = Destination::BlindedPath(blinded_path);
- nodes[0].messenger.send_onion_message_using_path(path, test_msg.clone(), None).unwrap();
+ nodes[0].messenger.send_onion_message(test_msg.clone(), destination, None).unwrap();
nodes[2].custom_message_handler.expect_message(TestCustomMessage::Response);
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 path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
- nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).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);
nodes.remove(2);
pass_along_path(&nodes);
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();
blinded_path.blinded_hops.clear();
- let path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
- let err = nodes[0].messenger.send_onion_message_using_path(path, test_msg.clone(), None).unwrap_err();
+ let destination = Destination::BlindedPath(blinded_path);
+ let err = nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap_err();
assert_eq!(err, SendError::TooFewBlindedHops);
}
// 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 path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::BlindedPath(blinded_path),
- first_node_addresses: None,
- };
+ 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();
- nodes[0].messenger.send_onion_message_using_path(path, test_msg, Some(reply_path)).unwrap();
+ nodes[0].messenger.send_onion_message(test_msg, destination, Some(reply_path)).unwrap();
nodes[3].custom_message_handler.expect_message(TestCustomMessage::Request);
pass_along_path(&nodes);
}
let test_msg = InvalidCustomMessage {};
- let path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::Node(nodes[1].node_id),
- first_node_addresses: None,
- };
- let err = nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).unwrap_err();
+ let destination = Destination::Node(nodes[1].node_id);
+ let err = nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap_err();
assert_eq!(err, SendError::InvalidMessage);
}
fn peer_buffer_full() {
let nodes = create_nodes(2);
let test_msg = TestCustomMessage::Request;
- let path = OnionMessagePath {
- intermediate_nodes: vec![],
- destination: Destination::Node(nodes[1].node_id),
- first_node_addresses: None,
- };
+ let destination = Destination::Node(nodes[1].node_id);
for _ in 0..188 { // Based on MAX_PER_PEER_BUFFER_SIZE in OnionMessenger
- nodes[0].messenger.send_onion_message_using_path(path.clone(), test_msg.clone(), None).unwrap();
+ nodes[0].messenger.send_onion_message(test_msg.clone(), destination.clone(), None).unwrap();
}
- let err = nodes[0].messenger.send_onion_message_using_path(path, test_msg, None).unwrap_err();
+ let err = nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap_err();
assert_eq!(err, SendError::BufferFull);
}