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.
This commit is contained in:
1 file changed
+7
-1
+7
-1
@@ -43,7 +43,7 @@ const (
|
|||||||
// defaultNodePort is the start of the range for listening ports of
|
// defaultNodePort is the start of the range for listening ports of
|
||||||
// harness nodes. Ports are monotonically increasing starting from this
|
// harness nodes. Ports are monotonically increasing starting from this
|
||||||
// number and are determined by the results of nextAvailablePort().
|
// 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
|
// 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
|
// 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")
|
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
|
// generateListeningPorts returns four ints representing ports to listen on
|
||||||
// designated for the current lightning network test. This returns the next
|
// designated for the current lightning network test. This returns the next
|
||||||
// available ports for the p2p, rpc, rest and profiling services.
|
// available ports for the p2p, rpc, rest and profiling services.
|
||||||
|
|||||||
Reference in new issue
Block a user