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

chore: use DefaultNetwork instead of duplicate code #1410

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
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
42 changes: 2 additions & 40 deletions testutil/testnode/full_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/testutil/namespace"
"github.com/celestiaorg/celestia-app/testutil/testfactory"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
Expand All @@ -19,7 +19,6 @@ import (
type IntegrationTestSuite struct {
suite.Suite

cleanups []func() error
accounts []string
cctx Context
}
Expand All @@ -30,45 +29,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
}

s.T().Log("setting up integration test suite")
require := s.Require()

// we create an arbitrary number of funded accounts
for i := 0; i < 300; i++ {
s.accounts = append(s.accounts, tmrand.Str(9))
}

genState, kr, err := DefaultGenesisState(s.accounts...)
require.NoError(err)

tmCfg := DefaultTendermintConfig()
tmCfg.RPC.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", getFreePort())
tmCfg.P2P.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", getFreePort())
tmCfg.RPC.GRPCListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", getFreePort())

tmNode, app, cctx, err := New(s.T(), DefaultParams(), tmCfg, false, genState, kr)
require.NoError(err)

cctx, stopNode, err := StartNode(tmNode, cctx)
require.NoError(err)
s.cleanups = append(s.cleanups, stopNode)

appConf := DefaultAppConfig()
appConf.GRPC.Address = fmt.Sprintf("127.0.0.1:%d", getFreePort())
appConf.API.Address = fmt.Sprintf("tcp://127.0.0.1:%d", getFreePort())

cctx, cleanupGRPC, err := StartGRPCServer(app, appConf, cctx)
require.NoError(err)
s.cleanups = append(s.cleanups, cleanupGRPC)

s.cctx = cctx
}

func (s *IntegrationTestSuite) TearDownSuite() {
s.T().Log("tearing down integration test suite")
for _, c := range s.cleanups {
err := c()
require.NoError(s.T(), err)
}
s.accounts, s.cctx = DefaultNetwork(s.T(), 400*time.Millisecond)
}

func (s *IntegrationTestSuite) Test_Liveness() {
Expand Down