Skip to content

Commit

Permalink
feat: add test port range Env
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Apr 17, 2024
1 parent 771a9d2 commit 99347ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/node/machinehash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cartesi/rollups-node/internal/deps"
"github.com/cartesi/rollups-node/internal/machine"
"github.com/cartesi/rollups-node/pkg/addresses"
"github.com/cartesi/rollups-node/pkg/testutil"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -139,7 +140,7 @@ func startDevnet() (*deps.DepsContainers, error) {
DockerImage: deps.DefaultDevnetDockerImage,
BlockTime: deps.DefaultBlockTime,
BlockToWaitForOnStartup: deps.DefaultBlockToWaitForOnStartup,
Port: "",
Port: testutil.GetCartesiTestDepsPortRange(),
},
})
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/ethutil/ethutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/cartesi/rollups-node/internal/deps"
"github.com/cartesi/rollups-node/pkg/addresses"
"github.com/cartesi/rollups-node/pkg/testutil"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -97,7 +98,7 @@ func newDevNetContainer(ctx context.Context) (*deps.DepsContainers, error) {
DockerImage: deps.DefaultDevnetDockerImage,
BlockTime: deps.DefaultBlockTime,
BlockToWaitForOnStartup: deps.DefaultBlockToWaitForOnStartup,
Port: "",
Port: testutil.GetCartesiTestDepsPortRange(),
},
})
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

// This package contains tests utilities.

package testutil

import "os"

func GetCartesiTestDepsPortRange() string {
return os.Getenv("CARTESI_TEST_DEPS_PORT_RANGE")
}
5 changes: 3 additions & 2 deletions test/echo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cartesi/rollups-node/internal/node"
"github.com/cartesi/rollups-node/pkg/ethutil"
"github.com/cartesi/rollups-node/pkg/readerclient"
"github.com/cartesi/rollups-node/pkg/testutil"
"github.com/stretchr/testify/suite"
)

Expand Down Expand Up @@ -63,12 +64,12 @@ func (s *EchoInputTestSuite) SetupTest() {
var depsConfig = deps.DepsConfig{
&deps.PostgresConfig{
DockerImage: deps.DefaultPostgresDockerImage,
Port: "",
Port: testutil.GetCartesiTestDepsPortRange(),
Password: deps.DefaultPostgresPassword,
},
&deps.DevnetConfig{
DockerImage: deps.DefaultDevnetDockerImage,
Port: "",
Port: testutil.GetCartesiTestDepsPortRange(),
BlockTime: devNetMiningBlockTimeInSeconds,
BlockToWaitForOnStartup: deps.DefaultBlockToWaitForOnStartup,
},
Expand Down

0 comments on commit 99347ca

Please sign in to comment.