TESTING
authorMatt Corallo <git@bluematt.me>
Fri, 1 Mar 2019 22:41:40 +0000 (17:41 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 3 Feb 2020 02:38:54 +0000 (21:38 -0500)
fuzz/src/full_stack.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs

index 6dedd1db66d89826db246530fb93ab2dd3d81fc4..720b9620529741421c27a6450911b6a65755fa6b 100644 (file)
@@ -96,6 +96,7 @@ struct FuzzEstimator {
 }
 impl FeeEstimator for FuzzEstimator {
        fn get_est_sat_per_1000_weight(&self, _: ConfirmationTarget) -> u64 {
+println!("fee_get");
                //TODO: We should actually be testing at least much more than 64k...
                match self.input.get_slice(2) {
                        Some(slice) => cmp::max(slice_to_be16(slice) as u64, 253),
@@ -383,7 +384,9 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
        let mut pending_funding_relay = Vec::new();
 
        loop {
-               match get_slice!(1)[0] {
+let a = get_slice!(1)[0];
+println!("action: {}", a);
+               match a {
                        0 => {
                                let mut new_id = 0;
                                for i in 1..256 {
@@ -548,13 +551,16 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
                        },
                        _ => return,
                }
+println!("PROCESSING EVENTS");
                loss_detector.handler.process_events();
                for event in loss_detector.manager.get_and_clear_pending_events() {
                        match event {
                                Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, output_script, .. } => {
+println!("fgr");
                                        pending_funding_generation.push((temporary_channel_id, channel_value_satoshis, output_script));
                                },
                                Event::FundingBroadcastSafe { funding_txo, .. } => {
+println!("fbs");
                                        pending_funding_relay.push(pending_funding_signatures.remove(&funding_txo).unwrap());
                                },
                                Event::PaymentReceived { payment_hash, payment_secret, amt } => {
@@ -564,6 +570,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
                                Event::PaymentSent {..} => {},
                                Event::PaymentFailed {..} => {},
                                Event::PendingHTLCsForwardable {..} => {
+println!("PENDING HTLCS FORWARDABLE");
                                        should_forward = true;
                                },
                                Event::SpendableOutputs {..} => {},
index d3767eb987f469e5e9bf2fe48c9325fd0a1f15a3..ed984ab8f62358ce191725013ba68008b4544ea4 100644 (file)
@@ -361,7 +361,7 @@ pub const OUR_MAX_HTLCS: u16 = 50; //TODO
 /// Confirmation count threshold at which we close a channel. Ideally we'd keep the channel around
 /// on ice until the funding transaction gets more confirmations, but the LN protocol doesn't
 /// really allow for this, so instead we're stuck closing it out at that point.
-const UNCONF_THRESHOLD: u32 = 6;
+const UNCONF_THRESHOLD: u32 = 1;
 const SPENDING_INPUT_FOR_A_OUTPUT_WEIGHT: u64 = 79; // prevout: 36, nSequence: 4, script len: 1, witness lengths: (3+1)/4, sig: 73/4, if-selector: 1, redeemScript: (6 ops + 2*33 pubkeys + 1*2 delay)/4
 const B_OUTPUT_PLUS_SPENDING_INPUT_WEIGHT: u64 = 104; // prevout: 40, nSequence: 4, script len: 1, witness lengths: 3/4, sig: 73/4, pubkey: 33/4, output: 31 (TODO: Wrong? Useless?)
 
@@ -536,7 +536,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                if (feerate_per_kw as u64) < fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background) {
                        return Err(ChannelError::Close("Peer's feerate much too low"));
                }
-               if (feerate_per_kw as u64) > fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) * 2 {
+               if (feerate_per_kw as u64) > fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) * 200 {
                        return Err(ChannelError::Close("Peer's feerate much too high"));
                }
                Ok(())
@@ -1677,6 +1677,7 @@ debug_assert!(false, "This should be triggerable, and we should add a test case
                                        None => {},
                                        Some(payment_hash) =>
                                                if payment_hash != htlc.payment_hash {
+                                                       println!("FAIL: {:?}, {:?}", htlc.payment_hash, payment_hash);
                                                        return Err(ChannelError::Close("Remote tried to fulfill HTLC with an incorrect preimage"));
                                                }
                                };
index fb917c93307d58908bdfd5ffc511a048814f7330..bcde81dd922b59bde534f0a1506b08924687ffb6 100644 (file)
@@ -692,6 +692,7 @@ impl<ChanSigner: ChannelKeys, M: Deref> ChannelManager<ChanSigner, M> where M::T
                let res = ChannelManager {
                        default_configuration: config.clone(),
                        genesis_hash: genesis_block(network).header.bitcoin_hash(),
+                       //genesis_hash: Sha256dHash::from_hex("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206").unwrap(),
                        fee_estimator: feeest.clone(),
                        monitor,
                        tx_broadcaster,