Skip to content

Commit

Permalink
fix(simapp/v2): panic with testnet init-files command (#21012)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli authored Jul 22, 2024
1 parent d2dc3ee commit f9f2ad7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion simapp/v2/simdv2/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/core/transaction"
svrcmd "cosmossdk.io/server/v2"
"cosmossdk.io/simapp/v2"
"cosmossdk.io/simapp/v2/simdv2/cmd"

"github.com/cosmos/cosmos-sdk/client/flags"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
)

Expand Down
2 changes: 1 addition & 1 deletion simapp/v2/simdv2/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func initTestnetFiles[T transaction.Tx](
// generate private keys, node IDs, and initial transactions
for i := 0; i < args.numValidators; i++ {
var portOffset int
var grpcConfig *grpc.Config
grpcConfig := grpc.DefaultConfig()
if args.singleMachine {
portOffset = i
p2pPortStart = 16656 // use different start point to not conflict with rpc port
Expand Down
27 changes: 27 additions & 0 deletions simapp/v2/simdv2/cmd/testnet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"cosmossdk.io/core/transaction"
svrcmd "cosmossdk.io/server/v2"
"cosmossdk.io/simapp/v2"
"cosmossdk.io/simapp/v2/simdv2/cmd"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
)

func TestInitTestFilesCmd(t *testing.T) {
rootCmd := cmd.NewRootCmd[transaction.Tx]()
rootCmd.SetArgs([]string{
"testnet", // Test the testnet init-files command
"init-files",
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), // Set keyring-backend to test
})

require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
}

0 comments on commit f9f2ad7

Please sign in to comment.