X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Ffunctional_tests.rs;h=89582305c2107baabcce522937ab13f793b0efbc;hb=ba1349982ba28657c9e2d03a5b02c3ecc054b5cc;hp=aee7f562defc5915517d696cf032353deee4e3d6;hpb=46fd7035b34de3035cec433558e27c823148fff1;p=rust-lightning diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index aee7f562..89582305 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -20,6 +20,7 @@ use bitcoin::network::constants::Network; use bitcoin::secp256k1::{PublicKey, Secp256k1}; use crate::io; +use crate::io_extras::read_to_end; use crate::sync::Arc; struct MessengerNode { @@ -59,8 +60,7 @@ impl CustomOnionMessageHandler for TestCustomMessageHandler { fn handle_custom_message(&self, _msg: Self::CustomMessage) {} fn read_custom_message(&self, message_type: u64, buffer: &mut R) -> Result, DecodeError> where Self: Sized { if message_type == CUSTOM_MESSAGE_TYPE { - let mut buf = Vec::new(); - buffer.read_to_end(&mut buf)?; + let buf = read_to_end(buffer)?; assert_eq!(buf, CUSTOM_MESSAGE_CONTENTS); return Ok(Some(TestCustomMessage {})) } @@ -104,8 +104,8 @@ fn pass_along_path(path: &Vec, expected_path_id: Option<[u8; 32]> node.messenger.handle_onion_message(&prev_node.get_node_pk(), &onion_msg); if idx == num_nodes - 1 { node.logger.assert_log_contains( - "lightning::onion_message::messenger".to_string(), - format!("Received an onion message with path_id: {:02x?}", expected_path_id).to_string(), 1); + "lightning::onion_message::messenger", + &format!("Received an onion message with path_id: {:02x?}", expected_path_id), 1); } prev_node = node; } @@ -218,8 +218,8 @@ fn reply_path() { pass_along_path(&nodes, None); // Make sure the last node successfully decoded the reply path. nodes[3].logger.assert_log_contains( - "lightning::onion_message::messenger".to_string(), - format!("Received an onion message with path_id None and a reply_path").to_string(), 1); + "lightning::onion_message::messenger", + &format!("Received an onion message with path_id None and a reply_path"), 1); // Destination::BlindedPath let blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap(); @@ -228,8 +228,8 @@ fn reply_path() { nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), Some(reply_path)).unwrap(); pass_along_path(&nodes, None); nodes[3].logger.assert_log_contains( - "lightning::onion_message::messenger".to_string(), - format!("Received an onion message with path_id None and a reply_path").to_string(), 2); + "lightning::onion_message::messenger", + &format!("Received an onion message with path_id None and a reply_path"), 2); } #[test]