diff --git a/lntest/harness.go b/lntest/harness.go index 0d8bf520..f83e7ae6 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -177,9 +177,16 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error { default: } + // First, make a connection between the two nodes. This will wait until + // both nodes are fully started since the Connect RPC is guarded behind + // the server.Started() flag that waits for all subsystems to be ready. + ctxb := context.Background() + if err := n.ConnectNodes(ctxb, n.Alice, n.Bob); err != nil { + return err + } + // Load up the wallets of the seeder nodes with 10 outputs of 1 BTC // each. - ctxb := context.Background() addrReq := &lnrpc.NewAddressRequest{ Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH, } @@ -216,8 +223,13 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error { return err } - // Finally, make a connection between both of the nodes. - if err := n.ConnectNodes(ctxb, n.Alice, n.Bob); err != nil { + // Now we want to wait for the nodes to catch up. + ctxt, cancel := context.WithTimeout(ctxb, DefaultTimeout) + defer cancel() + if err := n.Alice.WaitForBlockchainSync(ctxt); err != nil { + return err + } + if err := n.Bob.WaitForBlockchainSync(ctxt); err != nil { return err } 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 @@