htlcswitch/link_test: fix preimage assertion

This flakes locally for me on darwin.
This commit is contained in:
Conner Fromknecht 2020-04-07 11:53:15 -07:00
parent 425b2c712f
commit 2c3641e915
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -30,6 +30,7 @@ import (
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnpeer" "github.com/lightningnetwork/lnd/lnpeer"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
@ -4661,15 +4662,24 @@ func checkHasPreimages(t *testing.T, coreLink *channelLink,
t.Helper() t.Helper()
for i := range htlcs { err := wait.NoError(func() error {
_, ok := coreLink.cfg.PreimageCache.LookupPreimage( for i := range htlcs {
htlcs[i].PaymentHash, _, ok := coreLink.cfg.PreimageCache.LookupPreimage(
) htlcs[i].PaymentHash,
if ok != expOk { )
t.Fatalf("expected to find witness: %v, "+ if ok == expOk {
continue
}
return fmt.Errorf("expected to find witness: %v, "+
"got %v for hash=%x", expOk, ok, "got %v for hash=%x", expOk, ok,
htlcs[i].PaymentHash) htlcs[i].PaymentHash)
} }
return nil
}, 5*time.Second)
if err != nil {
t.Fatalf("unable to find preimages: %v", err)
} }
} }