Skip to content

Commit 71d22f7

Browse files
committed
[fuzz] Expand the amounts we can send in chanmon_consistency
This should make it a bit easier for the fuzzer to hit any given balance breakdown during run as well as tweaks the command strings to be more bit-pattern friendly.
1 parent acf68ed commit 71d22f7

File tree

1 file changed

+100
-58
lines changed

1 file changed

+100
-58
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 100 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
286286
let mut channel_txn = Vec::new();
287287
macro_rules! make_channel {
288288
($source: expr, $dest: expr, $chan_id: expr) => { {
289-
$source.create_channel($dest.get_our_node_id(), 10000000, 42, 0, None).unwrap();
289+
$source.create_channel($dest.get_our_node_id(), 100_000, 42, 0, None).unwrap();
290290
let open_channel = {
291291
let events = $source.get_and_clear_pending_msg_events();
292292
assert_eq!(events.len(), 1);
@@ -498,28 +498,28 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
498498
node_features: NodeFeatures::empty(),
499499
short_channel_id: $middle.1,
500500
channel_features: ChannelFeatures::empty(),
501-
fee_msat: 50000,
501+
fee_msat: 50_000,
502502
cltv_expiry_delta: 100,
503503
},RouteHop {
504504
pubkey: $dest.0.get_our_node_id(),
505505
node_features: NodeFeatures::empty(),
506506
short_channel_id: $dest.1,
507507
channel_features: ChannelFeatures::empty(),
508-
fee_msat: 5000000,
508+
fee_msat: 10_000_000,
509509
cltv_expiry_delta: 200,
510510
}],vec![RouteHop {
511511
pubkey: $middle.0.get_our_node_id(),
512512
node_features: NodeFeatures::empty(),
513513
short_channel_id: $middle.1,
514514
channel_features: ChannelFeatures::empty(),
515-
fee_msat: 50000,
515+
fee_msat: 50_000,
516516
cltv_expiry_delta: 100,
517517
},RouteHop {
518518
pubkey: $dest.0.get_our_node_id(),
519519
node_features: NodeFeatures::empty(),
520520
short_channel_id: $dest.1,
521521
channel_features: ChannelFeatures::empty(),
522-
fee_msat: 5000000,
522+
fee_msat: 10_000_000,
523523
cltv_expiry_delta: 200,
524524
}]],
525525
}, PaymentHash(payment_hash.into_inner()), &Some(PaymentSecret(payment_secret.into_inner()))) {
@@ -700,81 +700,83 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
700700
}
701701

