Merge pull request #2931 from cfromknecht/channel-backup-flake

lnd_test: use WaitNoError when testing num singles in...
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2019-04-11 15:39:36 -07:00
commit 6963a92950
1 file changed
+16 -5
+16 -5
View File
@@ -13378,21 +13378,32 @@ func testExportChannelBackup(net *lntest.NetworkHarness, t *harnessTest) {
// Before we proceed, we'll make two utility methods we'll use below // Before we proceed, we'll make two utility methods we'll use below
// for our primary assertions. // for our primary assertions.
assertNumSingleBackups := func(numSingles int) { assertNumSingleBackups := func(numSingles int) {
err := lntest.WaitNoError(func() error {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
req := &lnrpc.ChanBackupExportRequest{} req := &lnrpc.ChanBackupExportRequest{}
chanSnapshot, err := carol.ExportAllChannelBackups(ctxt, req) chanSnapshot, err := carol.ExportAllChannelBackups(
ctxt, req,
)
if err != nil { if err != nil {
t.Fatalf("unable to export channel backup: %v", err) return fmt.Errorf("unable to export channel "+
"backup: %v", err)
} }
if chanSnapshot.SingleChanBackups == nil { if chanSnapshot.SingleChanBackups == nil {
t.Fatalf("single chan backups not populated") return fmt.Errorf("single chan backups not " +
"populated")
} }
backups := chanSnapshot.SingleChanBackups.ChanBackups backups := chanSnapshot.SingleChanBackups.ChanBackups
if len(backups) != numSingles { if len(backups) != numSingles {
t.Fatalf("expected %v singles, got %v", len(backups), return fmt.Errorf("expected %v singles, "+
numSingles) "got %v", len(backups), numSingles)
}
return nil
}, defaultTimeout)
if err != nil {
t.Fatalf(err.Error())
} }
} }
assertMultiBackupFound := func() func(bool, map[wire.OutPoint]struct{}) { assertMultiBackupFound := func() func(bool, map[wire.OutPoint]struct{}) {