Skip to content

Commit 1ad6ce7

Browse files
committed
f Try fix fuzzer
1 parent e2d9146 commit 1ad6ce7

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use bitcoin::secp256k1::{self, Message, PublicKey, Scalar, Secp256k1, SecretKey}
8585
use lightning::util::dyn_signer::DynSigner;
8686

8787
use std::cell::RefCell;
88-
use std::cmp::{self, Ordering};
88+
use std::cmp;
8989
use std::mem;
9090
use std::sync::atomic;
9191
use std::sync::{Arc, Mutex};
@@ -1304,28 +1304,6 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
13041304
// deduplicate the calls here.
13051305
let mut claim_set = new_hash_map();
13061306
let mut events = nodes[$node].get_and_clear_pending_events();
1307-
// Sort events so that PendingHTLCsForwardable get processed last. This avoids a
1308-
// case where we first process a PendingHTLCsForwardable, then claim/fail on a
1309-
// PaymentClaimable, claiming/failing two HTLCs, but leaving a just-generated
1310-
// PaymentClaimable event for the second HTLC in our pending_events (and breaking
1311-
// our claim_set deduplication).
1312-
events.sort_by(|a, b| {
1313-
if let events::Event::PaymentClaimable { .. } = a {
1314-
if let events::Event::PendingHTLCsForwardable { .. } = b {
1315-
Ordering::Less
1316-
} else {
1317-
Ordering::Equal
1318-
}
1319-
} else if let events::Event::PendingHTLCsForwardable { .. } = a {
1320-
if let events::Event::PaymentClaimable { .. } = b {
1321-
Ordering::Greater
1322-
} else {
1323-
Ordering::Equal
1324-
}
1325-
} else {
1326-
Ordering::Equal
1327-
}
1328-
});
13291307
let had_events = !events.is_empty();
13301308
for event in events.drain(..) {
13311309
match event {
@@ -1352,9 +1330,6 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
13521330
},
13531331
events::Event::PaymentForwarded { .. } if $node == 1 => {},
13541332
events::Event::ChannelReady { .. } => {},
1355-
events::Event::PendingHTLCsForwardable { .. } => {
1356-
nodes[$node].process_pending_htlc_forwards();
1357-
},
13581333
events::Event::HTLCHandlingFailed { .. } => {},
13591334
_ => {
13601335
if out.may_fail.load(atomic::Ordering::Acquire) {
@@ -1365,6 +1340,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
13651340
},
13661341
}
13671342
}
1343+
nodes[$node].process_pending_htlc_forwards();
13681344
had_events
13691345
}};
13701346
}
@@ -1806,8 +1782,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
18061782
last_pass_no_updates = false;
18071783
continue;
18081784
}
1809-
// ...making sure any pending PendingHTLCsForwardable events are handled and
1810-
// payments claimed.
1785+
// ...making sure any payments are claimed.
18111786
if process_events!(0, false) {
18121787
last_pass_no_updates = false;
18131788
continue;

fuzz/src/full_stack.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
635635
let mut loss_detector =
636636
MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), peer_manager);
637637

638-
let mut should_forward = false;
639638
let mut payments_received: Vec<PaymentHash> = Vec::new();
640639
let mut intercepted_htlcs: Vec<InterceptId> = Vec::new();
641640
let mut payments_sent: u16 = 0;
@@ -785,10 +784,7 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
785784
}
786785
},
787786
7 => {
788-
if should_forward {
789-
channelmanager.process_pending_htlc_forwards();
790-
should_forward = false;
791-
}
787+
channelmanager.process_pending_htlc_forwards();
792788
},
793789
8 => {
794790
for payment in payments_received.drain(..) {
@@ -1004,9 +1000,6 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
10041000
//TODO: enhance by fetching random amounts from fuzz input?
10051001
payments_received.push(payment_hash);
10061002
},
1007-
Event::PendingHTLCsForwardable { .. } => {
1008-
should_forward = true;
1009-
},
10101003
Event::HTLCIntercepted { intercept_id, .. } => {
10111004
if !intercepted_htlcs.contains(&intercept_id) {
10121005
intercepted_htlcs.push(intercept_id);

0 commit comments

Comments
 (0)