lntest: use extraArgs, fix linter issues

This commit is contained in:
Oliver Gugger 2020-10-09 13:35:02 +02:00
parent 43c2031fa8
commit b7fc7c3dae
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -71,7 +71,7 @@ func (b BitcoindBackendConfig) Name() string {
// newBackend starts a bitcoind node with the given extra parameters and returns // newBackend starts a bitcoind node with the given extra parameters and returns
// a BitcoindBackendConfig for that node. // a BitcoindBackendConfig for that node.
func newBackend(miner string, netParams *chaincfg.Params, _ []string) ( func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
*BitcoindBackendConfig, func() error, error) { *BitcoindBackendConfig, func() error, error) {
if netParams != &chaincfg.RegressionNetParams { if netParams != &chaincfg.RegressionNetParams {
@ -98,33 +98,33 @@ func newBackend(miner string, netParams *chaincfg.Params, _ []string) (
rpcPort := rand.Int()%(65536-1024) + 1024 rpcPort := rand.Int()%(65536-1024) + 1024
p2pPort := rand.Int()%(65536-1024) + 1024 p2pPort := rand.Int()%(65536-1024) + 1024
bitcoind := exec.Command( cmdArgs := []string{
"bitcoind", "-datadir=" + tempBitcoindDir,
"-datadir="+tempBitcoindDir,
"-debug",
"-regtest",
"-txindex",
"-whitelist=127.0.0.1", // whitelist localhost to speed up relay "-whitelist=127.0.0.1", // whitelist localhost to speed up relay
"-rpcauth=weks:469e9bb14ab2360f8e226efed5ca6f"+ "-rpcauth=weks:469e9bb14ab2360f8e226efed5ca6f" +
"d$507c670e800a95284294edb5773b05544b"+ "d$507c670e800a95284294edb5773b05544b" +
"220110063096c221be9933c82d38e1", "220110063096c221be9933c82d38e1",
fmt.Sprintf("-rpcport=%d", rpcPort), fmt.Sprintf("-rpcport=%d", rpcPort),
fmt.Sprintf("-port=%d", p2pPort), fmt.Sprintf("-port=%d", p2pPort),
"-disablewallet", "-zmqpubrawblock=" + zmqBlockPath,
"-zmqpubrawblock="+zmqBlockPath, "-zmqpubrawtx=" + zmqTxPath,
"-zmqpubrawtx="+zmqTxPath, "-debuglogfile=" + logFile,
"-debuglogfile="+logFile, }
) cmdArgs = append(cmdArgs, extraArgs...)
bitcoind := exec.Command("bitcoind", cmdArgs...)
err = bitcoind.Start() err = bitcoind.Start()
if err != nil { if err != nil {
os.RemoveAll(tempBitcoindDir) if err := os.RemoveAll(tempBitcoindDir); err != nil {
fmt.Printf("unable to remote temp dir %v: %v",
tempBitcoindDir, err)
}
return nil, nil, fmt.Errorf("couldn't start bitcoind: %v", err) return nil, nil, fmt.Errorf("couldn't start bitcoind: %v", err)
} }
cleanUp := func() error { cleanUp := func() error {
bitcoind.Process.Kill() _ = bitcoind.Process.Kill()
bitcoind.Wait() _ = bitcoind.Wait()
var errStr string var errStr string
// After shutting down the chain backend, we'll make a copy of // After shutting down the chain backend, we'll make a copy of
@ -169,7 +169,7 @@ func newBackend(miner string, netParams *chaincfg.Params, _ []string) (
client, err := rpcclient.New(&rpcCfg, nil) client, err := rpcclient.New(&rpcCfg, nil)
if err != nil { if err != nil {
cleanUp() _ = cleanUp()
return nil, nil, fmt.Errorf("unable to create rpc client: %v", return nil, nil, fmt.Errorf("unable to create rpc client: %v",
err) err)
} }