itest: disable node retrying to connect to miner
Previously the chainbackend connected to the miner using a permanent connection, which would retry the connection when it’s disconnected. It would leave multiple connections between the chainbackend and the miner, causing difficulties in debugging. Currently, there are two occasions when disconnection happens. One happens when running the open channel reorg test, the miner is connected/disconnected multiple times on purpose. The other happens when the chainbackend receives a MSG_WITNESS_TX type from the miner, which would be considered as an invalid type and disconnects the miner. With the latter one being fixed in btcd, the chainbackend will still be disconnected from the miner if it reaches the ban score by requesting too many notfound messages in a short time which is why the `--nobanning` flag is added.
This commit is contained in:
parent
724f6e0969
commit
567fa9ed10
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user