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

refactor(testnode): create genTx on Export (backport #3673) #3691

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions app/test/testnode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package app_test

import (
"testing"

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

func Test_testnode(t *testing.T) {
t.Run("testnode can start a network with default chain ID", func(t *testing.T) {
testnode.NewNetwork(t, testnode.DefaultConfig())
})
t.Run("testnode can start a network with a custom chain ID", func(t *testing.T) {
chainID := "custom-chain-id"
config := testnode.DefaultConfig().WithChainID(chainID)
testnode.NewNetwork(t, config)
})
}
15 changes: 6 additions & 9 deletions test/util/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ func (g *Genesis) AddValidator(val Validator) error {
return err
}

// Add the validator's genesis transaction
gentx, err := val.GenTx(g.ecfg, g.kr, g.ChainID)
if err != nil {
return err
}

// install the validator
g.genTxs = append(g.genTxs, gentx)
g.validators = append(g.validators, val)
return nil
}
Expand All @@ -192,7 +184,12 @@ func (g *Genesis) NewValidator(val Validator) error {
// Export returns the genesis document of the network.
func (g *Genesis) Export() (*coretypes.GenesisDoc, error) {
gentxs := make([]json.RawMessage, 0, len(g.genTxs))
for _, genTx := range g.genTxs {
for _, val := range g.validators {
genTx, err := val.GenTx(g.ecfg, g.kr, g.ChainID)
if err != nil {
return nil, err
}

bz, err := g.ecfg.TxConfig.TxJSONEncoder()(genTx)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions test/util/testnode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func DefaultConfig() *Config {
WithAppOptions(DefaultAppOptions()).
WithAppCreator(cmd.NewAppServer).
WithSuppressLogs(true).
WithConsensusParams(DefaultConsensusParams()).
WithSuppressLogs(true)
// TODO: consider removing this line because default consensus params is invoked above.
WithConsensusParams(DefaultConsensusParams())
}

func DefaultConsensusParams() *tmproto.ConsensusParams {
Expand Down
Loading