X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=fuzz%2Fsrc%2Fchanmon_consistency.rs;h=70ddac5d204225365a5be66b9c0348d69d3642d5;hb=69ee4860848d5992b238eca3343141004d9d1572;hp=38e12b8496bcc1c5ac0d6fe269acc38aeb8959a2;hpb=da298e498fc8bdf6af2b2becf82b0123118f46b4;p=rust-lightning diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 38e12b84..70ddac5d 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -241,6 +241,7 @@ fn check_api_err(api_err: APIError) { _ if err.starts_with("Cannot push more than their max accepted HTLCs ") => {}, _ if err.starts_with("Cannot send value that would put us over the max HTLC value in flight our peer will accept ") => {}, _ if err.starts_with("Cannot send value that would put our balance under counterparty-announced channel reserve value") => {}, + _ if err.starts_with("Cannot send value that would put counterparty balance under holder-announced channel reserve value") => {}, _ if err.starts_with("Cannot send value that would overdraw remaining funds.") => {}, _ if err.starts_with("Cannot send value that would not leave enough to pay for fees.") => {}, _ => panic!("{}", err), @@ -338,7 +339,7 @@ pub fn do_test(data: &[u8], out: Out) { let monitor = Arc::new(TestChainMonitor::new(broadcast.clone(), logger.clone(), fee_est.clone(), Arc::new(TestPersister{}), Arc::clone(&keys_manager))); let mut config = UserConfig::default(); - config.channel_options.fee_proportional_millionths = 0; + config.channel_options.forwarding_fee_proportional_millionths = 0; config.channel_options.announced_channel = true; let network = Network::Bitcoin; let params = ChainParameters { @@ -357,7 +358,7 @@ pub fn do_test(data: &[u8], out: Out) { let chain_monitor = Arc::new(TestChainMonitor::new(broadcast.clone(), logger.clone(), fee_est.clone(), Arc::new(TestPersister{}), Arc::clone(& $keys_manager))); let mut config = UserConfig::default(); - config.channel_options.fee_proportional_millionths = 0; + config.channel_options.forwarding_fee_proportional_millionths = 0; config.channel_options.announced_channel = true; let mut monitors = HashMap::new(); @@ -571,7 +572,12 @@ pub fn do_test(data: &[u8], out: Out) { events::MessageSendEvent::SendFundingLocked { .. } => continue, events::MessageSendEvent::SendAnnouncementSignatures { .. } => continue, events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => continue, - _ => panic!("Unhandled message event"), + events::MessageSendEvent::SendChannelUpdate { ref node_id, ref msg } => { + assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set! + if Some(*node_id) == expect_drop_id { panic!("peer_disconnected should drop msgs bound for the disconnected peer"); } + *node_id == a_id + }, + _ => panic!("Unhandled message event {:?}", event), }; if push_a { ba_events.push(event); } else { bc_events.push(event); } } @@ -692,7 +698,16 @@ pub fn do_test(data: &[u8], out: Out) { // Can be generated due to a payment forward being rejected due to a // channel having previously failed a monitor update }, - _ => panic!("Unhandled message event"), + events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => { + // When we reconnect we will resend a channel_update to make sure our + // counterparty has the latest parameters for receiving payments + // through us. We do, however, check that the message does not include + // the "disabled" bit, as we should never ever have a channel which is + // disabled when we send such an update (or it may indicate channel + // force-close which we should detect as an error). + assert_eq!(msg.contents.flags & 2, 0); + }, + _ => panic!("Unhandled message event {:?}", event), } if $limit_events != ProcessMessages::AllMessages { break; @@ -722,6 +737,9 @@ pub fn do_test(data: &[u8], out: Out) { events::MessageSendEvent::SendFundingLocked { .. } => {}, events::MessageSendEvent::SendAnnouncementSignatures { .. } => {}, events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => {}, + events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => { + assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set! + }, _ => panic!("Unhandled message event"), } } @@ -737,6 +755,9 @@ pub fn do_test(data: &[u8], out: Out) { events::MessageSendEvent::SendFundingLocked { .. } => {}, events::MessageSendEvent::SendAnnouncementSignatures { .. } => {}, events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => {}, + events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => { + assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set! + }, _ => panic!("Unhandled message event"), } } @@ -784,6 +805,7 @@ pub fn do_test(data: &[u8], out: Out) { }, events::Event::PaymentSent { .. } => {}, events::Event::PaymentFailed { .. } => {}, + events::Event::PaymentForwarded { .. } if $node == 1 => {}, events::Event::PendingHTLCsForwardable { .. } => { nodes[$node].process_pending_htlc_forwards(); },