From 8147b270d4716d81054c7fc54bff154fd215298a Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 7 May 2021 19:11:22 +0200 Subject: [PATCH] lntest: wait for chain sync in switch test --- lntest/itest/lnd_test.go | 20 +++++++++++++++++++- lntest/itest/log_error_whitelist.txt | 1 + lntest/itest/log_substitutions.txt | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index d3a86d4f..fcf21ea0 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -11787,7 +11787,15 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { err) } - time.Sleep(time.Millisecond * 50) + // Make sure all nodes are fully synced before we continue. + ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) + defer cancel() + for _, node := range nodes { + err := node.WaitForBlockchainSync(ctxt) + if err != nil { + t.Fatalf("unable to wait for sync: %v", err) + } + } // Using Carol as the source, pay to the 5 invoices from Bob created // above. @@ -11856,6 +11864,16 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("htlc mismatch: %v", predErr) } + // Make sure all nodes are fully synced again. + ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) + defer cancel() + for _, node := range nodes { + err := node.WaitForBlockchainSync(ctxt) + if err != nil { + t.Fatalf("unable to wait for sync: %v", err) + } + } + // Now that the settles have reached Dave, reconnect him with Alice, // allowing the settles to return to the sender. ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) diff --git a/lntest/itest/log_error_whitelist.txt b/lntest/itest/log_error_whitelist.txt index 2496b070..665b3266 100644 --- a/lntest/itest/log_error_whitelist.txt +++ b/lntest/itest/log_error_whitelist.txt @@ -155,6 +155,7 @@