diff --git a/lntest/bitcoind.go b/lntest/bitcoind.go index 86d59ef4..56670892 100644 --- a/lntest/bitcoind.go +++ b/lntest/bitcoind.go @@ -174,14 +174,6 @@ func NewBackend(miner string, netParams *chaincfg.Params) ( err) } - // We start by adding the miner to the bitcoind addnode list. We do - // this instead of connecting using command line flags, because it will - // allow us to disconnect the miner using the AddNode command later. - if err := client.AddNode(miner, rpcclient.ANAdd); err != nil { - cleanUp() - return nil, nil, fmt.Errorf("unable to add node: %v", err) - } - bd := BitcoindBackendConfig{ rpcHost: rpcHost, rpcUser: rpcUser, diff --git a/lntest/btcd.go b/lntest/btcd.go index 3b75b7bc..b3ec7b45 100644 --- a/lntest/btcd.go +++ b/lntest/btcd.go @@ -17,11 +17,11 @@ import ( // logDir is the name of the temporary log directory. const logDir = "./.backendlogs" -// perm is used to signal we want to establish a permanent connection using the +// temp is used to signal we want to establish a temporary connection using the // btcd Node API. // // NOTE: Cannot be const, since the node API expects a reference. -var perm = "perm" +var temp = "temp" // BtcdBackendConfig is an implementation of the BackendConfig interface // backed by a btcd node. @@ -56,12 +56,12 @@ func (b BtcdBackendConfig) GenArgs() []string { // ConnectMiner is called to establish a connection to the test miner. func (b BtcdBackendConfig) ConnectMiner() error { - return b.harness.Node.Node(btcjson.NConnect, b.minerAddr, &perm) + return b.harness.Node.Node(btcjson.NConnect, b.minerAddr, &temp) } // DisconnectMiner is called to disconnect the miner. func (b BtcdBackendConfig) DisconnectMiner() error { - return b.harness.Node.Node(btcjson.NRemove, b.minerAddr, &perm) + return b.harness.Node.Node(btcjson.NDisconnect, b.minerAddr, &temp) } // Name returns the name of the backend type. @@ -81,8 +81,11 @@ func NewBackend(miner string, netParams *chaincfg.Params) ( "--trickleinterval=100ms", "--debuglevel=debug", "--logdir=" + logDir, - "--connect=" + miner, "--nowinservice", + // The miner will get banned and disconnected from the node if + // its requested data are not found. We add a nobanning flag to + // make sure they stay connected if it happens. + "--nobanning", } chainBackend, err := rpctest.New(netParams, nil, args) if err != nil { diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index a8589450..0d151b71 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -2467,6 +2467,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) { "--rejectnonstd", "--txindex", "--nowinservice", + "--nobanning", } tempMiner, err := rpctest.New( harnessNetParams, &rpcclient.NotificationHandlers{}, args, @@ -14407,6 +14408,7 @@ func TestLightningNetworkDaemon(t *testing.T) { "--logdir=" + minerLogDir, "--trickleinterval=100ms", "--nowinservice", + "--nobanning", } handlers := &rpcclient.NotificationHandlers{ OnTxAccepted: func(hash *chainhash.Hash, amt btcutil.Amount) { @@ -14458,6 +14460,12 @@ func TestLightningNetworkDaemon(t *testing.T) { ht.Fatalf("unable to request transaction notifications: %v", err) } + // Connect chainbackend to miner. + require.NoError( + t, chainBackend.ConnectMiner(), + "failed to connect to miner", + ) + binary := itestLndBinary if runtime.GOOS == "windows" { // Windows (even in a bash like environment like git bash as on diff --git a/lntest/neutrino.go b/lntest/neutrino.go index 25f2af24..d8e4596c 100644 --- a/lntest/neutrino.go +++ b/lntest/neutrino.go @@ -29,7 +29,7 @@ func (b NeutrinoBackendConfig) GenArgs() []string { // ConnectMiner is called to establish a connection to the test miner. func (b NeutrinoBackendConfig) ConnectMiner() error { - return fmt.Errorf("unimplemented") + return nil } // DisconnectMiner is called to disconnect the miner.