lntest: re-use P2P ports during SCB recovery
In some rare instances it can happen that the nodes don't find each other again after one of them has been re-created and the other one has been restarted in the SCB tests. By making sure the re-created has the same P2P port again as before, we make sure they can connect to each other again successfully for executing DLP.
This commit is contained in:
4 files changed
+56
-23
No files matched your search
+14
-8
@@ -155,13 +155,19 @@ func GenerateBtcdListenerAddresses() (string, string) {
|
||||
// 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.
|
||||
func generateListeningPorts() (int, int, int, int) {
|
||||
p2p := NextAvailablePort()
|
||||
rpc := NextAvailablePort()
|
||||
rest := NextAvailablePort()
|
||||
profile := NextAvailablePort()
|
||||
|
||||
return p2p, rpc, rest, profile
|
||||
func generateListeningPorts(cfg *NodeConfig) {
|
||||
if cfg.P2PPort == 0 {
|
||||
cfg.P2PPort = NextAvailablePort()
|
||||
}
|
||||
if cfg.RPCPort == 0 {
|
||||
cfg.RPCPort = NextAvailablePort()
|
||||
}
|
||||
if cfg.RESTPort == 0 {
|
||||
cfg.RESTPort = NextAvailablePort()
|
||||
}
|
||||
if cfg.ProfilePort == 0 {
|
||||
cfg.ProfilePort = NextAvailablePort()
|
||||
}
|
||||
}
|
||||
|
||||
// BackendConfig is an interface that abstracts away the specific chain backend
|
||||
@@ -406,7 +412,7 @@ func newNode(cfg NodeConfig) (*HarnessNode, error) {
|
||||
cfg.ReadMacPath = filepath.Join(networkDir, "readonly.macaroon")
|
||||
cfg.InvoiceMacPath = filepath.Join(networkDir, "invoice.macaroon")
|
||||
|
||||
cfg.P2PPort, cfg.RPCPort, cfg.RESTPort, cfg.ProfilePort = generateListeningPorts()
|
||||
generateListeningPorts(&cfg)
|
||||
|
||||
// Run all tests with accept keysend. The keysend code is very isolated
|
||||
// and it is highly unlikely that it would affect regular itests when
|
||||
|
||||
Reference in new issue
Block a user