X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Ffunctional_tests.rs;h=0193001b30c0d5ca4fc0421b27470a9fab81d0de;hb=10b8f4c44e94ef2f280decec43ee351502e2a218;hp=6540fc89cd0032160799bc9d109cf4f5d7b60442;hpb=8b442fe4eb80ee43121c3a0f7a364698a296b713;p=rust-lightning diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 6540fc89..0193001b 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -197,7 +197,7 @@ fn pass_along_path(path: &Vec) { } #[test] -fn one_hop() { +fn one_unblinded_hop() { let nodes = create_nodes(2); let test_msg = TestCustomMessage::Response; @@ -224,6 +224,22 @@ fn two_unblinded_hops() { pass_along_path(&nodes); } +#[test] +fn one_blinded_hop() { + let nodes = create_nodes(2); + let test_msg = TestCustomMessage::Response; + + let secp_ctx = Secp256k1::new(); + let blinded_path = BlindedPath::new_for_message(&[nodes[1].get_node_pk()], &*nodes[1].keys_manager, &secp_ctx).unwrap(); + let path = OnionMessagePath { + intermediate_nodes: vec![], + destination: Destination::BlindedPath(blinded_path), + }; + nodes[0].messenger.send_onion_message(path, test_msg, None).unwrap(); + nodes[1].custom_message_handler.expect_message(TestCustomMessage::Response); + pass_along_path(&nodes); +} + #[test] fn two_unblinded_two_blinded() { let nodes = create_nodes(5); @@ -320,17 +336,6 @@ fn invalid_blinded_path_error() { }; let err = nodes[0].messenger.send_onion_message(path, test_msg.clone(), None).unwrap_err(); assert_eq!(err, SendError::TooFewBlindedHops); - - // 1 hop - let mut blinded_path = BlindedPath::new_for_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap(); - blinded_path.blinded_hops.remove(0); - assert_eq!(blinded_path.blinded_hops.len(), 1); - let path = OnionMessagePath { - intermediate_nodes: vec![], - destination: Destination::BlindedPath(blinded_path), - }; - let err = nodes[0].messenger.send_onion_message(path, test_msg, None).unwrap_err(); - assert_eq!(err, SendError::TooFewBlindedHops); } #[test]