lntest/node: make ProfilePort part of node config
This commit is contained in:
parent
93aad89f4c
commit
6028722d71
@ -33,35 +33,34 @@ import (
|
||||
macaroon "gopkg.in/macaroon.v2"
|
||||
)
|
||||
|
||||
var (
|
||||
// numActiveNodes is the number of active nodes within the test network.
|
||||
numActiveNodes = 0
|
||||
|
||||
const (
|
||||
// defaultNodePort is the initial p2p port which will be used by the
|
||||
// first created lightning node to listen on for incoming p2p
|
||||
// connections. Subsequent allocated ports for future Lightning nodes
|
||||
// instances will be monotonically increasing numbers calculated as
|
||||
// such: defaultP2pPort + (3 * harness.nodeNum).
|
||||
// such: defaultP2pPort + (4 * harness.nodeNum).
|
||||
defaultNodePort = 19555
|
||||
|
||||
// defaultClientPort is the initial rpc port which will be used by the
|
||||
// first created lightning node to listen on for incoming rpc
|
||||
// connections. Subsequent allocated ports for future rpc harness
|
||||
// instances will be monotonically increasing numbers calculated
|
||||
// as such: defaultP2pPort + (3 * harness.nodeNum).
|
||||
defaultClientPort = 19556
|
||||
// as such: defaultP2pPort + (4 * harness.nodeNum).
|
||||
defaultClientPort = defaultNodePort + 1
|
||||
|
||||
// defaultRestPort is the initial rest port which will be used by the
|
||||
// first created lightning node to listen on for incoming rest
|
||||
// connections. Subsequent allocated ports for future rpc harness
|
||||
// instances will be monotonically increasing numbers calculated
|
||||
// as such: defaultP2pPort + (3 * harness.nodeNum).
|
||||
defaultRestPort = 19557
|
||||
// as such: defaultP2pPort + (4 * harness.nodeNum).
|
||||
defaultRestPort = defaultNodePort + 2
|
||||
|
||||
// logOutput is a flag that can be set to append the output from the
|
||||
// seed nodes to log files.
|
||||
logOutput = flag.Bool("logoutput", false,
|
||||
"log output from node n to file outputn.log")
|
||||
// defaultProfilePort is the initial port which will be used for
|
||||
// profiling by the first created lightning node. Subsequent allocated
|
||||
// ports for future rpc harness instances will be monotonically
|
||||
// increasing numbers calculated as such:
|
||||
// defaultProfilePort + (4 * harness.nodeNum).
|
||||
defaultProfilePort = defaultNodePort + 3
|
||||
|
||||
// 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
|
||||
@ -74,24 +73,28 @@ var (
|
||||
trickleDelay = 50
|
||||
)
|
||||
|
||||
var (
|
||||
// numActiveNodes is the number of active nodes within the test network.
|
||||
numActiveNodes = 0
|
||||
|
||||
// logOutput is a flag that can be set to append the output from the
|
||||
// seed nodes to log files.
|
||||
logOutput = flag.Bool("logoutput", false,
|
||||
"log output from node n to file outputn.log")
|
||||
)
|
||||
|
||||
// generateListeningPorts returns three ints representing ports to listen on
|
||||
// designated for the current lightning network test. If there haven't been any
|
||||
// test instances created, the default ports are used. Otherwise, in order to
|
||||
// support multiple test nodes running at once, the p2p, rpc, and rest ports
|
||||
// are incremented after each initialization.
|
||||
func generateListeningPorts() (int, int, int) {
|
||||
var p2p, rpc, rest int
|
||||
if numActiveNodes == 0 {
|
||||
p2p = defaultNodePort
|
||||
rpc = defaultClientPort
|
||||
rest = defaultRestPort
|
||||
} else {
|
||||
p2p = defaultNodePort + (3 * numActiveNodes)
|
||||
rpc = defaultClientPort + (3 * numActiveNodes)
|
||||
rest = defaultRestPort + (3 * numActiveNodes)
|
||||
}
|
||||
// support multiple test nodes running at once, the p2p, rpc, rest and
|
||||
// profiling ports are incremented after each initialization.
|
||||
func generateListeningPorts() (int, int, int, int) {
|
||||
p2p := defaultNodePort + (4 * numActiveNodes)
|
||||
rpc := defaultClientPort + (4 * numActiveNodes)
|
||||
rest := defaultRestPort + (4 * numActiveNodes)
|
||||
profile := defaultProfilePort + (4 * numActiveNodes)
|
||||
|
||||
return p2p, rpc, rest
|
||||
return p2p, rpc, rest, profile
|
||||
}
|
||||
|
||||
// BackendConfig is an interface that abstracts away the specific chain backend
|
||||
@ -129,9 +132,10 @@ type nodeConfig struct {
|
||||
HasSeed bool
|
||||
Password []byte
|
||||
|
||||
P2PPort int
|
||||
RPCPort int
|
||||
RESTPort int
|
||||
P2PPort int
|
||||
RPCPort int
|
||||
RESTPort int
|
||||
ProfilePort int
|
||||
}
|
||||
|
||||
func (cfg nodeConfig) P2PAddr() string {
|
||||
@ -195,6 +199,7 @@ func (cfg nodeConfig) genArgs() []string {
|
||||
args = append(args, fmt.Sprintf("--readonlymacaroonpath=%v", cfg.ReadMacPath))
|
||||
args = append(args, fmt.Sprintf("--invoicemacaroonpath=%v", cfg.InvoiceMacPath))
|
||||
args = append(args, fmt.Sprintf("--trickledelay=%v", trickleDelay))
|
||||
args = append(args, fmt.Sprintf("--profile=%d", cfg.ProfilePort))
|
||||
|
||||
if !cfg.HasSeed {
|
||||
args = append(args, "--noseedbackup")
|
||||
@ -280,7 +285,7 @@ func newNode(cfg nodeConfig) (*HarnessNode, error) {
|
||||
cfg.ReadMacPath = filepath.Join(cfg.DataDir, "readonly.macaroon")
|
||||
cfg.InvoiceMacPath = filepath.Join(cfg.DataDir, "invoice.macaroon")
|
||||
|
||||
cfg.P2PPort, cfg.RPCPort, cfg.RESTPort = generateListeningPorts()
|
||||
cfg.P2PPort, cfg.RPCPort, cfg.RESTPort, cfg.ProfilePort = generateListeningPorts()
|
||||
|
||||
nodeNum := numActiveNodes
|
||||
numActiveNodes++
|
||||
@ -333,7 +338,6 @@ func (hn *HarnessNode) start(lndError chan<- error) error {
|
||||
hn.quit = make(chan struct{})
|
||||
|
||||
args := hn.cfg.genArgs()
|
||||
args = append(args, fmt.Sprintf("--profile=%d", 9000+hn.NodeID))
|
||||
hn.cmd = exec.Command("../../lnd-itest", args...)
|
||||
|
||||
// Redirect stderr output to buffer
|
||||
|
Loading…
Reference in New Issue
Block a user