multi: new bitcoind rpcpolling backend for itests

This commit is contained in:
Elle Mouton committed 2022-05-11 09:02:13 +02:00
1 parent 7509af1a70
commit e789107e1f
7 files changed
+62 -18

No files matched your search

+3 -3
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)
}
+17 -6
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
+3 -3
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)
}
+23
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)
}