Skip to content

Commit

Permalink
Merge pull request lightningnetwork#5659 from guggero/unit-test-race-fix
Browse files Browse the repository at this point in the history
multi: fix unit test for high CPU load envs
  • Loading branch information
guggero authored Aug 24, 2021
2 parents 998abd1 + 1f3a6e1 commit 2835ceb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
17 changes: 10 additions & 7 deletions breacharbiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import (
)

var (
defaultTimeout = 30 * time.Second

breachOutPoints = []wire.OutPoint{
{
Hash: [chainhash.HashSize]byte{
Expand Down Expand Up @@ -1849,7 +1851,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {

select {
case contractBreaches <- breach:
case <-time.After(15 * time.Second):
case <-time.After(defaultTimeout):
t.Fatalf("breach not delivered")
}

Expand All @@ -1859,7 +1861,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
if err != nil {
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")
}

Expand Down Expand Up @@ -1895,7 +1897,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {

select {
case notifier.ConfChan <- &chainntnfs.TxConfirmation{}:
case <-time.After(15 * time.Second):
case <-time.After(defaultTimeout):
t.Fatalf("conf not delivered")
}

Expand All @@ -1904,7 +1906,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
var justiceTx *wire.MsgTx
select {
case justiceTx = <-publTx:
case <-time.After(5 * time.Second):
case <-time.After(defaultTimeout):
t.Fatalf("tx was not published")
}

Expand All @@ -1920,6 +1922,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {

// Now we'll pretend some blocks pass without the justice tx
// confirming.
const pollInterval = 500 * time.Millisecond
for i := int32(0); i <= 3; i++ {
notifier.EpochChan <- &chainntnfs.BlockEpoch{
Height: blockHeight + i,
Expand All @@ -1929,7 +1932,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
select {
case <-publTx:
t.Fatalf("tx was published")
case <-time.After(20 * time.Millisecond):
case <-time.After(pollInterval):
}
}

Expand All @@ -1952,7 +1955,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
case tx = <-publTx:
splits = append(splits, tx)

case <-time.After(5 * time.Second):
case <-time.After(defaultTimeout):
t.Fatalf("tx not published")
}

Expand Down Expand Up @@ -1997,7 +2000,7 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
)
}

case <-time.After(5 * time.Second):
case <-time.After(defaultTimeout):
t.Fatalf("tx not published")
}

Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ you.

* [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

* [Outdated warning about unsupported pruning was replaced with clarification that LND **does**
Expand Down
2 changes: 1 addition & 1 deletion walletunlocker/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (

testRecoveryWindow uint32 = 150

defaultTestTimeout = 3 * time.Second
defaultTestTimeout = 30 * time.Second

defaultRootKeyIDContext = macaroons.ContextWithRootKeyID(
context.Background(), macaroons.DefaultRootKeyID,
Expand Down

0 comments on commit 2835ceb

Please sign in to comment.