From a50d337e4212b6960f8ad9660b81f63647e9e962 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 4 Nov 2020 11:03:25 +0100 Subject: [PATCH] lntest: lower initial port, add ApplyPortOffset function To allow running multiple test tranches in parallel, we need a way to make sure the TCP ports don't collide. We'll work with offsets for the ports, using a different offset for each tranche. --- lntest/node.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lntest/node.go b/lntest/node.go index cdf0be03..8c72a1ed 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -43,7 +43,7 @@ const ( // defaultNodePort is the start of the range for listening ports of // harness nodes. Ports are monotonically increasing starting from this // number and are determined by the results of nextAvailablePort(). - defaultNodePort = 19555 + defaultNodePort = 5555 // logPubKeyBytes is the number of bytes of the node's PubKey that will // be appended to the log file name. The whole PubKey is too long and @@ -104,6 +104,12 @@ func nextAvailablePort() int { panic("no ports available for listening") } +// ApplyPortOffset adds the given offset to the lastPort variable, making it +// possible to run the tests in parallel without colliding on the same ports. +func ApplyPortOffset(offset uint32) { + _ = atomic.AddUint32(&lastPort, offset) +} + // generateListeningPorts returns four ints representing ports to listen on // designated for the current lightning network test. This returns the next // available ports for the p2p, rpc, rest and profiling services.