mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 23:30:59 +01:00
Merge pull request #197 from TheBlueMatt/master
Fix fuzztarget failures
This commit is contained in:
commit
d4ba4af057
2 changed files with 18 additions and 7 deletions
|
@ -365,9 +365,15 @@ impl ChannelManager {
|
||||||
let channel = Channel::new_outbound(&*self.fee_estimator, chan_keys, their_network_key, channel_value_satoshis, push_msat, self.announce_channels_publicly, user_id, Arc::clone(&self.logger))?;
|
let channel = Channel::new_outbound(&*self.fee_estimator, chan_keys, their_network_key, channel_value_satoshis, push_msat, self.announce_channels_publicly, user_id, Arc::clone(&self.logger))?;
|
||||||
let res = channel.get_open_channel(self.genesis_hash.clone(), &*self.fee_estimator);
|
let res = channel.get_open_channel(self.genesis_hash.clone(), &*self.fee_estimator);
|
||||||
let mut channel_state = self.channel_state.lock().unwrap();
|
let mut channel_state = self.channel_state.lock().unwrap();
|
||||||
match channel_state.by_id.insert(channel.channel_id(), channel) {
|
match channel_state.by_id.entry(channel.channel_id()) {
|
||||||
Some(_) => panic!("RNG is bad???"),
|
hash_map::Entry::Occupied(_) => {
|
||||||
None => {}
|
if cfg!(feature = "fuzztarget") {
|
||||||
|
return Err(APIError::APIMisuseError { err: "Fuzzy bad RNG" });
|
||||||
|
} else {
|
||||||
|
panic!("RNG is bad???");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hash_map::Entry::Vacant(entry) => { entry.insert(channel); }
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut events = self.pending_events.lock().unwrap();
|
let mut events = self.pending_events.lock().unwrap();
|
||||||
|
@ -2456,9 +2462,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
impl Drop for Node {
|
impl Drop for Node {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Check that we processed all pending events
|
if !::std::thread::panicking() {
|
||||||
assert_eq!(self.node.get_and_clear_pending_events().len(), 0);
|
// Check that we processed all pending events
|
||||||
assert_eq!(self.chan_monitor.added_monitors.lock().unwrap().len(), 0);
|
assert_eq!(self.node.get_and_clear_pending_events().len(), 0);
|
||||||
|
assert_eq!(self.chan_monitor.added_monitors.lock().unwrap().len(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1011,7 +1011,9 @@ impl ChannelMonitor {
|
||||||
|
|
||||||
/// Attempst to claim a remote HTLC-Success/HTLC-Timeout s outputs using the revocation key
|
/// Attempst to claim a remote HTLC-Success/HTLC-Timeout s outputs using the revocation key
|
||||||
fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64) -> Option<Transaction> {
|
fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64) -> Option<Transaction> {
|
||||||
let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
|
if tx.input.len() != 1 || tx.output.len() != 1 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! ignore_error {
|
macro_rules! ignore_error {
|
||||||
( $thing : expr ) => {
|
( $thing : expr ) => {
|
||||||
|
@ -1039,6 +1041,7 @@ impl ChannelMonitor {
|
||||||
};
|
};
|
||||||
let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
|
let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
|
||||||
let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
|
let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
|
||||||
|
let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
|
||||||
|
|
||||||
let mut inputs = Vec::new();
|
let mut inputs = Vec::new();
|
||||||
let mut amount = 0;
|
let mut amount = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue