mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-14 19:01:10 +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
|
// TestHistoricalConfDetailsTxIndex ensures that we correctly retrieve
|
||||||
// historical confirmation details using the backend node's txindex.
|
// historical confirmation details using the backend node's txindex.
|
||||||
func TestHistoricalConfDetailsTxIndex(t *testing.T) {
|
func TestHistoricalConfDetailsTxIndex(t *testing.T) {
|
||||||
t.Run("txindex enabled", func(st *testing.T) {
|
t.Run("rpc polling enabled", func(st *testing.T) {
|
||||||
st.Parallel()
|
st.Parallel()
|
||||||
testHistoricalConfDetailsTxIndex(st, true)
|
testHistoricalConfDetailsTxIndex(st, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("txindex disabled", func(st *testing.T) {
|
t.Run("rpc polling disabled", func(st *testing.T) {
|
||||||
st.Parallel()
|
st.Parallel()
|
||||||
testHistoricalConfDetailsTxIndex(st, false)
|
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
|
// historical confirmation details using the set of fallback methods when the
|
||||||
// backend node's txindex is disabled.
|
// backend node's txindex is disabled.
|
||||||
func TestHistoricalConfDetailsNoTxIndex(t *testing.T) {
|
func TestHistoricalConfDetailsNoTxIndex(t *testing.T) {
|
||||||
t.Run("txindex enabled", func(st *testing.T) {
|
t.Run("rpc polling enabled", func(st *testing.T) {
|
||||||
st.Parallel()
|
st.Parallel()
|
||||||
testHistoricalConfDetailsNoTxIndex(st, true)
|
testHistoricalConfDetailsNoTxIndex(st, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("txindex disabled", func(st *testing.T) {
|
t.Run("rpc polling disabled", func(st *testing.T) {
|
||||||
st.Parallel()
|
st.Parallel()
|
||||||
testHistoricalConfDetailsNoTxIndex(st, false)
|
testHistoricalConfDetailsNoTxIndex(st, false)
|
||||||
})
|
})
|
||||||
|
@ -6,6 +6,7 @@ package chainntnfs
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -197,7 +198,11 @@ func NewBitcoindBackend(t *testing.T, minerAddr string, txindex,
|
|||||||
|
|
||||||
t.Helper()
|
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
|
rpcPort := rand.Intn(65536-1024) + 1024
|
||||||
zmqBlockHost := "ipc:///" + tempBitcoindDir + "/blocks.socket"
|
zmqBlockHost := "ipc:///" + tempBitcoindDir + "/blocks.socket"
|
||||||
@ -241,20 +246,20 @@ func NewBitcoindBackend(t *testing.T, minerAddr string, txindex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rpcpolling {
|
if rpcpolling {
|
||||||
|
cfg.PollingConfig = &chain.PollingConfig{
|
||||||
|
BlockPollingInterval: time.Millisecond * 20,
|
||||||
|
TxPollingInterval: time.Millisecond * 20,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
cfg.ZMQConfig = &chain.ZMQConfig{
|
cfg.ZMQConfig = &chain.ZMQConfig{
|
||||||
ZMQBlockHost: zmqBlockHost,
|
ZMQBlockHost: zmqBlockHost,
|
||||||
ZMQTxHost: zmqTxHost,
|
ZMQTxHost: zmqTxHost,
|
||||||
ZMQReadDeadline: 5 * time.Second,
|
ZMQReadDeadline: 5 * time.Second,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
cfg.PollingConfig = &chain.PollingConfig{
|
|
||||||
BlockPollingInterval: time.Millisecond * 20,
|
|
||||||
TxPollingInterval: time.Millisecond * 20,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var conn *chain.BitcoindConn
|
var conn *chain.BitcoindConn
|
||||||
err := wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
var err error
|
var err error
|
||||||
conn, err = chain.NewBitcoindConn(cfg)
|
conn, err = chain.NewBitcoindConn(cfg)
|
||||||
if err != nil {
|
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
|
// If f() doesn't succeed within the timeout, return the last
|
||||||
// encountered error.
|
// encountered error.
|
||||||
if err := Predicate(pred, timeout); err != nil {
|
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
|
return predErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user