Browse Source

testnet cmd: add config option (#3559)

Option to explicitly provide the -config in the testnet command, closing #3160.
pull/3594/head
Greg Hill 5 years ago
committed by Anton Kaliaev
parent
commit
968e955c46
2 changed files with 20 additions and 0 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +19
    -0
      cmd/tendermint/commands/testnet.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -18,6 +18,7 @@
### IMPROVEMENTS:
- [rpc] [\#3534](https://github.com/tendermint/tendermint/pull/3534) Add support for batched requests/responses in JSON RPC
- [cli] [\#3160](https://github.com/tendermint/tendermint/issues/3160) Add `-config=<path-to-config>` option to `testnet` cmd (@gregdhill)
- [cs/replay] \#3460 check appHash for each block
### BUG FIXES:


+ 19
- 0
cmd/tendermint/commands/testnet.go View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
@ -20,6 +21,7 @@ import (
var (
nValidators int
nNonValidators int
configFile string
outputDir string
nodeDirPrefix string
@ -36,6 +38,8 @@ const (
func init() {
TestnetFilesCmd.Flags().IntVar(&nValidators, "v", 4,
"Number of validators to initialize the testnet with")
TestnetFilesCmd.Flags().StringVar(&configFile, "config", "",
"Config file to use (note some options may be overwritten)")
TestnetFilesCmd.Flags().IntVar(&nNonValidators, "n", 0,
"Number of non-validators to initialize the testnet with")
TestnetFilesCmd.Flags().StringVar(&outputDir, "o", "./mytestnet",
@ -73,6 +77,21 @@ Example:
func testnetFiles(cmd *cobra.Command, args []string) error {
config := cfg.DefaultConfig()
// overwrite default config if set and valid
if configFile != "" {
viper.SetConfigFile(configFile)
if err := viper.ReadInConfig(); err != nil {
return err
}
if err := viper.Unmarshal(config); err != nil {
return err
}
if err := config.ValidateBasic(); err != nil {
return err
}
}
genVals := make([]types.GenesisValidator, nValidators)
for i := 0; i < nValidators; i++ {


Loading…
Cancel
Save