diff --git a/chainntnfs/bitcoindnotify/bitcoind_test.go b/chainntnfs/bitcoindnotify/bitcoind_test.go index 696fe06c2..62acffba7 100644 --- a/chainntnfs/bitcoindnotify/bitcoind_test.go +++ b/chainntnfs/bitcoindnotify/bitcoind_test.go @@ -179,7 +179,7 @@ func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) { ) bitcoindConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, miner.P2PAddress(), true, rpcPolling, + t, unittest.NetParams, miner, true, rpcPolling, ) hintCache := initHintCache(t) @@ -279,7 +279,7 @@ func testHistoricalConfDetailsNoTxIndex(t *testing.T, rpcpolling bool) { miner := unittest.NewMiner(t, unittest.NetParams, nil, true, 25) bitcoindConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, miner.P2PAddress(), false, rpcpolling, + t, unittest.NetParams, miner, false, rpcpolling, ) hintCache := initHintCache(t) diff --git a/chainntnfs/test/test_interface.go b/chainntnfs/test/test_interface.go index fd42b10de..7536d24c5 100644 --- a/chainntnfs/test/test_interface.go +++ b/chainntnfs/test/test_interface.go @@ -1932,7 +1932,7 @@ func TestInterfaces(t *testing.T, targetBackEnd string) { case "bitcoind": var bitcoindConn *chain.BitcoindConn bitcoindConn = unittest.NewBitcoindBackend( - t, unittest.NetParams, p2pAddr, true, false, + t, unittest.NetParams, miner, true, false, ) newNotifier = func() (chainntnfs.TestChainNotifier, error) { return bitcoindnotify.New( @@ -1944,7 +1944,7 @@ func TestInterfaces(t *testing.T, targetBackEnd string) { case "bitcoind-rpc-polling": var bitcoindConn *chain.BitcoindConn bitcoindConn = unittest.NewBitcoindBackend( - t, unittest.NetParams, p2pAddr, true, true, + t, unittest.NetParams, miner, true, true, ) newNotifier = func() (chainntnfs.TestChainNotifier, error) { return bitcoindnotify.New( diff --git a/lntest/unittest/backend.go b/lntest/unittest/backend.go index 390284e8a..30c1a00a4 100644 --- a/lntest/unittest/backend.go +++ b/lntest/unittest/backend.go @@ -83,7 +83,7 @@ func NewMiner(t *testing.T, netParams *chaincfg.Params, extraArgs []string, // used for block and tx notifications or if its ZMQ interface should be used. // A connection to the newly spawned bitcoind node is returned. func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, - minerAddr string, txindex, rpcpolling bool) *chain.BitcoindConn { + miner *rpctest.Harness, txindex, rpcpolling bool) *chain.BitcoindConn { t.Helper() @@ -204,7 +204,7 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, require.NoError(t, err, "failed to create RPC client") // Connect to the miner node. - err = rpcClient.AddNode(minerAddr, rpcclient.ANAdd) + err = rpcClient.AddNode(miner.P2PAddress(), rpcclient.ANAdd) require.NoError(t, err, "failed to connect to miner") // Get the network info and assert the num of outbound connections is 1. diff --git a/lnwallet/test/test_interface.go b/lnwallet/test/test_interface.go index 27de51708..52ad1dded 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -3352,8 +3352,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, case "bitcoind": // Start a bitcoind instance. chainConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, miningNode.P2PAddress(), - true, false, + t, unittest.NetParams, miningNode, true, false, ) // Create a btcwallet bitcoind client for both Alice and @@ -3364,8 +3363,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, case "bitcoind-rpc-polling": // Start a bitcoind instance. chainConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, miningNode.P2PAddress(), - true, true, + t, unittest.NetParams, miningNode, true, true, ) // Create a btcwallet bitcoind client for both Alice and diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index b953389af..c0f336a68 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -460,7 +460,7 @@ func testFilterBlockDisconnected(node *rpctest.Harness, // Init a chain view that has this node as its block source. reorgView, err := chainViewInit( - t, reorgNode.RPCConfig(), reorgNode.P2PAddress(), bestHeight, + t, reorgNode.RPCConfig(), reorgNode, bestHeight, ) require.NoError(t, err, "unable to create chain view") @@ -632,7 +632,7 @@ func testFilterBlockDisconnected(node *rpctest.Harness, } type chainViewInitFunc func(t *testing.T, rpcInfo rpcclient.ConnConfig, - p2pAddr string, bestHeight int32) (FilteredChainView, error) + miner *rpctest.Harness, bestHeight int32) (FilteredChainView, error) type testCase struct { name string @@ -666,12 +666,12 @@ var interfaceImpls = []struct { { name: "bitcoind_zmq", chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig, - p2pAddr string, bestHeight int32) (FilteredChainView, - error) { + miner *rpctest.Harness, bestHeight int32) ( + FilteredChainView, error) { // Start a bitcoind instance. chainConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, p2pAddr, true, + t, unittest.NetParams, miner, true, false, ) blockCache := blockcache.NewBlockCache(10000) @@ -686,12 +686,12 @@ var interfaceImpls = []struct { { name: "bitcoind_polling", chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig, - p2pAddr string, bestHeight int32) (FilteredChainView, - error) { + miner *rpctest.Harness, bestHeight int32) ( + FilteredChainView, error) { // Wait for the bitcoind instance to start up. chainConn := unittest.NewBitcoindBackend( - t, unittest.NetParams, p2pAddr, true, + t, unittest.NetParams, miner, true, true, ) blockCache := blockcache.NewBlockCache(10000) @@ -706,8 +706,8 @@ var interfaceImpls = []struct { { name: "p2p_neutrino", chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig, - p2pAddr string, bestHeight int32) (FilteredChainView, - error) { + miner *rpctest.Harness, bestHeight int32) ( + FilteredChainView, error) { spvDir := t.TempDir() @@ -723,7 +723,7 @@ var interfaceImpls = []struct { DataDir: spvDir, Database: spvDatabase, ChainParams: *netParams, - ConnectPeers: []string{p2pAddr}, + ConnectPeers: []string{miner.P2PAddress()}, } spvNode, err := neutrino.NewChainService(spvConfig) @@ -776,8 +776,8 @@ var interfaceImpls = []struct { { name: "btcd_websockets", chainViewInit: func(_ *testing.T, config rpcclient.ConnConfig, - p2pAddr string, bestHeight int32) (FilteredChainView, - error) { + _ *rpctest.Harness, _ int32) ( + FilteredChainView, error) { blockCache := blockcache.NewBlockCache(10000) chainView, err := NewBtcdFilteredChainView( @@ -802,7 +802,6 @@ func TestFilteredChainView(t *testing.T) { ) rpcConfig := miner.RPCConfig() - p2pAddr := miner.P2PAddress() for _, chainViewImpl := range interfaceImpls { t.Logf("Testing '%v' implementation of FilteredChainView", @@ -814,7 +813,7 @@ func TestFilteredChainView(t *testing.T) { } chainView, err := chainViewImpl.chainViewInit( - t, rpcConfig, p2pAddr, bestHeight, + t, rpcConfig, miner, bestHeight, ) if err != nil { t.Fatalf("unable to make chain view: %v", err)