chacha.process_in_place(packet_data);
if i == 0 {
- packet_data[ONION_DATA_LEN - filler.len()..ONION_DATA_LEN].copy_from_slice(&filler[..]);
+ let onion_data_len = packet_data.len();
+ packet_data[onion_data_len - filler.len()..onion_data_len].copy_from_slice(&filler[..]);
}
let mut hmac = HmacEngine::<Sha256>::new(&keys.mu);
let err = nodes[0].messenger.send_onion_message(&[], Destination::Node(nodes[1].get_node_pk()), OnionMessageContents::Custom(test_msg), None).unwrap_err();
assert_eq!(err, SendError::BufferFull);
}
+
+#[test]
+fn many_hops() {
+ // Check we can send over a route with many hops. This will exercise our logic for onion messages
+ // of size [`crate::onion_message::packet::BIG_PACKET_HOP_DATA_LEN`].
+ let num_nodes: usize = 25;
+ let nodes = create_nodes(num_nodes as u8);
+ let test_msg = OnionMessageContents::Custom(TestCustomMessage {});
+
+ let mut intermediates = vec![];
+ for i in 1..(num_nodes-1) {
+ intermediates.push(nodes[i].get_node_pk());
+ }
+
+ nodes[0].messenger.send_onion_message(&intermediates, Destination::Node(nodes[num_nodes-1].get_node_pk()), test_msg, None).unwrap();
+ pass_along_path(&nodes);
+}