Skip to content

Commit

Permalink
chore: use DefaultNetwork instead of duplicate code (#1410)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

Remove duplicated code and use directly `DefaultNetwork`.

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords
  • Loading branch information
rach-id authored Feb 22, 2023
1 parent f88dc67 commit 37614da
Showing 1 changed file with 2 additions and 40 deletions.
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

0 comments on commit 37614da

Please sign in to comment.