Merge pull request #5748 from Roasbeef/flake-block-diff

routing: add wait.NoError to TestBlockDifferenceFix assertion [skip ci]
This commit is contained in:
Oliver Gugger authored and GitHub committed 2021-09-20 08:25:27 +02:00
commit d9f0f07142
2 files changed
+15 -5

No files matched your search

+1 -1
View File
@@ -313,7 +313,7 @@ you.
* [Catches up on blocks in the * [Catches up on blocks in the
router](https://github.com/lightningnetwork/lnd/pull/5315) in order to fix an router](https://github.com/lightningnetwork/lnd/pull/5315) in order to fix an
"out of order" error that crops up. "out of order" error that [crops up](https://github.com/lightningnetwork/lnd/pull/5748).
* [Fix healthcheck might be running after the max number of attempts are * [Fix healthcheck might be running after the max number of attempts are
reached](https://github.com/lightningnetwork/lnd/pull/5686). reached](https://github.com/lightningnetwork/lnd/pull/5686).
+14 -4
View File
@@ -23,6 +23,7 @@ import (
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
lnmock "github.com/lightningnetwork/lnd/lntest/mock" lnmock "github.com/lightningnetwork/lnd/lntest/mock"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/record" "github.com/lightningnetwork/lnd/record"
@@ -4274,6 +4275,7 @@ func TestBlockDifferenceFix(t *testing.T) {
t.Parallel() t.Parallel()
initialBlockHeight := uint32(0) initialBlockHeight := uint32(0)
// Starting height here is set to 0, which is behind where we want to be. // Starting height here is set to 0, which is behind where we want to be.
ctx, cleanup := createTestCtxSingleNode(t, initialBlockHeight) ctx, cleanup := createTestCtxSingleNode(t, initialBlockHeight)
defer cleanup() defer cleanup()
@@ -4330,9 +4332,17 @@ func TestBlockDifferenceFix(t *testing.T) {
<-ctx.chainView.notifyBlockAck <-ctx.chainView.notifyBlockAck
} }
// Then router height should be updated to the latest block. err := wait.NoError(func() error {
if atomic.LoadUint32(&ctx.router.bestHeight) != newBlockHeight { // Then router height should be updated to the latest block.
t.Fatalf("height should have been updated to %v, instead got "+ if atomic.LoadUint32(&ctx.router.bestHeight) != newBlockHeight {
"%v", newBlockHeight, ctx.router.bestHeight) return fmt.Errorf("height should have been updated "+
"to %v, instead got %v", newBlockHeight,
ctx.router.bestHeight)
}
return nil
}, testTimeout)
if err != nil {
t.Fatalf("block height wasn't updated: %v", err)
} }
} }