htlcswitch: extend timeouts within bandwidth consistency tests

This commit is contained in:
Olaoluwa Osuntokun committed 2017-12-21 11:47:45 +01:00
1 parent a93be76d16
commit 3b986b4c14
1 file changed
+10 -9
+10 -9
View File
@@ -1540,7 +1540,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) {
htlc: htlc, htlc: htlc,
} }
aliceLink.HandleSwitchPacket(&addPkt) aliceLink.HandleSwitchPacket(&addPkt)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee)
// If we now send in a valid HTLC settle for the prior HTLC we added, // 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, PaymentPreimage: invoice.Terms.PaymentPreimage,
} }
aliceLink.HandleChannelUpdate(htlcSettle) aliceLink.HandleChannelUpdate(htlcSettle)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt)
// Next, we'll add another HTLC initiated by the switch (of the same // Next, we'll add another HTLC initiated by the switch (of the same
@@ -1564,7 +1564,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) {
htlc: htlc, htlc: htlc,
} }
aliceLink.HandleSwitchPacket(&addPkt) aliceLink.HandleSwitchPacket(&addPkt)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt*2-htlcFee) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt*2-htlcFee)
// With that processed, we'll now generate an HTLC fail (sent by the // 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")), Reason: lnwire.OpaqueReason([]byte("nop")),
} }
aliceLink.HandleChannelUpdate(failMsg) aliceLink.HandleChannelUpdate(failMsg)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt)
// Moving along, we'll now receive a new HTLC from the remote peer, // 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. PaymentHash: htlc.PaymentHash, // Re-using the same payment hash.
} }
aliceLink.HandleChannelUpdate(updateMsg) aliceLink.HandleChannelUpdate(updateMsg)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcAmt-htlcFee)
// Next, we'll settle the HTLC with our knowledge of the pre-image that // 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) aliceLink.HandleSwitchPacket(&settlePkt)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth)
// Finally, we'll test the scenario of failing an HTLC received by the // 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, PaymentHash: htlc.PaymentHash,
} }
aliceLink.HandleChannelUpdate(htlcAdd) aliceLink.HandleChannelUpdate(htlcAdd)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcFee) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth-htlcFee)
failPkt := htlcPacket{ failPkt := htlcPacket{
htlc: &lnwire.UpdateFailHTLC{ htlc: &lnwire.UpdateFailHTLC{
@@ -1622,7 +1622,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) {
}, },
} }
aliceLink.HandleSwitchPacket(&failPkt) aliceLink.HandleSwitchPacket(&failPkt)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth) assertLinkBandwidth(t, aliceLink, aliceStartingBandwidth)
} }
@@ -1683,6 +1683,7 @@ func TestChannelLinkBandwidthConsistencyOverflow(t *testing.T) {
totalHtlcAmt += htlcAmt totalHtlcAmt += htlcAmt
} }
// TODO(roasbeef): increase sleep
time.Sleep(time.Second * 1) time.Sleep(time.Second * 1)
commitWeight := lnwallet.CommitWeight + lnwallet.HtlcWeight*numHTLCs commitWeight := lnwallet.CommitWeight + lnwallet.HtlcWeight*numHTLCs
htlcFee := lnwire.NewMSatFromSatoshis( htlcFee := lnwire.NewMSatFromSatoshis(
@@ -1740,7 +1741,7 @@ func TestChannelLinkBandwidthConsistencyOverflow(t *testing.T) {
coreLink.overflowQueue.SignalFreeSlot() coreLink.overflowQueue.SignalFreeSlot()
} }
time.Sleep(time.Millisecond * 200) time.Sleep(time.Millisecond * 500)
assertLinkBandwidth(t, aliceLink, expectedBandwidth) assertLinkBandwidth(t, aliceLink, expectedBandwidth)
// Finally, at this point, the queue itself should be fully empty. As // Finally, at this point, the queue itself should be fully empty. As