mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +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 res = channel.get_open_channel(self.genesis_hash.clone(), &*self.fee_estimator);
|
||||
let mut channel_state = self.channel_state.lock().unwrap();
|
||||
match channel_state.by_id.insert(channel.channel_id(), channel) {
|
||||
Some(_) => panic!("RNG is bad???"),
|
||||
None => {}
|
||||
match channel_state.by_id.entry(channel.channel_id()) {
|
||||
hash_map::Entry::Occupied(_) => {
|
||||
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();
|
||||
|
@ -2456,11 +2462,13 @@ mod tests {
|
|||
}
|
||||
impl Drop for Node {
|
||||
fn drop(&mut self) {
|
||||
if !::std::thread::panicking() {
|
||||
// Check that we processed all pending events
|
||||
assert_eq!(self.node.get_and_clear_pending_events().len(), 0);
|
||||
assert_eq!(self.chan_monitor.added_monitors.lock().unwrap().len(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_chan_between_nodes(node_a: &Node, node_b: &Node) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
node_a.node.create_channel(node_b.node.get_our_node_id(), 100000, 10001, 42).unwrap();
|
||||
|
|
|
@ -1011,7 +1011,9 @@ impl ChannelMonitor {
|
|||
|
||||
/// 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> {
|
||||
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 {
|
||||
( $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 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 amount = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue