mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-12 22:19:06 +02:00
Merge pull request #7483 from ellemouton/fixNoErrorFunc
multi: fix wait.NoError and sub-test names
This commit is contained in:
commit
ca3debf351
@ -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)
|
||||
})
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user