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

feat: support custom mnemonics in in-process testing network #10922

Merged
merged 14 commits into from
Jan 12, 2022
Merged
14 changes: 13 additions & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type Config struct {
TimeoutCommit time.Duration // the consensus commitment timeout
ChainID string // the network chain-id
NumValidators int // the total number of validators to create and bond
Mnemonics []string // custom user-provided validator mnemonics
BondDenom string // the staking bond denomination
MinGasPrices string // the minimum gas prices each validator will accept
AccountTokens sdk.Int // the amount of unique validator tokens (e.g. 1000node0)
Expand Down Expand Up @@ -327,14 +328,25 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
if err != nil {
return nil, err
}

tmCfg.P2P.ListenAddress = p2pAddr
tmCfg.P2P.AddrBookStrict = false
tmCfg.P2P.AllowDuplicateIP = true

nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(tmCfg)
var (
nodeID string
pubKey cryptotypes.PubKey
)

if i < len(cfg.Mnemonics) && cfg.Mnemonics[i] != "" {
nodeID, pubKey, err = genutil.InitializeNodeValidatorFilesFromMnemonic(tmCfg, cfg.Mnemonics[i])
} else {
nodeID, pubKey, err = genutil.InitializeNodeValidatorFiles(tmCfg)
}
if err != nil {
return nil, err
}

nodeIDs[i] = nodeID
valPubKeys[i] = pubKey

Expand Down