fix(systemtests): avoid HTTP server on port 8080 conflict when AddFullnode (#22810)
This commit is contained in:
parent
332d0b106d
commit
e07fee5cc1
@ -36,6 +36,10 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v1.0.0-rc.4] - 2024-12-10
|
||||
|
||||
* [#22810](https://github.com/cosmos/cosmos-sdk/pull/22810) Avoid HTTP server conflicts on port 8080
|
||||
|
||||
## [v1.0.0-rc.3] - 2024-12-05
|
||||
|
||||
* [#22774](https://github.com/cosmos/cosmos-sdk/pull/22774) Add greater than or equal support in Rest test suite
|
||||
|
||||
@ -22,6 +22,7 @@ import (
|
||||
client "github.com/cometbft/cometbft/rpc/client/http"
|
||||
ctypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
tmtypes "github.com/cometbft/cometbft/types"
|
||||
"github.com/creachadair/tomledit"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tidwall/sjson"
|
||||
|
||||
@ -38,7 +39,11 @@ var (
|
||||
|
||||
MaxGas = 10_000_000
|
||||
// DefaultApiPort is the port for the node to interact with
|
||||
DefaultApiPort = 1317
|
||||
DefaultApiPort = 1317
|
||||
DefaultRpcPort = 26657
|
||||
DefaultRestPort = 8080
|
||||
DefaultGrpcPort = 9090
|
||||
DefaultP2PPort = 16656
|
||||
)
|
||||
|
||||
type TestnetInitializer interface {
|
||||
@ -719,15 +724,21 @@ func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumb
|
||||
|
||||
configPath := filepath.Join(WorkDir, nodePath, "config")
|
||||
|
||||
// start node
|
||||
allNodes := s.AllNodes(t)
|
||||
node := allNodes[len(allNodes)-1]
|
||||
// quick hack: copy config and overwrite by start params
|
||||
for _, tomlFile := range []string{"config.toml", "app.toml"} {
|
||||
configFile := filepath.Join(configPath, tomlFile)
|
||||
_ = os.Remove(configFile)
|
||||
_ = MustCopyFile(filepath.Join(WorkDir, s.nodePath(0), "config", tomlFile), configFile)
|
||||
if tomlFile == "app.toml" && IsV2() {
|
||||
file := filepath.Join(WorkDir, s.nodePath(nodeNumber), "config", tomlFile)
|
||||
EditToml(file, func(doc *tomledit.Document) {
|
||||
SetValue(doc, fmt.Sprintf("%s:%d", node.IP, DefaultRestPort+nodeNumber), "rest", "address")
|
||||
})
|
||||
}
|
||||
}
|
||||
// start node
|
||||
allNodes := s.AllNodes(t)
|
||||
node := allNodes[len(allNodes)-1]
|
||||
peers := make([]string, len(allNodes)-1)
|
||||
for i, n := range allNodes[0 : len(allNodes)-1] {
|
||||
peers[i] = n.PeerAddr()
|
||||
@ -740,7 +751,7 @@ func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumb
|
||||
"--p2p.persistent_peers=" + strings.Join(peers, ","),
|
||||
fmt.Sprintf("--p2p.laddr=tcp://localhost:%d", node.P2PPort),
|
||||
fmt.Sprintf("--rpc.laddr=tcp://localhost:%d", node.RPCPort),
|
||||
fmt.Sprintf("--grpc.address=localhost:%d", 9090+nodeNumber),
|
||||
fmt.Sprintf("--grpc.address=localhost:%d", DefaultGrpcPort+nodeNumber),
|
||||
"--p2p.pex=false",
|
||||
"--moniker=" + moniker,
|
||||
"--log_level=info",
|
||||
|
||||
@ -118,13 +118,6 @@ func NewModifyConfigYamlInitializer(exec string, s *SystemUnderTest) *ModifyConf
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
rpcPortStart = 26657
|
||||
apiPortStart = 1317
|
||||
grpcPortStart = 9090
|
||||
p2pPortStart = 16656
|
||||
)
|
||||
|
||||
func (s ModifyConfigYamlInitializer) Initialize() {
|
||||
// init with legacy testnet command
|
||||
args := []string{
|
||||
@ -154,7 +147,7 @@ func (s ModifyConfigYamlInitializer) Initialize() {
|
||||
for i := 0; i < s.initialNodesCount; i++ {
|
||||
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
|
||||
id := string(mustV(p2p.LoadNodeKey(filepath.Join(nodeDir, "node_key.json"))).ID())
|
||||
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, p2pPortStart+i)
|
||||
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, DefaultP2PPort+i)
|
||||
}
|
||||
|
||||
// then update configs
|
||||
@ -162,8 +155,8 @@ func (s ModifyConfigYamlInitializer) Initialize() {
|
||||
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
|
||||
nodeNumber := i
|
||||
EditToml(filepath.Join(nodeDir, "config.toml"), func(doc *tomledit.Document) {
|
||||
UpdatePort(doc, rpcPortStart+i, "rpc", "laddr")
|
||||
UpdatePort(doc, p2pPortStart+i, "p2p", "laddr")
|
||||
UpdatePort(doc, DefaultRpcPort+i, "rpc", "laddr")
|
||||
UpdatePort(doc, DefaultP2PPort+i, "p2p", "laddr")
|
||||
SetBool(doc, false, "p2p", "addr_book_strict")
|
||||
SetBool(doc, false, "p2p", "pex")
|
||||
SetBool(doc, true, "p2p", "allow_duplicate_ip")
|
||||
@ -174,8 +167,8 @@ func (s ModifyConfigYamlInitializer) Initialize() {
|
||||
SetValue(doc, s.commitTimeout.String(), "consensus", "timeout_commit")
|
||||
})
|
||||
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
|
||||
UpdatePort(doc, apiPortStart+i, "api", "address")
|
||||
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
|
||||
UpdatePort(doc, DefaultApiPort+i, "api", "address")
|
||||
UpdatePort(doc, DefaultGrpcPort+i, "grpc", "address")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user