702702
match get_slice!(1)[0] {
703+
// In general, we keep related message groups close together in binary form, allowing
704+
// bit-twiddling mutations to have similar effects. This is probably overkill, but no
705+
// harm in doing so.
706+
703707
0x00 => *monitor_a.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
704708
0x01 => *monitor_b.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
705709
0x02 => *monitor_c.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
706-
0x03 => *monitor_a.update_ret.lock().unwrap() = Ok(()),
707-
0x04 => *monitor_b.update_ret.lock().unwrap() = Ok(()),
708-
0x05 => *monitor_c.update_ret.lock().unwrap() = Ok(()),
709-
0x06 => {
710+
0x04 => *monitor_a.update_ret.lock().unwrap() = Ok(()),
711+
0x05 => *monitor_b.update_ret.lock().unwrap() = Ok(()),
712+
0x06 => *monitor_c.update_ret.lock().unwrap() = Ok(()),
713+
714+
0x08 => {
710715
if let Some((id, _)) = monitor_a.latest_monitors.lock().unwrap().get(&chan_1_funding) {
711716
nodes[0].channel_monitor_updated(&chan_1_funding, *id);
712717
}
713718
},
714-
0x07 => {
719+
0x09 => {
715720
if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_1_funding) {
716721
nodes[1].channel_monitor_updated(&chan_1_funding, *id);
717722
}
718723
},
719-
0x24 => {
724+
0x0a => {
720725
if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_2_funding) {
721726
nodes[1].channel_monitor_updated(&chan_2_funding, *id);
722727
}
723728
},
724-
0x08 => {
729+
0x0b => {
725730
if let Some((id, _)) = monitor_c.latest_monitors.lock().unwrap().get(&chan_2_funding) {
726731
nodes[2].channel_monitor_updated(&chan_2_funding, *id);
727732
}
728733
},
729-
0x09 => send_payment!(nodes[0], (&nodes[1], chan_a), 5_000_000),
730-
0x0a => send_payment!(nodes[1], (&nodes[0], chan_a), 5_000_000),
731-
0x0b => send_payment!(nodes[1], (&nodes[2], chan_b), 5_000_000),
732-
0x0c => send_payment!(nodes[2], (&nodes[1], chan_b), 5_000_000),
733-
0x0d => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 5_000_000),
734-
0x0e => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 5_000_000),
735-
0x0f => {
734+
735+
0x0c => {
736736
if !chan_a_disconnected {
737737
nodes[0].peer_disconnected(&nodes[1].get_our_node_id(), false);
738738
nodes[1].peer_disconnected(&nodes[0].get_our_node_id(), false);
739739
chan_a_disconnected = true;
740740
drain_msg_events_on_disconnect!(0);
741741
}
742742
},
743-
0x10 => {
743+
0x0d => {
744744
if !chan_b_disconnected {
745745
nodes[1].peer_disconnected(&nodes[2].get_our_node_id(), false);
746746
nodes[2].peer_disconnected(&nodes[1].get_our_node_id(), false);
747747
chan_b_disconnected = true;
748748
drain_msg_events_on_disconnect!(2);
749749
}
750750
},
751-
0x11 => {
751+
0x0e => {
752752
if chan_a_disconnected {
753753
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
754754
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: InitFeatures::empty() });
755755
chan_a_disconnected = false;
756756
}
757757
},
758-
0x12 => {
758+
0x0f => {
759759
if chan_b_disconnected {
760760
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: InitFeatures::empty() });
761761
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
762762
chan_b_disconnected = false;
763763
}
764764
},
765-
0x13 => process_msg_events!(0, true),
766-
0x14 => process_msg_events!(0, false),
767-
0x15 => process_events!(0, true),
768-
0x16 => process_events!(0, false),
769-
0x17 => process_msg_events!(1, true),
770-
0x18 => process_msg_events!(1, false),
771-
0x19 => process_events!(1, true),
772-
0x1a => process_events!(1, false),
773-
0x1b => process_msg_events!(2, true),
774-
0x1c => process_msg_events!(2, false),
775-
0x1d => process_events!(2, true),
776-
0x1e => process_events!(2, false),
777-
0x1f => {
765+
766+
0x10 => process_msg_events!(0, true),
767+
0x11 => process_msg_events!(0, false),
768+
0x12 => process_events!(0, true),
769+
0x13 => process_events!(0, false),
770+
0x14 => process_msg_events!(1, true),
771+
0x15 => process_msg_events!(1, false),
772+
0x16 => process_events!(1, true),
773+
0x17 => process_events!(1, false),
774+
0x18 => process_msg_events!(2, true),
775+
0x19 => process_msg_events!(2, false),
776+
0x1a => process_events!(2, true),
777+
0x1b => process_events!(2, false),
778+
779+
0x1c => {
778780
if !chan_a_disconnected {
779781
nodes[1].peer_disconnected(&nodes[0].get_our_node_id(), false);
780782
chan_a_disconnected = true;
@@ -785,7 +787,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
785787
nodes[0] = node_a.clone();
786788
monitor_a = new_monitor_a;
787789
},
788-
0x20 => {
790+
0x1d => {
789791
if !chan_a_disconnected {
790792
nodes[0].peer_disconnected(&nodes[1].get_our_node_id(), false);
791793
chan_a_disconnected = true;
@@ -803,7 +805,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
803805
nodes[1] = node_b.clone();
804806
monitor_b = new_monitor_b;
805807
},
806-
0x21 => {
808+
0x1e => {
807809
if !chan_b_disconnected {
808810
nodes[1].peer_disconnected(&nodes[2].get_our_node_id(), false);
809811
chan_b_disconnected = true;
@@ -814,27 +816,67 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
814816
nodes[2] = node_c.clone();
815817
monitor_c = new_monitor_c;
816818
},
817-
0x22 => send_payment_with_secret!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b)),
818-
0x23 => send_payment_with_secret!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a)),
819-
0x25 => send_payment!(nodes[0], (&nodes[1], chan_a), 10),
820-
0x26 => send_payment!(nodes[1], (&nodes[0], chan_a), 10),
821-
0x27 => send_payment!(nodes[1], (&nodes[2], chan_b), 10),
822-
0x28 => send_payment!(nodes[2], (&nodes[1], chan_b), 10),
823-
0x29 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10),
824-
0x2a => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10),
825-
0x2b => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000),
826-
0x2c => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000),
827-
0x2d => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000),
828-
0x2e => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000),
829-
0x2f => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000),
830-
0x30 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000),
831-
0x31 => send_payment!(nodes[0], (&nodes[1], chan_a), 100_000),
832-
0x32 => send_payment!(nodes[1], (&nodes[0], chan_a), 100_000),
833-
0x33 => send_payment!(nodes[1], (&nodes[2], chan_b), 100_000),
834-
0x34 => send_payment!(nodes[2], (&nodes[1], chan_b), 100_000),
835-
0x35 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100_000),
836-
0x36 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100_000),
837-
// 0x24 defined above
819+
820+
// 1/10th the channel size:
821+
0x20 => send_payment!(nodes[0], (&nodes[1], chan_a), 10_000_000),
822+
0x21 => send_payment!(nodes[1], (&nodes[0], chan_a), 10_000_000),
823+
0x22 => send_payment!(nodes[1], (&nodes[2], chan_b), 10_000_000),
824+
0x23 => send_payment!(nodes[2], (&nodes[1], chan_b), 10_000_000),
825+
0x24 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10_000_000),
826+
0x25 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10_000_000),
827+
828+
0x26 => send_payment_with_secret!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b)),
829+
0x27 => send_payment_with_secret!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a)),
830+
831+
0x28 => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000_000),
832+
0x29 => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000_000),
833+
0x2a => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000_000),
834+
0x2b => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000_000),
835+
0x2c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000_000),
836+
0x2d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000_000),
837+
838+
0x30 => send_payment!(nodes[0], (&nodes[1], chan_a), 100_000),
839+
0x31 => send_payment!(nodes[1], (&nodes[0], chan_a), 100_000),
840+
0x32 => send_payment!(nodes[1], (&nodes[2], chan_b), 100_000),
841+
0x33 => send_payment!(nodes[2], (&nodes[1], chan_b), 100_000),
842+
0x34 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100_000),
843+
0x35 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100_000),
844+
845+
0x38 => send_payment!(nodes[0], (&nodes[1], chan_a), 10_000),
846+
0x39 => send_payment!(nodes[1], (&nodes[0], chan_a), 10_000),
847+
0x3a => send_payment!(nodes[1], (&nodes[2], chan_b), 10_000),
848+
0x3b => send_payment!(nodes[2], (&nodes[1], chan_b), 10_000),
849+
0x3c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10_000),
850+
0x3d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10_000),
851+
852+
0x40 => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000),
853+
0x41 => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000),
854+
0x42 => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000),
855+
0x43 => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000),
856+
0x44 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000),
857+
0x45 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000),
858+
859+
0x48 => send_payment!(nodes[0], (&nodes[1], chan_a), 100),
860+
0x49 => send_payment!(nodes[1], (&nodes[0], chan_a), 100),
861+
0x4a => send_payment!(nodes[1], (&nodes[2], chan_b), 100),
862+
0x4b => send_payment!(nodes[2], (&nodes[1], chan_b), 100),
863+
0x4c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100),
864+
0x4d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100),
865+
866+
0x50 => send_payment!(nodes[0], (&nodes[1], chan_a), 10),
867+
0x51 => send_payment!(nodes[1], (&nodes[0], chan_a), 10),
868+
0x52 => send_payment!(nodes[1], (&nodes[2], chan_b), 10),
869+
0x53 => send_payment!(nodes[2], (&nodes[1], chan_b), 10),
870+
0x54 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10),
871+
0x55 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10),
872+
873+
0x58 => send_payment!(nodes[0], (&nodes[1], chan_a), 1),
874+
0x59 => send_payment!(nodes[1], (&nodes[0], chan_a), 1),
875+
0x5a => send_payment!(nodes[1], (&nodes[2], chan_b), 1),
876+
0x5b => send_payment!(nodes[2], (&nodes[1], chan_b), 1),
877+
0x5c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1),
878+
0x5d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1),
879+
838880
_ => test_return!(),
839881
}
840882

0 commit comments

Comments
 (0)