test: wrap assertion in WaitPredicate in testMultiHopReceiverChainClaim

This commit is contained in:
Olaoluwa Osuntokun 2018-01-22 21:06:27 -08:00
parent 99cc4be448
commit d0abb8219c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -5467,13 +5467,22 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
if _, err := net.Miner.Node.Generate(1); err != nil {
t.Fatalf("unable to mine block: %v", err)
}
err = lntest.WaitPredicate(func() bool {
pendingChanResp, err = carol.PendingChannels(ctxb, pendingChansRequest)
if err != nil {
t.Fatalf("unable to query for pending channels: %v", err)
predErr = fmt.Errorf("unable to query for pending channels: %v", err)
return false
}
if len(pendingChanResp.PendingForceClosingChannels) != 0 {
t.Fatalf("carol still has pending channels: %v",
predErr = fmt.Error("carol still has pending channels: %v",
spew.Sdump(pendingChanResp))
return false
}
return true
}, time.Second*15)
if err != nil {
t.Fatalf(predErr.Error())
}
// We'll close out the channel between Alice and Bob, then shutdown
@ -6067,6 +6076,11 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
t.Fatalf("unable to generate block: %v", err)
}
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
if err != nil {
t.Fatalf("unable to find bob's sweeping transaction")
}
// At this point, Bob should detect that he has no pending channels
// anymore, as this just resolved it by the confirmation of the sweep
// transaction we detected above.