X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fsign%2Fmod.rs;h=da24510866e775742e9721cf0f68bdc0bd6774c2;hb=a71000f35dd23949d26fffd421d6f6478f0cd6b5;hp=cd898f12b32e41ca7523f79843f4a1ceff3407be;hpb=8c0479ac539ebcb41ad7cce8fda5ff15772c0cff;p=rust-lightning diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index cd898f12..da245108 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -689,6 +689,7 @@ pub trait SignerProvider { /// /// This implementation performs no policy checks and is insufficient by itself as /// a secure external signer. +#[derive(Debug)] pub struct InMemorySigner { /// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the /// holder's anchor output in a commitment transaction, if one is present. @@ -718,6 +719,21 @@ pub struct InMemorySigner { rand_bytes_index: AtomicCounter, } +impl PartialEq for InMemorySigner { + fn eq(&self, other: &Self) -> bool { + self.funding_key == other.funding_key && + self.revocation_base_key == other.revocation_base_key && + self.payment_key == other.payment_key && + self.delayed_payment_base_key == other.delayed_payment_base_key && + self.htlc_base_key == other.htlc_base_key && + self.commitment_seed == other.commitment_seed && + self.holder_channel_pubkeys == other.holder_channel_pubkeys && + self.channel_parameters == other.channel_parameters && + self.channel_value_satoshis == other.channel_value_satoshis && + self.channel_keys_id == other.channel_keys_id + } +} + impl Clone for InMemorySigner { fn clone(&self) -> Self { Self { @@ -1628,8 +1644,8 @@ pub fn dyn_sign() { let _signer: Box; } -#[cfg(all(test, feature = "_bench_unstable", not(feature = "no-std")))] -mod benches { +#[cfg(ldk_bench)] +pub mod benches { use std::sync::{Arc, mpsc}; use std::sync::mpsc::TryRecvError; use std::thread; @@ -1638,10 +1654,9 @@ mod benches { use bitcoin::Network; use crate::sign::{EntropySource, KeysManager}; - use test::Bencher; + use criterion::Criterion; - #[bench] - fn bench_get_secure_random_bytes(bench: &mut Bencher) { + pub fn bench_get_secure_random_bytes(bench: &mut Criterion) { let seed = [0u8; 32]; let now = Duration::from_secs(genesis_block(Network::Testnet).header.time as u64); let keys_manager = Arc::new(KeysManager::new(&seed, now.as_secs(), now.subsec_micros())); @@ -1667,11 +1682,8 @@ mod benches { stops.push(stop_sender); } - bench.iter(|| { - for _ in 1..100 { - keys_manager.get_secure_random_bytes(); - } - }); + bench.bench_function("get_secure_random_bytes", |b| b.iter(|| + keys_manager.get_secure_random_bytes())); for stop in stops { let _ = stop.send(()); @@ -1680,5 +1692,4 @@ mod benches { handle.join().unwrap(); } } - }