diff --git a/chainntnfs/bitcoindnotify/bitcoind_test.go b/chainntnfs/bitcoindnotify/bitcoind_test.go index 9a89d3454..124872de0 100644 --- a/chainntnfs/bitcoindnotify/bitcoind_test.go +++ b/chainntnfs/bitcoindnotify/bitcoind_test.go @@ -105,12 +105,12 @@ func syncNotifierWithMiner(t *testing.T, notifier *BitcoindNotifier, // TestHistoricalConfDetailsTxIndex ensures that we correctly retrieve // historical confirmation details using the backend node's txindex. func TestHistoricalConfDetailsTxIndex(t *testing.T) { - t.Run("txindex enabled", func(st *testing.T) { + t.Run("rpc polling enabled", func(st *testing.T) { st.Parallel() testHistoricalConfDetailsTxIndex(st, true) }) - t.Run("txindex disabled", func(st *testing.T) { + t.Run("rpc polling disabled", func(st *testing.T) { st.Parallel() testHistoricalConfDetailsTxIndex(st, false) }) @@ -200,12 +200,12 @@ func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) { // historical confirmation details using the set of fallback methods when the // backend node's txindex is disabled. func TestHistoricalConfDetailsNoTxIndex(t *testing.T) { - t.Run("txindex enabled", func(st *testing.T) { + t.Run("rpc polling enabled", func(st *testing.T) { st.Parallel() testHistoricalConfDetailsNoTxIndex(st, true) }) - t.Run("txindex disabled", func(st *testing.T) { + t.Run("rpc polling disabled", func(st *testing.T) { st.Parallel() testHistoricalConfDetailsNoTxIndex(st, false) }) diff --git a/chainntnfs/test_utils.go b/chainntnfs/test_utils.go index 401e2f052..fa6b7cd56 100644 --- a/chainntnfs/test_utils.go +++ b/chainntnfs/test_utils.go @@ -6,6 +6,7 @@ package chainntnfs import ( "errors" "fmt" + "io/ioutil" "math/rand" "os/exec" "path/filepath" @@ -197,7 +198,11 @@ func NewBitcoindBackend(t *testing.T, minerAddr string, txindex, t.Helper() - tempBitcoindDir := t.TempDir() + // We use ioutil.TempDir here instead of t.TempDir because some versions + // of bitcoind complain about the zmq connection string formats when the + // t.TempDir directory string is used. + tempBitcoindDir, err := ioutil.TempDir("", "bitcoind") + require.NoError(t, err, "unable to create temp dir") rpcPort := rand.Intn(65536-1024) + 1024 zmqBlockHost := "ipc:///" + tempBitcoindDir + "/blocks.socket" @@ -241,20 +246,20 @@ func NewBitcoindBackend(t *testing.T, minerAddr string, txindex, } if rpcpolling { + cfg.PollingConfig = &chain.PollingConfig{ + BlockPollingInterval: time.Millisecond * 20, + TxPollingInterval: time.Millisecond * 20, + } + } else { cfg.ZMQConfig = &chain.ZMQConfig{ ZMQBlockHost: zmqBlockHost, ZMQTxHost: zmqTxHost, ZMQReadDeadline: 5 * time.Second, } - } else { - cfg.PollingConfig = &chain.PollingConfig{ - BlockPollingInterval: time.Millisecond * 20, - TxPollingInterval: time.Millisecond * 20, - } } var conn *chain.BitcoindConn - err := wait.NoError(func() error { + err = wait.NoError(func() error { var err error conn, err = chain.NewBitcoindConn(cfg) if err != nil { diff --git a/lntest/wait/wait.go b/lntest/wait/wait.go index b6274086c..c0cd2ded2 100644 --- a/lntest/wait/wait.go +++ b/lntest/wait/wait.go @@ -58,6 +58,13 @@ func NoError(f func() error, timeout time.Duration) error { // If f() doesn't succeed within the timeout, return the last // encountered error. if err := Predicate(pred, timeout); err != nil { + // Handle the case where the passed in method, f, hangs for the + // full timeout + if predErr == nil { + return fmt.Errorf("method did not return within the " + + "timeout") + } + return predErr }