From b8c463ffbe0a03f5a4a3dd363525d83bf4049f2c Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Wed, 13 Dec 2023 16:37:55 +0800 Subject: [PATCH] fix(test): chain monitor server endpoint conflict (#1047) Co-authored-by: georgehao --- common/version/version.go | 2 +- rollup/internal/controller/relayer/relayer_test.go | 7 +++++++ rollup/tests/bridge_test.go | 8 ++++++++ rollup/tests/process_start_test.go | 12 ++++++------ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/common/version/version.go b/common/version/version.go index a97953e2db..c8b2aed094 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.43" +var tag = "v4.3.44" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/rollup/internal/controller/relayer/relayer_test.go b/rollup/internal/controller/relayer/relayer_test.go index 519408aa4f..6ca76d8cf4 100644 --- a/rollup/internal/controller/relayer/relayer_test.go +++ b/rollup/internal/controller/relayer/relayer_test.go @@ -1,8 +1,11 @@ package relayer import ( + "crypto/rand" "encoding/json" + "math/big" "os" + "strconv" "testing" "github.com/scroll-tech/go-ethereum/common" @@ -52,6 +55,10 @@ func setupEnv(t *testing.T) { MaxOpenNum: base.DBConfig.MaxOpenNum, MaxIdleNum: base.DBConfig.MaxIdleNum, } + port, err := rand.Int(rand.Reader, big.NewInt(10000)) + assert.NoError(t, err) + svrPort := strconv.FormatInt(port.Int64()+50000, 10) + cfg.L2Config.RelayerConfig.ChainMonitor.BaseURL = "http://localhost:" + svrPort // Create l2geth client. l2Cli, err = base.L2Client() diff --git a/rollup/tests/bridge_test.go b/rollup/tests/bridge_test.go index 34a6ba6d69..57ab7dac11 100644 --- a/rollup/tests/bridge_test.go +++ b/rollup/tests/bridge_test.go @@ -2,7 +2,10 @@ package tests import ( "context" + "crypto/rand" + "math/big" "net/http" + "strconv" "strings" "testing" @@ -84,6 +87,11 @@ func setupEnv(t *testing.T) { l2Auth, err = bind.NewKeyedTransactorWithChainID(rollupApp.Config.L1Config.RelayerConfig.GasOracleSenderPrivateKey, base.L2gethImg.ChainID()) assert.NoError(t, err) + + port, err := rand.Int(rand.Reader, big.NewInt(10000)) + assert.NoError(t, err) + svrPort := strconv.FormatInt(port.Int64()+40000, 10) + rollupApp.Config.L2Config.RelayerConfig.ChainMonitor.BaseURL = "http://localhost:" + svrPort } func mockChainMonitorServer(baseURL string) (*http.Server, error) { diff --git a/rollup/tests/process_start_test.go b/rollup/tests/process_start_test.go index 58fe9eef9e..83189cb97f 100644 --- a/rollup/tests/process_start_test.go +++ b/rollup/tests/process_start_test.go @@ -31,19 +31,19 @@ func testProcessStartEnableMetrics(t *testing.T) { db := setupDB(t) defer database.CloseDB(db) - port, err := rand.Int(rand.Reader, big.NewInt(2000)) + port, err := rand.Int(rand.Reader, big.NewInt(10000)) assert.NoError(t, err) - svrPort := strconv.FormatInt(port.Int64()+50000, 10) + svrPort := strconv.FormatInt(port.Int64()+10000, 10) rollupApp.RunApp(t, cutils.EventWatcherApp, "--metrics", "--metrics.addr", "localhost", "--metrics.port", svrPort) - port, err = rand.Int(rand.Reader, big.NewInt(2000)) + port, err = rand.Int(rand.Reader, big.NewInt(10000)) assert.NoError(t, err) - svrPort = strconv.FormatInt(port.Int64()+50000, 10) + svrPort = strconv.FormatInt(port.Int64()+20000, 10) rollupApp.RunApp(t, cutils.GasOracleApp, "--metrics", "--metrics.addr", "localhost", "--metrics.port", svrPort) - port, err = rand.Int(rand.Reader, big.NewInt(2000)) + port, err = rand.Int(rand.Reader, big.NewInt(10000)) assert.NoError(t, err) - svrPort = strconv.FormatInt(port.Int64()+50000, 10) + svrPort = strconv.FormatInt(port.Int64()+30000, 10) rollupApp.RunApp(t, cutils.RollupRelayerApp, "--metrics", "--metrics.addr", "localhost", "--metrics.port", svrPort) rollupApp.WaitExit()