X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=fuzz%2Fsrc%2Frefund_deser.rs;h=11907b6d6965c121be2c6d612453d9169893b8d8;hb=65efd92c4a931b3b3622c84c6055bc015152fde0;hp=fd273d7e0284573e13899db7e8f510a0da49e0a7;hpb=af3a369ef1ce07057e07c24a1709b494ad62493b;p=rust-lightning diff --git a/fuzz/src/refund_deser.rs b/fuzz/src/refund_deser.rs index fd273d7e..11907b6d 100644 --- a/fuzz/src/refund_deser.rs +++ b/fuzz/src/refund_deser.rs @@ -7,16 +7,17 @@ // You may not use this file except in accordance with one or both of these // licenses. -use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey, self}; use crate::utils::test_logger; -use core::convert::{Infallible, TryFrom}; +use bitcoin::secp256k1::{self, Keypair, PublicKey, Secp256k1, SecretKey}; +use core::convert::TryFrom; +use lightning::blinded_path::message::ForwardNode; use lightning::blinded_path::BlindedPath; -use lightning::sign::EntropySource; -use lightning::ln::PaymentHash; use lightning::ln::features::BlindedHopFeatures; +use lightning::ln::PaymentHash; use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice}; use lightning::offers::parse::Bolt12SemanticError; use lightning::offers::refund::Refund; +use lightning::sign::EntropySource; use lightning::util::ser::Writeable; #[inline] @@ -27,15 +28,15 @@ pub fn do_test(data: &[u8], _out: Out) { assert_eq!(data, bytes); let secp_ctx = Secp256k1::new(); - let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); + let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); let pubkey = PublicKey::from(keys); let mut buffer = Vec::new(); if let Ok(invoice) = build_response(&refund, pubkey, &secp_ctx) { invoice - .sign::<_, Infallible>( - |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) - ) + .sign(|message: &UnsignedBolt12Invoice| { + Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) + }) .unwrap() .write(&mut buffer) .unwrap(); @@ -46,7 +47,9 @@ pub fn do_test(data: &[u8], _out: Out) { struct Randomness; impl EntropySource for Randomness { - fn get_secure_random_bytes(&self) -> [u8; 32] { [42; 32] } + fn get_secure_random_bytes(&self) -> [u8; 32] { + [42; 32] + } } fn pubkey(byte: u8) -> PublicKey { @@ -59,12 +62,24 @@ fn privkey(byte: u8) -> SecretKey { } fn build_response( - refund: &Refund, signing_pubkey: PublicKey, secp_ctx: &Secp256k1 + refund: &Refund, signing_pubkey: PublicKey, secp_ctx: &Secp256k1, ) -> Result { let entropy_source = Randomness {}; + let intermediate_nodes = [ + [ + ForwardNode { node_id: pubkey(43), short_channel_id: None }, + ForwardNode { node_id: pubkey(44), short_channel_id: None }, + ], + [ + ForwardNode { node_id: pubkey(45), short_channel_id: None }, + ForwardNode { node_id: pubkey(46), short_channel_id: None }, + ], + ]; let paths = vec![ - BlindedPath::new_for_message(&[pubkey(43), pubkey(44), pubkey(42)], &entropy_source, secp_ctx).unwrap(), - BlindedPath::new_for_message(&[pubkey(45), pubkey(46), pubkey(42)], &entropy_source, secp_ctx).unwrap(), + BlindedPath::new_for_message(&intermediate_nodes[0], pubkey(42), &entropy_source, secp_ctx) + .unwrap(), + BlindedPath::new_for_message(&intermediate_nodes[1], pubkey(42), &entropy_source, secp_ctx) + .unwrap(), ]; let payinfo = vec![