Skip to content

Commit f1a57ae

Browse files
Update chanmon fuzzer to include small payment actions.
This change should allow the fuzzer to catch more edge cases, such as channel reserve checks that cut it close when sending payments.
1 parent 6ca654a commit f1a57ae

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

fuzz/src/chanmon_consistency.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ pub fn do_test(data: &[u8]) {
405405

406406
loop {
407407
macro_rules! send_payment {
408-
($source: expr, $dest: expr) => { {
408+
($source: expr, $dest: expr, $amt: expr) => { {
409409
let payment_hash = Sha256::hash(&[payment_id; 1]);
410410
payment_id = payment_id.wrapping_add(1);
411411
if let Err(_) = $source.send_payment(Route {
@@ -414,15 +414,15 @@ pub fn do_test(data: &[u8]) {
414414
node_features: NodeFeatures::empty(),
415415
short_channel_id: $dest.1,
416416
channel_features: ChannelFeatures::empty(),
417-
fee_msat: 5000000,
417+
fee_msat: $amt,
418418
cltv_expiry_delta: 200,
419419
}],
420420
}, PaymentHash(payment_hash.into_inner())) {
421421
// Probably ran out of funds
422422
test_return!();
423423
}
424424
} };
425-
($source: expr, $middle: expr, $dest: expr) => { {
425+
($source: expr, $middle: expr, $dest: expr, $amt: expr) => { {
426426
let payment_hash = Sha256::hash(&[payment_id; 1]);
427427
payment_id = payment_id.wrapping_add(1);
428428
if let Err(_) = $source.send_payment(Route {
@@ -438,7 +438,7 @@ pub fn do_test(data: &[u8]) {
438438
node_features: NodeFeatures::empty(),
439439
short_channel_id: $dest.1,
440440
channel_features: ChannelFeatures::empty(),
441-
fee_msat: 5000000,
441+
fee_msat: $amt,
442442
cltv_expiry_delta: 200,
443443
}],
444444
}, PaymentHash(payment_hash.into_inner())) {
@@ -646,12 +646,12 @@ pub fn do_test(data: &[u8]) {
646646
nodes[2].channel_monitor_updated(&chan_2_funding, *id);
647647
}
648648
},
649-
0x09 => send_payment!(nodes[0], (&nodes[1], chan_a)),
650-
0x0a => send_payment!(nodes[1], (&nodes[0], chan_a)),
651-
0x0b => send_payment!(nodes[1], (&nodes[2], chan_b)),
652-
0x0c => send_payment!(nodes[2], (&nodes[1], chan_b)),
653-
0x0d => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b)),
654-
0x0e => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a)),
649+
0x09 => send_payment!(nodes[0], (&nodes[1], chan_a), 5000000),
650+
0x0a => send_payment!(nodes[1], (&nodes[0], chan_a), 5000000),
651+
0x0b => send_payment!(nodes[1], (&nodes[2], chan_b), 5000000),
652+
0x0c => send_payment!(nodes[2], (&nodes[1], chan_b), 5000000),
653+
0x0d => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 5000000),
654+
0x0e => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 5000000),
655655
0x0f => {
656656
if !chan_a_disconnected {
657657
nodes[0].peer_disconnected(&nodes[1].get_our_node_id(), false);
@@ -734,6 +734,12 @@ pub fn do_test(data: &[u8]) {
734734
nodes[2] = node_c.clone();
735735
monitor_c = new_monitor_c;
736736
},
737+
0x22 => send_payment!(nodes[0], (&nodes[1], chan_a), 20),
738+
0x23 => send_payment!(nodes[1], (&nodes[0], chan_a), 20),
739+
0x25 => send_payment!(nodes[1], (&nodes[2], chan_b), 20),
740+
0x26 => send_payment!(nodes[2], (&nodes[1], chan_b), 20),
741+
0x27 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 20),
742+
0x28 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 20),
737743
// 0x24 defined above
738744
_ => test_return!(),
739745
}

0 commit comments

Comments
 (0)