lnwallet/interface_test: wait for bitcoind startup

Flakes locally for me on darwin.
This commit is contained in:
Conner Fromknecht committed 2020-04-09 12:49:07 -07:00
1 parent 3ad7ab223e
commit 2b2c8b5a10
1 file changed
+12 -7
+12 -7
View File
@@ -38,6 +38,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb/kvdb" "github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet" "github.com/lightningnetwork/lnd/lnwallet/btcwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
@@ -3062,18 +3063,22 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
defer bitcoind.Process.Kill() defer bitcoind.Process.Kill()
// Wait for the bitcoind instance to start up. // Wait for the bitcoind instance to start up.
time.Sleep(time.Second)
host := fmt.Sprintf("127.0.0.1:%d", rpcPort) host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
chainConn, err := chain.NewBitcoindConn( var chainConn *chain.BitcoindConn
netParams, host, "weks", "weks", zmqBlockHost, err = wait.NoError(func() error {
zmqTxHost, 100*time.Millisecond, chainConn, err = chain.NewBitcoindConn(
netParams, host, "weks", "weks",
zmqBlockHost, zmqTxHost,
100*time.Millisecond,
) )
if err != nil { if err != nil {
t.Fatalf("unable to establish connection to "+ return err
"bitcoind: %v", err)
} }
if err := chainConn.Start(); err != nil {
return chainConn.Start()
}, 10*time.Second)
if err != nil {
t.Fatalf("unable to establish connection to "+ t.Fatalf("unable to establish connection to "+
"bitcoind: %v", err) "bitcoind: %v", err)
} }