Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(systemtests): avoid HTTP server on port 8080 conflict when AddFullnode #22810

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(simapp/v2): avoid HTTP server on port 8080 conflict when AddFullnode
in TestValidatorDoubleSign
mmsqe committed Dec 10, 2024
commit 6097c9fd91cce4e5b24ad4ba85364783cd5a1318
19 changes: 14 additions & 5 deletions systemtests/system.go
Original file line number Diff line number Diff line change
@@ -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,9 @@ var (

MaxGas = 10_000_000
// DefaultApiPort is the port for the node to interact with
DefaultApiPort = 1317
DefaultApiPort = 1317
DefaultRestPort = 8080
DefaultGrpcPort = 9090
)

type TestnetInitializer interface {
@@ -719,15 +722,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" {
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 +749,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",