Merge pull request #5659 from guggero/unit-test-race-fix

multi: fix unit test for high CPU load envs
This commit is contained in:
Oliver Gugger authored and GitHub committed 2021-08-24 15:16:28 +02:00
commit 2835cebe90
3 files changed
+16 -8

No files matched your search

+10 -7
View File
@@ -40,6 +40,8 @@ import (
) )
var ( var (
defaultTimeout = 30 * time.Second
breachOutPoints = []wire.OutPoint{ breachOutPoints = []wire.OutPoint{
{ {
Hash: [chainhash.HashSize]byte{ Hash: [chainhash.HashSize]byte{
@@ -1849,7 +1851,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
select { select {
case contractBreaches <- breach: case contractBreaches <- breach:
case <-time.After(15 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("breach not delivered") t.Fatalf("breach not delivered")
} }
@@ -1859,7 +1861,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("handoff failed: %v", err) t.Fatalf("handoff failed: %v", err)
} }
case <-time.After(time.Second * 15): case <-time.After(defaultTimeout):
t.Fatalf("breach arbiter didn't send ack back") t.Fatalf("breach arbiter didn't send ack back")
} }
@@ -1895,7 +1897,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
select { select {
case notifier.ConfChan <- &chainntnfs.TxConfirmation{}: case notifier.ConfChan <- &chainntnfs.TxConfirmation{}:
case <-time.After(15 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("conf not delivered") t.Fatalf("conf not delivered")
} }
@@ -1904,7 +1906,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
var justiceTx *wire.MsgTx var justiceTx *wire.MsgTx
select { select {
case justiceTx = <-publTx: case justiceTx = <-publTx:
case <-time.After(5 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("tx was not published") t.Fatalf("tx was not published")
} }
@@ -1920,6 +1922,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
// Now we'll pretend some blocks pass without the justice tx // Now we'll pretend some blocks pass without the justice tx
// confirming. // confirming.
const pollInterval = 500 * time.Millisecond
for i := int32(0); i <= 3; i++ { for i := int32(0); i <= 3; i++ {
notifier.EpochChan <- &chainntnfs.BlockEpoch{ notifier.EpochChan <- &chainntnfs.BlockEpoch{
Height: blockHeight + i, Height: blockHeight + i,
@@ -1929,7 +1932,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
select { select {
case <-publTx: case <-publTx:
t.Fatalf("tx was published") t.Fatalf("tx was published")
case <-time.After(20 * time.Millisecond): case <-time.After(pollInterval):
} }
} }
@@ -1952,7 +1955,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
case tx = <-publTx: case tx = <-publTx:
splits = append(splits, tx) splits = append(splits, tx)
case <-time.After(5 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("tx not published") t.Fatalf("tx not published")
} }
@@ -1997,7 +2000,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
) )
} }
case <-time.After(5 * time.Second): case <-time.After(defaultTimeout):
t.Fatalf("tx not published") t.Fatalf("tx not published")
} }
@@ -90,6 +90,11 @@ you.
* [The `lnwire` fuzz tests have been fixed and now run without crashing.](https://github.com/lightningnetwork/lnd/pull/5395) * [The `lnwire` fuzz tests have been fixed and now run without crashing.](https://github.com/lightningnetwork/lnd/pull/5395)
* [A flake in the race unit
tests](https://github.com/lightningnetwork/lnd/pull/5659) was addressed that
lead to failed tests sometimes when the CPU of the GitHub CI runner was
strained too much.
## Documentation ## Documentation
* [Outdated warning about unsupported pruning was replaced with clarification that LND **does** * [Outdated warning about unsupported pruning was replaced with clarification that LND **does**
+1 -1
View File
@@ -41,7 +41,7 @@ var (
testRecoveryWindow uint32 = 150 testRecoveryWindow uint32 = 150
defaultTestTimeout = 3 * time.Second defaultTestTimeout = 30 * time.Second
defaultRootKeyIDContext = macaroons.ContextWithRootKeyID( defaultRootKeyIDContext = macaroons.ContextWithRootKeyID(
context.Background(), macaroons.DefaultRootKeyID, context.Background(), macaroons.DefaultRootKeyID,