Skip to content

Commit 642d03b

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 286a329 commit 642d03b

File tree

1 file changed

+96
-58
lines changed

1 file changed

+96
-58
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 96 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
245245
let mut channel_txn = Vec::new();
246246
macro_rules! make_channel {
247247
($source: expr, $dest: expr, $chan_id: expr) => { {
248-
$source.create_channel($dest.get_our_node_id(), 10000000, 42, 0, None).unwrap();
248+
$source.create_channel($dest.get_our_node_id(), 100_000, 42, 0, None).unwrap();
249249
let open_channel = {
250250
let events = $source.get_and_clear_pending_msg_events();
251251
assert_eq!(events.len(), 1);
@@ -497,28 +497,28 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
497497
node_features: NodeFeatures::empty(),
498498
short_channel_id: $middle.1,
499499
channel_features: ChannelFeatures::empty(),
500-
fee_msat: 50000,
500+
fee_msat: 50_000,
501501
cltv_expiry_delta: 100,
502502
},RouteHop {
503503
pubkey: $dest.0.get_our_node_id(),
504504
node_features: NodeFeatures::empty(),
505505
short_channel_id: $dest.1,
506506
channel_features: ChannelFeatures::empty(),
507-
fee_msat: 5000000,
507+
fee_msat: 10_000_000,
508508
cltv_expiry_delta: 200,
509509
}],vec![RouteHop {
510510
pubkey: $middle.0.get_our_node_id(),
511511
node_features: NodeFeatures::empty(),
512512
short_channel_id: $middle.1,
513513
channel_features: ChannelFeatures::empty(),
514-
fee_msat: 50000,
514+
fee_msat: 50_000,
515515
cltv_expiry_delta: 100,
516516
},RouteHop {
517517
pubkey: $dest.0.get_our_node_id(),
518518
node_features: NodeFeatures::empty(),
519519
short_channel_id: $dest.1,
520520
channel_features: ChannelFeatures::empty(),
521-
fee_msat: 5000000,
521+
fee_msat: 10_000_000,
522522
cltv_expiry_delta: 200,
523523
}]],
524524
}, PaymentHash(payment_hash.into_inner()), &Some(PaymentSecret(payment_secret.into_inner()))) {
@@ -702,78 +702,76 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
702702
0x00 => *monitor_a.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
703703
0x01 => *monitor_b.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
704704
0x02 => *monitor_c.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure),
705-
0x03 => *monitor_a.update_ret.lock().unwrap() = Ok(()),
706-
0x04 => *monitor_b.update_ret.lock().unwrap() = Ok(()),
707-
0x05 => *monitor_c.update_ret.lock().unwrap() = Ok(()),
708-
0x06 => {
705+
0x04 => *monitor_a.update_ret.lock().unwrap() = Ok(()),
706+
0x05 => *monitor_b.update_ret.lock().unwrap() = Ok(()),
707+
0x06 => *monitor_c.update_ret.lock().unwrap() = Ok(()),
708+
709+
0x08 => {
709710
if let Some((id, _)) = monitor_a.latest_monitors.lock().unwrap().get(&chan_1_funding) {
710711
nodes[0].channel_monitor_updated(&chan_1_funding, *id);
711712
}
712713
},
713-
0x07 => {
714+
0x09 => {
714715
if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_1_funding) {
715716
nodes[1].channel_monitor_updated(&chan_1_funding, *id);
716717
}
717718
},
718-
0x24 => {
719+
0x0a => {
719720
if let Some((id, _)) = monitor_b.latest_monitors.lock().unwrap().get(&chan_2_funding) {
720721
nodes[1].channel_monitor_updated(&chan_2_funding, *id);
721722
}
722723
},
723-
0x08 => {
724+
0x0b => {
724725
if let Some((id, _)) = monitor_c.latest_monitors.lock().unwrap().get(&chan_2_funding) {
725726
nodes[2].channel_monitor_updated(&chan_2_funding, *id);
726727
}
727728
},
728-
0x09 => send_payment!(nodes[0], (&nodes[1], chan_a), 5_000_000),
729-
0x0a => send_payment!(nodes[1], (&nodes[0], chan_a), 5_000_000),
730-
0x0b => send_payment!(nodes[1], (&nodes[2], chan_b), 5_000_000),
731-
0x0c => send_payment!(nodes[2], (&nodes[1], chan_b), 5_000_000),
732-
0x0d => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 5_000_000),
733-
0x0e => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 5_000_000),
734-
0x0f => {
729+
730+
0x0c => {
735731
if !chan_a_disconnected {
736732
nodes[0].peer_disconnected(&nodes[1].get_our_node_id(), false);
737733
nodes[1].peer_disconnected(&nodes[0].get_our_node_id(), false);
738734
chan_a_disconnected = true;
739735
drain_msg_events_on_disconnect!(0);
740736
}
741737
},
742-
0x10 => {
738+
0x0d => {
743739
if !chan_b_disconnected {
744740
nodes[1].peer_disconnected(&nodes[2].get_our_node_id(), false);
745741
nodes[2].peer_disconnected(&nodes[1].get_our_node_id(), false);
746742
chan_b_disconnected = true;
747743
drain_msg_events_on_disconnect!(2);
748744
}
749745
},
750-
0x11 => {
746+
0x0e => {
751747
if chan_a_disconnected {
752748
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
753749
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: InitFeatures::empty() });
754750
chan_a_disconnected = false;
755751
}
756752
},
757-
0x12 => {
753+
0x0f => {
758754
if chan_b_disconnected {
759755
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: InitFeatures::empty() });
760756
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: InitFeatures::empty() });
761757
chan_b_disconnected = false;
762758
}
763759
},
764-
0x13 => process_msg_events!(0, true),
765-
0x14 => process_msg_events!(0, false),
766-
0x15 => process_events!(0, true),
767-
0x16 => process_events!(0, false),
768-
0x17 => process_msg_events!(1, true),
769-
0x18 => process_msg_events!(1, false),
770-
0x19 => process_events!(1, true),
771-
0x1a => process_events!(1, false),
772-
0x1b => process_msg_events!(2, true),
773-
0x1c => process_msg_events!(2, false),
774-
0x1d => process_events!(2, true),
775-
0x1e => process_events!(2, false),
776-
0x1f => {
760+
761+
0x10 => process_msg_events!(0, true),
762+
0x11 => process_msg_events!(0, false),
763+
0x12 => process_events!(0, true),
764+
0x13 => process_events!(0, false),
765+
0x14 => process_msg_events!(1, true),
766+
0x15 => process_msg_events!(1, false),
767+
0x16 => process_events!(1, true),
768+
0x17 => process_events!(1, false),
769+
0x18 => process_msg_events!(2, true),
770+
0x19 => process_msg_events!(2, false),
771+
0x1a => process_events!(2, true),
772+
0x1b => process_events!(2, false),
773+
774+
0x1c => {
777775
if !chan_a_disconnected {
778776
nodes[1].peer_disconnected(&nodes[0].get_our_node_id(), false);
779777
chan_a_disconnected = true;
@@ -784,7 +782,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
784782
nodes[0] = node_a.clone();
785783
monitor_a = new_monitor_a;
786784
},
787-
0x20 => {
785+
0x1d => {
788786
if !chan_a_disconnected {
789787
nodes[0].peer_disconnected(&nodes[1].get_our_node_id(), false);
790788
chan_a_disconnected = true;
@@ -802,7 +800,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
802800
nodes[1] = node_b.clone();
803801
monitor_b = new_monitor_b;
804802
},
805-
0x21 => {
803+
0x1e => {
806804
if !chan_b_disconnected {
807805
nodes[1].peer_disconnected(&nodes[2].get_our_node_id(), false);
808806
chan_b_disconnected = true;
@@ -813,27 +811,67 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
813811
nodes[2] = node_c.clone();
814812
monitor_c = new_monitor_c;
815813
},
816-
0x22 => send_payment_with_secret!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b)),
817-
0x23 => send_payment_with_secret!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a)),
818-
0x25 => send_payment!(nodes[0], (&nodes[1], chan_a), 10),
819-
0x26 => send_payment!(nodes[1], (&nodes[0], chan_a), 10),
820-
0x27 => send_payment!(nodes[1], (&nodes[2], chan_b), 10),
821-
0x28 => send_payment!(nodes[2], (&nodes[1], chan_b), 10),
822-
0x29 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10),
823-
0x2a => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10),
824-
0x2b => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000),
825-
0x2c => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000),
826-
0x2d => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000),
827-
0x2e => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000),
828-
0x2f => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000),
829-
0x30 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000),
830-
0x31 => send_payment!(nodes[0], (&nodes[1], chan_a), 100_000),
831-
0x32 => send_payment!(nodes[1], (&nodes[0], chan_a), 100_000),
832-
0x33 => send_payment!(nodes[1], (&nodes[2], chan_b), 100_000),
833-
0x34 => send_payment!(nodes[2], (&nodes[1], chan_b), 100_000),
834-
0x35 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100_000),
835-
0x36 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100_000),
836-
// 0x24 defined above
814+
815+
// 1/10th the channel size:
816+
0x20 => send_payment!(nodes[0], (&nodes[1], chan_a), 10_000_000),
817+
0x21 => send_payment!(nodes[1], (&nodes[0], chan_a), 10_000_000),
818+
0x22 => send_payment!(nodes[1], (&nodes[2], chan_b), 10_000_000),
819+
0x23 => send_payment!(nodes[2], (&nodes[1], chan_b), 10_000_000),
820+
0x24 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10_000_000),
821+
0x25 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10_000_000),
822+
823+
0x26 => send_payment_with_secret!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b)),
824+
0x27 => send_payment_with_secret!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a)),
825+
826+
0x28 => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000_000),
827+
0x29 => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000_000),
828+
0x2a => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000_000),
829+
0x2b => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000_000),
830+
0x2c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000_000),
831+
0x2d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000_000),
832+
833+
0x30 => send_payment!(nodes[0], (&nodes[1], chan_a), 100_000),
834+
0x31 => send_payment!(nodes[1], (&nodes[0], chan_a), 100_000),
835+
0x32 => send_payment!(nodes[1], (&nodes[2], chan_b), 100_000),
836+
0x33 => send_payment!(nodes[2], (&nodes[1], chan_b), 100_000),
837+
0x34 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100_000),
838+
0x35 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100_000),
839+
840+
0x38 => send_payment!(nodes[0], (&nodes[1], chan_a), 10_000),
841+
0x39 => send_payment!(nodes[1], (&nodes[0], chan_a), 10_000),
842+
0x3a => send_payment!(nodes[1], (&nodes[2], chan_b), 10_000),
843+
0x3b => send_payment!(nodes[2], (&nodes[1], chan_b), 10_000),
844+
0x3c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10_000),
845+
0x3d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10_000),
846+
847+
0x40 => send_payment!(nodes[0], (&nodes[1], chan_a), 1_000),
848+
0x41 => send_payment!(nodes[1], (&nodes[0], chan_a), 1_000),
849+
0x42 => send_payment!(nodes[1], (&nodes[2], chan_b), 1_000),
850+
0x43 => send_payment!(nodes[2], (&nodes[1], chan_b), 1_000),
851+
0x44 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1_000),
852+
0x45 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1_000),
853+
854+
0x48 => send_payment!(nodes[0], (&nodes[1], chan_a), 100),
855+
0x49 => send_payment!(nodes[1], (&nodes[0], chan_a), 100),
856+
0x4a => send_payment!(nodes[1], (&nodes[2], chan_b), 100),
857+
0x4b => send_payment!(nodes[2], (&nodes[1], chan_b), 100),
858+
0x4c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 100),
859+
0x4d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 100),
860+
861+
0x50 => send_payment!(nodes[0], (&nodes[1], chan_a), 10),
862+
0x51 => send_payment!(nodes[1], (&nodes[0], chan_a), 10),
863+
0x52 => send_payment!(nodes[1], (&nodes[2], chan_b), 10),
864+
0x53 => send_payment!(nodes[2], (&nodes[1], chan_b), 10),
865+
0x54 => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 10),
866+
0x55 => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 10),
867+
868+
0x58 => send_payment!(nodes[0], (&nodes[1], chan_a), 1),
869+
0x59 => send_payment!(nodes[1], (&nodes[0], chan_a), 1),
870+
0x5a => send_payment!(nodes[1], (&nodes[2], chan_b), 1),
871+
0x5b => send_payment!(nodes[2], (&nodes[1], chan_b), 1),
872+
0x5c => send_payment!(nodes[0], (&nodes[1], chan_a), (&nodes[2], chan_b), 1),
873+
0x5d => send_payment!(nodes[2], (&nodes[1], chan_b), (&nodes[0], chan_a), 1),
874+
837875
_ => test_return!(),
838876
}
839877

0 commit comments

Comments
 (0)