From f2ed14c13065608c5e200f6f2a248d0521cc98d7 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 3 Sep 2024 11:58:34 +0200 Subject: [PATCH] lntest: avoid port collision on Tor listen port bitcoind now seems to listen on the -bind port at all times. So we need to make sure multiple instances don't collide by using a unique port. --- lntest/bitcoind_common.go | 2 ++ lntest/unittest/backend.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lntest/bitcoind_common.go b/lntest/bitcoind_common.go index ec26e6cc06..c66532bbca 100644 --- a/lntest/bitcoind_common.go +++ b/lntest/bitcoind_common.go @@ -115,6 +115,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string, zmqTxAddr := fmt.Sprintf("tcp://127.0.0.1:%d", port.NextAvailablePort()) rpcPort := port.NextAvailablePort() p2pPort := port.NextAvailablePort() + torBindPort := port.NextAvailablePort() cmdArgs := []string{ "-datadir=" + tempBitcoindDir, @@ -124,6 +125,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string, "220110063096c221be9933c82d38e1", fmt.Sprintf("-rpcport=%d", rpcPort), fmt.Sprintf("-port=%d", p2pPort), + fmt.Sprintf("-bind=127.0.0.1:%d=onion", torBindPort), "-zmqpubrawblock=" + zmqBlockAddr, "-zmqpubrawtx=" + zmqTxAddr, "-debug", diff --git a/lntest/unittest/backend.go b/lntest/unittest/backend.go index be09b395c3..ac700044d2 100644 --- a/lntest/unittest/backend.go +++ b/lntest/unittest/backend.go @@ -82,6 +82,7 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, tempBitcoindDir := t.TempDir() rpcPort := port.NextAvailablePort() + torBindPort := port.NextAvailablePort() zmqBlockPort := port.NextAvailablePort() zmqTxPort := port.NextAvailablePort() zmqBlockHost := fmt.Sprintf("tcp://127.0.0.1:%d", zmqBlockPort) @@ -94,6 +95,7 @@ func NewBitcoindBackend(t *testing.T, netParams *chaincfg.Params, "-rpcauth=weks:469e9bb14ab2360f8e226efed5ca6fd$507c670e800a95" + "284294edb5773b05544b220110063096c221be9933c82d38e1", fmt.Sprintf("-rpcport=%d", rpcPort), + fmt.Sprintf("-bind=127.0.0.1:%d=onion", torBindPort), "-disablewallet", "-zmqpubrawblock=" + zmqBlockHost, "-zmqpubrawtx=" + zmqTxHost,