mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
multi: change NewBitcoindBackend
to take a miner as its param
Prepares for the following commit where we assert the chain backend is synced to the miner.
This commit is contained in:
parent
c725ba9f25
commit
99d49dec6a
5 changed files with 22 additions and 25 deletions
|
@ -179,7 +179,7 @@ func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) {
|
||||||
)
|
)
|
||||||
|
|
||||||
bitcoindConn := unittest.NewBitcoindBackend(
|
bitcoindConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, miner.P2PAddress(), true, rpcPolling,
|
t, unittest.NetParams, miner, true, rpcPolling,
|
||||||
)
|
)
|
||||||
|
|
||||||
hintCache := initHintCache(t)
|
hintCache := initHintCache(t)
|
||||||
|
@ -279,7 +279,7 @@ func testHistoricalConfDetailsNoTxIndex(t *testing.T, rpcpolling bool) {
|
||||||
miner := unittest.NewMiner(t, unittest.NetParams, nil, true, 25)
|
miner := unittest.NewMiner(t, unittest.NetParams, nil, true, 25)
|
||||||
|
|
||||||
bitcoindConn := unittest.NewBitcoindBackend(
|
bitcoindConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, miner.P2PAddress(), false, rpcpolling,
|
t, unittest.NetParams, miner, false, rpcpolling,
|
||||||
)
|
)
|
||||||
|
|
||||||
hintCache := initHintCache(t)
|
hintCache := initHintCache(t)
|
||||||
|
|
|
@ -1932,7 +1932,7 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
|
||||||
case "bitcoind":
|
case "bitcoind":
|
||||||
var bitcoindConn *chain.BitcoindConn
|
var bitcoindConn *chain.BitcoindConn
|
||||||
bitcoindConn = unittest.NewBitcoindBackend(
|
bitcoindConn = unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, p2pAddr, true, false,
|
t, unittest.NetParams, miner, true, false,
|
||||||
)
|
)
|
||||||
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
|
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
|
||||||
return bitcoindnotify.New(
|
return bitcoindnotify.New(
|
||||||
|
@ -1944,7 +1944,7 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
|
||||||
case "bitcoind-rpc-polling":
|
case "bitcoind-rpc-polling":
|
||||||
var bitcoindConn *chain.BitcoindConn
|
var bitcoindConn *chain.BitcoindConn
|
||||||
bitcoindConn = unittest.NewBitcoindBackend(
|
bitcoindConn = unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, p2pAddr, true, true,
|
t, unittest.NetParams, miner, true, true,
|
||||||
)
|
)
|
||||||
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
|
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
|
||||||
return bitcoindnotify.New(
|
return bitcoindnotify.New(
|
||||||
|
|
|
@ -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.
|
// used for block and tx notifications or if its ZMQ interface should be used.
|
||||||
// A connection to the newly spawned bitcoind node is returned.
|
// A connection to the newly spawned bitcoind node is returned.
|
||||||
func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params,
|
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()
|
t.Helper()
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params,
|
||||||
require.NoError(t, err, "failed to create RPC client")
|
require.NoError(t, err, "failed to create RPC client")
|
||||||
|
|
||||||
// Connect to the miner node.
|
// 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")
|
require.NoError(t, err, "failed to connect to miner")
|
||||||
|
|
||||||
// Get the network info and assert the num of outbound connections is 1.
|
// Get the network info and assert the num of outbound connections is 1.
|
||||||
|
|
|
@ -3352,8 +3352,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
|
||||||
case "bitcoind":
|
case "bitcoind":
|
||||||
// Start a bitcoind instance.
|
// Start a bitcoind instance.
|
||||||
chainConn := unittest.NewBitcoindBackend(
|
chainConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, miningNode.P2PAddress(),
|
t, unittest.NetParams, miningNode, true, false,
|
||||||
true, false,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a btcwallet bitcoind client for both Alice and
|
// 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":
|
case "bitcoind-rpc-polling":
|
||||||
// Start a bitcoind instance.
|
// Start a bitcoind instance.
|
||||||
chainConn := unittest.NewBitcoindBackend(
|
chainConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, miningNode.P2PAddress(),
|
t, unittest.NetParams, miningNode, true, true,
|
||||||
true, true,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a btcwallet bitcoind client for both Alice and
|
// Create a btcwallet bitcoind client for both Alice and
|
||||||
|
|
|
@ -460,7 +460,7 @@ func testFilterBlockDisconnected(node *rpctest.Harness,
|
||||||
|
|
||||||
// Init a chain view that has this node as its block source.
|
// Init a chain view that has this node as its block source.
|
||||||
reorgView, err := chainViewInit(
|
reorgView, err := chainViewInit(
|
||||||
t, reorgNode.RPCConfig(), reorgNode.P2PAddress(), bestHeight,
|
t, reorgNode.RPCConfig(), reorgNode, bestHeight,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to create chain view")
|
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,
|
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 {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
|
@ -666,12 +666,12 @@ var interfaceImpls = []struct {
|
||||||
{
|
{
|
||||||
name: "bitcoind_zmq",
|
name: "bitcoind_zmq",
|
||||||
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
||||||
p2pAddr string, bestHeight int32) (FilteredChainView,
|
miner *rpctest.Harness, bestHeight int32) (
|
||||||
error) {
|
FilteredChainView, error) {
|
||||||
|
|
||||||
// Start a bitcoind instance.
|
// Start a bitcoind instance.
|
||||||
chainConn := unittest.NewBitcoindBackend(
|
chainConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, p2pAddr, true,
|
t, unittest.NetParams, miner, true,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
blockCache := blockcache.NewBlockCache(10000)
|
blockCache := blockcache.NewBlockCache(10000)
|
||||||
|
@ -686,12 +686,12 @@ var interfaceImpls = []struct {
|
||||||
{
|
{
|
||||||
name: "bitcoind_polling",
|
name: "bitcoind_polling",
|
||||||
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
||||||
p2pAddr string, bestHeight int32) (FilteredChainView,
|
miner *rpctest.Harness, bestHeight int32) (
|
||||||
error) {
|
FilteredChainView, error) {
|
||||||
|
|
||||||
// Wait for the bitcoind instance to start up.
|
// Wait for the bitcoind instance to start up.
|
||||||
chainConn := unittest.NewBitcoindBackend(
|
chainConn := unittest.NewBitcoindBackend(
|
||||||
t, unittest.NetParams, p2pAddr, true,
|
t, unittest.NetParams, miner, true,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
blockCache := blockcache.NewBlockCache(10000)
|
blockCache := blockcache.NewBlockCache(10000)
|
||||||
|
@ -706,8 +706,8 @@ var interfaceImpls = []struct {
|
||||||
{
|
{
|
||||||
name: "p2p_neutrino",
|
name: "p2p_neutrino",
|
||||||
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
chainViewInit: func(t *testing.T, _ rpcclient.ConnConfig,
|
||||||
p2pAddr string, bestHeight int32) (FilteredChainView,
|
miner *rpctest.Harness, bestHeight int32) (
|
||||||
error) {
|
FilteredChainView, error) {
|
||||||
|
|
||||||
spvDir := t.TempDir()
|
spvDir := t.TempDir()
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ var interfaceImpls = []struct {
|
||||||
DataDir: spvDir,
|
DataDir: spvDir,
|
||||||
Database: spvDatabase,
|
Database: spvDatabase,
|
||||||
ChainParams: *netParams,
|
ChainParams: *netParams,
|
||||||
ConnectPeers: []string{p2pAddr},
|
ConnectPeers: []string{miner.P2PAddress()},
|
||||||
}
|
}
|
||||||
|
|
||||||
spvNode, err := neutrino.NewChainService(spvConfig)
|
spvNode, err := neutrino.NewChainService(spvConfig)
|
||||||
|
@ -776,8 +776,8 @@ var interfaceImpls = []struct {
|
||||||
{
|
{
|
||||||
name: "btcd_websockets",
|
name: "btcd_websockets",
|
||||||
chainViewInit: func(_ *testing.T, config rpcclient.ConnConfig,
|
chainViewInit: func(_ *testing.T, config rpcclient.ConnConfig,
|
||||||
p2pAddr string, bestHeight int32) (FilteredChainView,
|
_ *rpctest.Harness, _ int32) (
|
||||||
error) {
|
FilteredChainView, error) {
|
||||||
|
|
||||||
blockCache := blockcache.NewBlockCache(10000)
|
blockCache := blockcache.NewBlockCache(10000)
|
||||||
chainView, err := NewBtcdFilteredChainView(
|
chainView, err := NewBtcdFilteredChainView(
|
||||||
|
@ -802,7 +802,6 @@ func TestFilteredChainView(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
rpcConfig := miner.RPCConfig()
|
rpcConfig := miner.RPCConfig()
|
||||||
p2pAddr := miner.P2PAddress()
|
|
||||||
|
|
||||||
for _, chainViewImpl := range interfaceImpls {
|
for _, chainViewImpl := range interfaceImpls {
|
||||||
t.Logf("Testing '%v' implementation of FilteredChainView",
|
t.Logf("Testing '%v' implementation of FilteredChainView",
|
||||||
|
@ -814,7 +813,7 @@ func TestFilteredChainView(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chainView, err := chainViewImpl.chainViewInit(
|
chainView, err := chainViewImpl.chainViewInit(
|
||||||
t, rpcConfig, p2pAddr, bestHeight,
|
t, rpcConfig, miner, bestHeight,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to make chain view: %v", err)
|
t.Fatalf("unable to make chain view: %v", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue