From 8dc5a3c14457faeb05087c562a8e91e7718355ce Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 24 Mar 2020 12:18:42 +0100 Subject: [PATCH] itest: wait for file writing in wait predicate --- lntest/itest/lnd_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 0e8237d0..482d2a7f 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -12717,12 +12717,16 @@ func testAbandonChannel(net *lntest.NetworkHarness, t *harnessTest) { } // Make sure the channel is no longer in the channel backup list. - bkupAfter, err := ioutil.ReadFile(net.Alice.ChanBackupPath()) + err = wait.Predicate(func() bool { + bkupAfter, err := ioutil.ReadFile(net.Alice.ChanBackupPath()) + if err != nil { + t.Fatalf("could not get channel backup before "+ + "abandoning channel: %v", err) + } + + return len(bkupAfter) < len(bkupBefore) + }, defaultTimeout) if err != nil { - t.Fatalf("could not get channel backup before abandoning "+ - "channel: %v", err) - } - if len(bkupAfter) >= len(bkupBefore) { t.Fatalf("channel wasn't removed from channel backup file") }