Skip to content

Commit

Permalink
chore: bump app v1.0.0 rc11 (celestiaorg#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes authored Aug 2, 2023
1 parent 110a41c commit fb8702d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 101 deletions.
4 changes: 2 additions & 2 deletions core/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestRemoteClient_Status(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
t.Cleanup(cancel)

client := StartTestNode(t).Client
Expand All @@ -20,7 +20,7 @@ func TestRemoteClient_Status(t *testing.T) {
}

func TestRemoteClient_StartBlockSubscription_And_GetBlock(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
t.Cleanup(cancel)

client := StartTestNode(t).Client
Expand Down
2 changes: 1 addition & 1 deletion core/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCoreExchange_RequestHeaders(t *testing.T) {
assert.Equal(t, 10, len(headers))
}

func createCoreFetcher(t *testing.T, cfg *TestConfig) (*BlockFetcher, testnode.Context) {
func createCoreFetcher(t *testing.T, cfg *testnode.Config) (*BlockFetcher, testnode.Context) {
cctx := StartTestNodeWithConfig(t, cfg)
// wait for height 2 in order to be able to start submitting txs (this prevents
// flakiness with accessing account state)
Expand Down
4 changes: 2 additions & 2 deletions core/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
t.Cleanup(cancel)

client := StartTestNode(t).Client
Expand Down Expand Up @@ -42,7 +42,7 @@ func TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent(t *testing.T) {
// TestBlockFetcherHeaderValues tests that both the Commit and ValidatorSet
// endpoints are working as intended.
func TestBlockFetcherHeaderValues(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
t.Cleanup(cancel)

client := StartTestNode(t).Client
Expand Down
86 changes: 13 additions & 73 deletions core/testing.go
Original file line number Diff line number Diff line change
@@ -1,48 +1,27 @@
package core

import (
"fmt"
"net"
"net/url"
"testing"
"time"

appconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/stretchr/testify/require"
tmconfig "github.com/tendermint/tendermint/config"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/celestiaorg/celestia-app/test/util/testnode"
)

// TestConfig encompasses all the configs required to run test Tendermint + Celestia App tandem.
type TestConfig struct {
ConsensusParams *tmproto.ConsensusParams
Tendermint *tmconfig.Config
App *appconfig.Config

Accounts []string
SuppressLogs bool
}

// DefaultTestConfig returns the default testing configuration for Tendermint + Celestia App tandem.
//
// It fetches free ports from OS and sets them into configs, s.t.
// user can make use of them(unlike 0 port) and allowing to run
// multiple tests nodes in parallel.
//
// Additionally, it instructs Tendermint + Celestia App tandem to setup 10 funded accounts.
func DefaultTestConfig() *TestConfig {
conCfg := testnode.DefaultParams()

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

appCfg := testnode.DefaultAppConfig()
appCfg.GRPC.Address = fmt.Sprintf("127.0.0.1:%d", getFreePort())
appCfg.API.Address = fmt.Sprintf("tcp://127.0.0.1:%d", getFreePort())
func DefaultTestConfig() *testnode.Config {
cfg := testnode.DefaultConfig()

// instructs creating funded accounts
// 10 usually is enough for testing
Expand All @@ -51,13 +30,13 @@ func DefaultTestConfig() *TestConfig {
accounts[i] = tmrand.Str(9)
}

return &TestConfig{
ConsensusParams: conCfg,
Tendermint: tnCfg,
App: appCfg,
Accounts: accounts,
SuppressLogs: true,
}
cfg.TmConfig.Consensus.TimeoutCommit = time.Millisecond * 200

cfg = cfg.
WithAccounts(accounts).
WithSupressLogs(true)

return cfg
}

// StartTestNode simply starts Tendermint and Celestia App tandem with default testing
Expand All @@ -67,40 +46,13 @@ func StartTestNode(t *testing.T) testnode.Context {
}

// StartTestNodeWithConfig starts Tendermint and Celestia App tandem with custom configuration.
func StartTestNodeWithConfig(t *testing.T, cfg *TestConfig) testnode.Context {
state, kr, err := testnode.DefaultGenesisState(cfg.Accounts...)
require.NoError(t, err)

tmNode, app, cctx, err := testnode.New(
t,
cfg.ConsensusParams,
cfg.Tendermint,
cfg.SuppressLogs,
state,
kr,
"private",
)
require.NoError(t, err)

cctx, cleanupCoreNode, err := testnode.StartNode(tmNode, cctx)
require.NoError(t, err)
t.Cleanup(func() {
err := cleanupCoreNode()
require.NoError(t, err)
})

cctx, cleanupGRPCServer, err := StartGRPCServer(app, cfg.App, cctx)
require.NoError(t, err)
t.Cleanup(func() {
err := cleanupGRPCServer()
require.NoError(t, err)
})

func StartTestNodeWithConfig(t *testing.T, cfg *testnode.Config) testnode.Context {
cctx, _, _ := testnode.NewNetwork(t, cfg)
// we want to test over remote http client,
// so we are as close to the real environment as possible
// however, it might be useful to use local tendermint client
// if you need to debug something inside of it
ip, port, err := getEndpoint(cfg.Tendermint)
ip, port, err := getEndpoint(cfg.TmConfig)
require.NoError(t, err)
client, err := NewRemote(ip, port)
require.NoError(t, err)
Expand All @@ -116,18 +68,6 @@ func StartTestNodeWithConfig(t *testing.T, cfg *TestConfig) testnode.Context {
return cctx
}

func getFreePort() int {
a, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port
}
}
panic("while getting free port: " + err.Error())
}

func getEndpoint(cfg *tmconfig.Config) (string, string, error) {
url, err := url.Parse(cfg.RPC.ListenAddress)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/alecthomas/jsonschema v0.0.0-20200530073317-71f438968921
github.com/benbjohnson/clock v1.3.5
github.com/celestiaorg/celestia-app v1.0.0-rc10
github.com/celestiaorg/celestia-app v1.0.0-rc11
github.com/celestiaorg/go-fraud v0.1.2
github.com/celestiaorg/go-header v0.2.12
github.com/celestiaorg/go-libp2p-messenger v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/celestiaorg/celestia-app v1.0.0-rc10 h1:wglTplF5qVVOtSYCGtNHz8qA37azD+fgcxCKAphYL6c=
github.com/celestiaorg/celestia-app v1.0.0-rc10/go.mod h1:A17xfzurB2RHpplh6+nGMeC9hCquu0aMYnanOeifDO0=
github.com/celestiaorg/celestia-app v1.0.0-rc11 h1:u94drhPdvgwNvx0F2xGib+fyOyP+fIvp3aL6Avd/HT0=
github.com/celestiaorg/celestia-app v1.0.0-rc11/go.mod h1:A17xfzurB2RHpplh6+nGMeC9hCquu0aMYnanOeifDO0=
github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28 h1:eXS3v26nob8Xs2+flKHVxcTzhzQW44KgTcooR3OxnK4=
github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28/go.mod h1:J/GsBjoTZaFz71VeyrLZbG8rV+Rzi6oFEUZUipQ97hQ=
github.com/celestiaorg/cosmos-sdk v1.16.1-sdk-v0.46.13 h1:CxEQDQEQR1ypB+VUmCISIqFVmHfb+mx8x+zh7rHbyU8=
Expand Down
4 changes: 2 additions & 2 deletions nodebuilder/tests/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
)

func TestBlobModule(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
t.Cleanup(cancel)
sw := swamp.NewSwamp(t)
sw := swamp.NewSwamp(t, swamp.WithBlockTime(time.Second*1))

appBlobs0, err := blobtest.GenerateV0Blobs([]int{8, 4}, true)
require.NoError(t, err)
Expand Down
10 changes: 10 additions & 0 deletions nodebuilder/tests/reconstruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestFullReconstructFromBridge(t *testing.T) {
err := bridge.Start(ctx)
require.NoError(t, err)

// TODO: This is required to avoid flakes coming from unfinished retry
// mechanism for the same peer in go-header
_, err = bridge.HeaderServ.WaitForHeight(ctx, uint64(blocks))
require.NoError(t, err)

cfg := nodebuilder.DefaultConfig(node.Full)
cfg.Share.UseShareExchange = false
cfg.Header.TrustedPeers = append(cfg.Header.TrustedPeers, getMultiAddr(t, bridge.Host))
Expand Down Expand Up @@ -125,6 +130,11 @@ func TestFullReconstructFromLights(t *testing.T) {
require.NoError(t, bridge.Start(ctx))
bootstrapperAddr := host.InfoFromHost(bootstrapper.Host)

// TODO: This is required to avoid flakes coming from unfinished retry
// mechanism for the same peer in go-header
_, err = bridge.HeaderServ.WaitForHeight(ctx, uint64(blocks))
require.NoError(t, err)

cfg = nodebuilder.DefaultConfig(node.Full)
setTimeInterval(cfg, defaultTimeInterval)
cfg.Share.UseShareExchange = false
Expand Down
25 changes: 10 additions & 15 deletions nodebuilder/tests/swamp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,30 @@ package swamp
import (
"time"

"github.com/celestiaorg/celestia-app/test/util/testnode"

"github.com/celestiaorg/celestia-node/core"
)

// Config struct represents a set of pre-requisite attributes from the test scenario
type Config struct {
*core.TestConfig
}

// DefaultConfig creates a celestia-app instance with a block time of around
// 100ms
func DefaultConfig() *Config {
func DefaultConfig() *testnode.Config {
cfg := core.DefaultTestConfig()
// timeout commit lower than this tend to be flakier
cfg.Tendermint.Consensus.TimeoutCommit = 200 * time.Millisecond
return &Config{
cfg,
}
cfg.TmConfig.Consensus.TimeoutCommit = 200 * time.Millisecond
return cfg
}

// Option for modifying Swamp's Config.
type Option func(*Config)
type Option func(*testnode.Config)

// WithBlockTime sets a custom interval for block creation.
func WithBlockTime(t time.Duration) Option {
return func(c *Config) {
return func(c *testnode.Config) {
// for empty block
c.Tendermint.Consensus.CreateEmptyBlocksInterval = t
c.TmConfig.Consensus.CreateEmptyBlocksInterval = t
// for filled block
c.Tendermint.Consensus.TimeoutCommit = t
c.Tendermint.Consensus.SkipTimeoutCommit = false
c.TmConfig.Consensus.TimeoutCommit = t
c.TmConfig.Consensus.SkipTimeoutCommit = false
}
}
6 changes: 3 additions & 3 deletions nodebuilder/tests/swamp/swamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const DefaultTestTimeout = time.Minute * 5
// - trustedHash taken from the CoreClient and shared between nodes
type Swamp struct {
t *testing.T
cfg *Config
cfg *testnode.Config

Network mocknet.Mocknet
Bootstrappers []ma.Multiaddr
Expand Down Expand Up @@ -76,7 +76,7 @@ func NewSwamp(t *testing.T, options ...Option) *Swamp {
// Now, we are making an assumption that consensus mechanism is already tested out
// so, we are not creating bridge nodes with each one containing its own core client
// instead we are assigning all created BNs to 1 Core from the swamp
cctx := core.StartTestNodeWithConfig(t, ic.TestConfig)
cctx := core.StartTestNodeWithConfig(t, ic)
swp := &Swamp{
t: t,
cfg: ic,
Expand Down Expand Up @@ -188,7 +188,7 @@ func (s *Swamp) setupGenesis() {
func (s *Swamp) DefaultTestConfig(tp node.Type) *nodebuilder.Config {
cfg := nodebuilder.DefaultConfig(tp)

ip, port, err := net.SplitHostPort(s.cfg.App.GRPC.Address)
ip, port, err := net.SplitHostPort(s.cfg.AppConfig.GRPC.Address)
require.NoError(s.t, err)

cfg.Core.IP = ip
Expand Down

0 comments on commit fb8702d

Please sign in to comment.