Skip to content

Commit 49749a8

Browse files
committed
cleanup
1 parent 6097c9f commit 49749a8

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

systemtests/system.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ var (
4040
MaxGas = 10_000_000
4141
// DefaultApiPort is the port for the node to interact with
4242
DefaultApiPort = 1317
43+
DefaultRpcPort = 26657
4344
DefaultRestPort = 8080
4445
DefaultGrpcPort = 9090
46+
DefaultP2PPort = 16656
4547
)
4648

4749
type TestnetInitializer interface {

systemtests/testnet_init.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ func NewModifyConfigYamlInitializer(exec string, s *SystemUnderTest) *ModifyConf
118118
}
119119
}
120120

121-
const (
122-
rpcPortStart = 26657
123-
apiPortStart = 1317
124-
grpcPortStart = 9090
125-
p2pPortStart = 16656
126-
)
127-
128121
func (s ModifyConfigYamlInitializer) Initialize() {
129122
// init with legacy testnet command
130123
args := []string{
@@ -154,16 +147,16 @@ func (s ModifyConfigYamlInitializer) Initialize() {
154147
for i := 0; i < s.initialNodesCount; i++ {
155148
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
156149
id := string(mustV(p2p.LoadNodeKey(filepath.Join(nodeDir, "node_key.json"))).ID())
157-
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, p2pPortStart+i)
150+
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, DefaultP2PPort+i)
158151
}
159152

160153
// then update configs
161154
for i := 0; i < s.initialNodesCount; i++ {
162155
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
163156
nodeNumber := i
164157
EditToml(filepath.Join(nodeDir, "config.toml"), func(doc *tomledit.Document) {
165-
UpdatePort(doc, rpcPortStart+i, "rpc", "laddr")
166-
UpdatePort(doc, p2pPortStart+i, "p2p", "laddr")
158+
UpdatePort(doc, DefaultRpcPort+i, "rpc", "laddr")
159+
UpdatePort(doc, DefaultP2PPort+i, "p2p", "laddr")
167160
SetBool(doc, false, "p2p", "addr_book_strict")
168161
SetBool(doc, false, "p2p", "pex")
169162
SetBool(doc, true, "p2p", "allow_duplicate_ip")
@@ -174,8 +167,8 @@ func (s ModifyConfigYamlInitializer) Initialize() {
174167
SetValue(doc, s.commitTimeout.String(), "consensus", "timeout_commit")
175168
})
176169
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
177-
UpdatePort(doc, apiPortStart+i, "api", "address")
178-
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
170+
UpdatePort(doc, DefaultApiPort+i, "api", "address")
171+
UpdatePort(doc, DefaultGrpcPort+i, "grpc", "address")
179172
})
180173
}
181174
}

0 commit comments

Comments
 (0)