mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 15:02:20 +01:00
rustfmt
: fuzz/src/invoice*.rs
This commit is contained in:
parent
9164e835e5
commit
f1ac0a3d97
2 changed files with 16 additions and 14 deletions
|
@ -7,17 +7,17 @@
|
||||||
// You may not use this file except in accordance with one or both of these
|
// You may not use this file except in accordance with one or both of these
|
||||||
// licenses.
|
// licenses.
|
||||||
|
|
||||||
use bitcoin::secp256k1::{Keypair, Parity, PublicKey, Secp256k1, SecretKey, self};
|
|
||||||
use crate::utils::test_logger;
|
use crate::utils::test_logger;
|
||||||
|
use bitcoin::secp256k1::{self, Keypair, Parity, PublicKey, Secp256k1, SecretKey};
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use lightning::blinded_path::BlindedPath;
|
|
||||||
use lightning::blinded_path::message::ForwardNode;
|
use lightning::blinded_path::message::ForwardNode;
|
||||||
use lightning::sign::EntropySource;
|
use lightning::blinded_path::BlindedPath;
|
||||||
use lightning::ln::PaymentHash;
|
|
||||||
use lightning::ln::features::BlindedHopFeatures;
|
use lightning::ln::features::BlindedHopFeatures;
|
||||||
|
use lightning::ln::PaymentHash;
|
||||||
use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice};
|
use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice};
|
||||||
use lightning::offers::invoice_request::InvoiceRequest;
|
use lightning::offers::invoice_request::InvoiceRequest;
|
||||||
use lightning::offers::parse::Bolt12SemanticError;
|
use lightning::offers::parse::Bolt12SemanticError;
|
||||||
|
use lightning::sign::EntropySource;
|
||||||
use lightning::util::ser::Writeable;
|
use lightning::util::ser::Writeable;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -38,17 +38,17 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
|
||||||
let even_pubkey = x_only_pubkey.public_key(Parity::Even);
|
let even_pubkey = x_only_pubkey.public_key(Parity::Even);
|
||||||
if signing_pubkey == odd_pubkey || signing_pubkey == even_pubkey {
|
if signing_pubkey == odd_pubkey || signing_pubkey == even_pubkey {
|
||||||
unsigned_invoice
|
unsigned_invoice
|
||||||
.sign(|message: &UnsignedBolt12Invoice|
|
.sign(|message: &UnsignedBolt12Invoice| {
|
||||||
Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
|
Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
|
||||||
)
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write(&mut buffer)
|
.write(&mut buffer)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
unsigned_invoice
|
unsigned_invoice
|
||||||
.sign(|message: &UnsignedBolt12Invoice|
|
.sign(|message: &UnsignedBolt12Invoice| {
|
||||||
Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
|
Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
|
||||||
)
|
})
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,9 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
|
||||||
struct Randomness;
|
struct Randomness;
|
||||||
|
|
||||||
impl EntropySource for 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 {
|
fn pubkey(byte: u8) -> PublicKey {
|
||||||
|
@ -71,7 +73,7 @@ fn privkey(byte: u8) -> SecretKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
|
fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
|
||||||
invoice_request: &InvoiceRequest, secp_ctx: &Secp256k1<T>
|
invoice_request: &InvoiceRequest, secp_ctx: &Secp256k1<T>,
|
||||||
) -> Result<UnsignedBolt12Invoice, Bolt12SemanticError> {
|
) -> Result<UnsignedBolt12Invoice, Bolt12SemanticError> {
|
||||||
let entropy_source = Randomness {};
|
let entropy_source = Randomness {};
|
||||||
let intermediate_nodes = [
|
let intermediate_nodes = [
|
||||||
|
@ -85,8 +87,10 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
let paths = vec![
|
let paths = vec![
|
||||||
BlindedPath::new_for_message(&intermediate_nodes[0], pubkey(42), &entropy_source, secp_ctx).unwrap(),
|
BlindedPath::new_for_message(&intermediate_nodes[0], pubkey(42), &entropy_source, secp_ctx)
|
||||||
BlindedPath::new_for_message(&intermediate_nodes[1], pubkey(42), &entropy_source, secp_ctx).unwrap(),
|
.unwrap(),
|
||||||
|
BlindedPath::new_for_message(&intermediate_nodes[1], pubkey(42), &entropy_source, secp_ctx)
|
||||||
|
.unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let payinfo = vec![
|
let payinfo = vec![
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
./bench/benches/bench.rs
|
./bench/benches/bench.rs
|
||||||
./fuzz/src/chanmon_consistency.rs
|
./fuzz/src/chanmon_consistency.rs
|
||||||
./fuzz/src/full_stack.rs
|
./fuzz/src/full_stack.rs
|
||||||
./fuzz/src/invoice_deser.rs
|
|
||||||
./fuzz/src/invoice_request_deser.rs
|
|
||||||
./fuzz/src/lib.rs
|
./fuzz/src/lib.rs
|
||||||
./fuzz/src/msg_targets/mod.rs
|
./fuzz/src/msg_targets/mod.rs
|
||||||
./fuzz/src/msg_targets/msg_accept_channel.rs
|
./fuzz/src/msg_targets/msg_accept_channel.rs
|
||||||
|
|
Loading…
Add table
Reference in a new issue