multi: new bitcoind rpcpolling backend for itests

This commit is contained in:
Elle Mouton 2022-03-10 10:32:32 +00:00
parent 7509af1a70
commit e789107e1f
No known key found for this signature in database
GPG Key ID: D7D916376026F177
7 changed files with 62 additions and 18 deletions

View File

@ -259,6 +259,8 @@ jobs:
args: backend=bitcoind
- name: bitcoind-notxindex
args: backend="bitcoind notxindex"
- name: bitcoind-rpcpolling
args: backend="bitcoind rpcpolling"
- name: bitcoind-etcd
args: backend=bitcoind dbbackend=etcd
- name: bitcoind-postgres

View File

@ -507,7 +507,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
// version 0.17.0) we make sure lnd subscribes to the correct
// zmq events. We do this to avoid a situation in which we are
// not notified of new transactions or blocks.
if ver >= 170000 {
if ver >= 170000 && !bitcoindMode.RPCPolling {
zmqPubRawBlockURL, err := url.Parse(bitcoindMode.ZMQPubRawBlock)
if err != nil {
return nil, nil, err

View File

@ -1777,11 +1777,19 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
}
}
// If all of RPCUser, RPCPass, ZMQBlockHost, and ZMQTxHost are
// set, we assume those parameters are good to use.
if conf.RPCUser != "" && conf.RPCPass != "" &&
conf.ZMQPubRawBlock != "" && conf.ZMQPubRawTx != "" {
return nil
if conf.RPCUser != "" && conf.RPCPass != "" {
// If all of RPCUser, RPCPass, ZMQBlockHost, and
// ZMQTxHost are set, we assume those parameters are
// good to use.
if conf.ZMQPubRawBlock != "" && conf.ZMQPubRawTx != "" {
return nil
}
// If RPCUser and RPCPass are set and RPCPolling is
// enabled, we assume the parameters are good to use.
if conf.RPCPolling {
return nil
}
}
// Get the daemon name for displaying proper errors.

View File

@ -1,5 +1,5 @@
//go:build bitcoind && !notxindex
// +build bitcoind,!notxindex
//go:build bitcoind && !notxindex && !rpcpolling
// +build bitcoind,!notxindex,!rpcpolling
package lntest
@ -19,5 +19,5 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
"-disablewallet",
}
return newBackend(miner, netParams, extraArgs)
return newBackend(miner, netParams, extraArgs, false)
}

View File

@ -29,6 +29,7 @@ type BitcoindBackendConfig struct {
zmqTxPath string
p2pPort int
rpcClient *rpcclient.Client
rpcPolling bool
// minerAddr is the p2p address of the miner to connect to.
minerAddr string
@ -46,10 +47,19 @@ func (b BitcoindBackendConfig) GenArgs() []string {
args = append(args, fmt.Sprintf("--bitcoind.rpchost=%v", b.rpcHost))
args = append(args, fmt.Sprintf("--bitcoind.rpcuser=%v", b.rpcUser))
args = append(args, fmt.Sprintf("--bitcoind.rpcpass=%v", b.rpcPass))
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawblock=%v",
b.zmqBlockPath))
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawtx=%v",
b.zmqTxPath))
if b.rpcPolling {
args = append(args, fmt.Sprintf("--bitcoind.rpcpolling"))
args = append(args,
fmt.Sprintf("--bitcoind.blockpollinginterval=10ms"))
args = append(args,
fmt.Sprintf("--bitcoind.txpollinginterval=10ms"))
} else {
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawblock=%v",
b.zmqBlockPath))
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawtx=%v",
b.zmqTxPath))
}
return args
}
@ -76,8 +86,8 @@ func (b BitcoindBackendConfig) Name() string {
// newBackend starts a bitcoind node with the given extra parameters and returns
// a BitcoindBackendConfig for that node.
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
*BitcoindBackendConfig, func() error, error) {
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string,
rpcPolling bool) (*BitcoindBackendConfig, func() error, error) {
baseLogDir := fmt.Sprintf(logDirPattern, GetLogDir())
if netParams != &chaincfg.RegressionNetParams {
@ -192,6 +202,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
p2pPort: p2pPort,
rpcClient: client,
minerAddr: miner,
rpcPolling: rpcPolling,
}
return &bd, cleanUp, nil

View File

@ -1,5 +1,5 @@
//go:build bitcoind && notxindex
// +build bitcoind,notxindex
//go:build bitcoind && notxindex && !rpcpolling
// +build bitcoind,notxindex,!rpcpolling
package lntest
@ -18,5 +18,5 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
"-disablewallet",
}
return newBackend(miner, netParams, extraArgs)
return newBackend(miner, netParams, extraArgs, false)
}

View File

@ -0,0 +1,23 @@
//go:build bitcoind && rpcpolling
// +build bitcoind,rpcpolling
package lntest
import (
"github.com/btcsuite/btcd/chaincfg"
)
// NewBackend starts a bitcoind node without the txindex enabled and returns a
// BitoindBackendConfig for that node.
func NewBackend(miner string, netParams *chaincfg.Params) (
*BitcoindBackendConfig, func() error, error) {
extraArgs := []string{
"-debug",
"-regtest",
"-txindex",
"-disablewallet",
}
return newBackend(miner, netParams, extraArgs, true)
}