Skip to content

Commit

Permalink
f fuzz DynSigner
Browse files Browse the repository at this point in the history
  • Loading branch information
devrandom committed Apr 27, 2024
1 parent affc49e commit c6114cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ use std::sync::{Arc,Mutex};
use std::sync::atomic;
use std::io::Cursor;
use bitcoin::bech32::u5;
use lightning::util::dyn_signer::DynSigner;

const MAX_FEE: u32 = 10_000;
struct FuzzEstimator {
Expand Down Expand Up @@ -276,6 +277,7 @@ impl SignerProvider for KeyProvider {
channel_keys_id,
);
let revoked_commitment = self.make_enforcement_state_cell(keys.commitment_seed);
let keys = DynSigner::new(keys);
TestChannelSigner::new_with_revoked(keys, revoked_commitment, false)
}

Expand All @@ -284,6 +286,7 @@ impl SignerProvider for KeyProvider {

let inner: InMemorySigner = ReadableArgs::read(&mut reader, self)?;
let state = self.make_enforcement_state_cell(inner.commitment_seed);
let inner = DynSigner::new(inner);

Ok(TestChannelSigner {
inner,
Expand Down
8 changes: 6 additions & 2 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use std::cmp;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicU64,AtomicUsize,Ordering};
use bitcoin::bech32::u5;
use lightning::util::dyn_signer::DynSigner;

#[inline]
pub fn slice_to_be16(v: &[u8]) -> u16 {
Expand Down Expand Up @@ -370,7 +371,7 @@ impl SignerProvider for KeyProvider {
let secp_ctx = Secp256k1::signing_only();
let ctr = channel_keys_id[0];
let (inbound, state) = self.signer_state.borrow().get(&ctr).unwrap().clone();
TestChannelSigner::new_with_revoked(if inbound {
let inner = if inbound {
InMemorySigner::new(
&secp_ctx,
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ctr]).unwrap(),
Expand All @@ -396,12 +397,15 @@ impl SignerProvider for KeyProvider {
channel_keys_id,
channel_keys_id,
)
}, state, false)
};
let inner = DynSigner::new(inner);
TestChannelSigner::new_with_revoked(inner, state, false)
}

fn read_chan_signer(&self, mut data: &[u8]) -> Result<TestChannelSigner, DecodeError> {
let inner: InMemorySigner = ReadableArgs::read(&mut data, self)?;
let state = Arc::new(Mutex::new(EnforcementState::new()));
let inner = DynSigner::new(inner);

Ok(TestChannelSigner::new_with_revoked(
inner,
Expand Down

0 comments on commit c6114cc

Please sign in to comment.