From 3b986b4c143f4895ee88a9cec82044b2c62498cd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 21 Dec 2017 11:47:35 +0100 Subject: [PATCH] htlcswitch: extend timeouts within bandwidth consistency tests --- htlcswitch/link_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 179c66ff..6d41e308 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1540,7 +1540,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { htlc: htlc, } aliceLink.HandleSwitchPacket(&addPkt) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee) // If we now send in a valid HTLC settle for the prior HTLC we added, @@ -1551,7 +1551,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { PaymentPreimage: invoice.Terms.PaymentPreimage, } aliceLink.HandleChannelUpdate(htlcSettle) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt) // Next, we'll add another HTLC initiated by the switch (of the same @@ -1564,7 +1564,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { htlc: htlc, } aliceLink.HandleSwitchPacket(&addPkt) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt*2-htlcFee) // With that processed, we'll now generate an HTLC fail (sent by the @@ -1575,7 +1575,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { Reason: lnwire.OpaqueReason([]byte("nop")), } aliceLink.HandleChannelUpdate(failMsg) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt) // Moving along, we'll now receive a new HTLC from the remote peer, @@ -1589,7 +1589,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { PaymentHash: htlc.PaymentHash, // Re-using the same payment hash. } aliceLink.HandleChannelUpdate(updateMsg) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee) // Next, we'll settle the HTLC with our knowledge of the pre-image that @@ -1602,7 +1602,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { }, } aliceLink.HandleSwitchPacket(&settlePkt) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth) // Finally, we'll test the scenario of failing an HTLC received by the @@ -1614,7 +1614,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { PaymentHash: htlc.PaymentHash, } aliceLink.HandleChannelUpdate(htlcAdd) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcFee) failPkt := htlcPacket{ htlc: &lnwire.UpdateFailHTLC{ @@ -1622,7 +1622,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { }, } aliceLink.HandleSwitchPacket(&failPkt) - time.Sleep(time.Millisecond * 100) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth) } @@ -1683,6 +1683,7 @@ func TestChannelLinkBandwidthConsistencyOverflow(t *testing.T) { totalHtlcAmt += htlcAmt } + // TODO(roasbeef): increase sleep time.Sleep(time.Second * 1) commitWeight := lnwallet.CommitWeight + lnwallet.HtlcWeight*numHTLCs htlcFee := lnwire.NewMSatFromSatoshis( @@ -1740,7 +1741,7 @@ func TestChannelLinkBandwidthConsistencyOverflow(t *testing.T) { coreLink.overflowQueue.SignalFreeSlot() } - time.Sleep(time.Millisecond * 200) + time.Sleep(time.Millisecond * 500) assertLinkBandwidth(t, aliceLink, expectedBandwidth) // Finally, at this point, the queue itself should be fully empty. As