Skip to content

Commit

Permalink
feat: support custom mnemonics in in-process testing network (backport
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored and JeancarloBarrios committed Sep 28, 2024
1 parent 87c6f53 commit 5a986d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func initTestnetFiles(
return err
}

addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo, sdk.GetFullBIP44Path())
addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo)
if err != nil {
_ = os.RemoveAll(args.outputDir)
return err
Expand Down
28 changes: 10 additions & 18 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,12 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) {
cmtCfg.P2P.AddrBookStrict = false
cmtCfg.P2P.AllowDuplicateIP = true

cmtConfigs[i] = cmtCfg
p2pAddr, _, err := server.FreeTCPAddr()
require.NoError(t, err)

var mnemonic string
if i < len(cfg.Mnemonics) {
mnemonic = cfg.Mnemonics[i]
}

nodeID, pubKey, err := genutil.InitializeNodeValidatorFilesFromMnemonic(cmtCfg, mnemonic, ed25519.PrivKeyName)
if err != nil {
return nil, err
}
tmCfg.P2P.ListenAddress = p2pAddr
tmCfg.P2P.AddrBookStrict = false
tmCfg.P2P.AllowDuplicateIP = true

nodeIDs[i] = nodeID
valPubKeys[i] = pubKey
Expand All @@ -452,16 +447,13 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) {
return nil, err
}

addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, mnemonic, true, algo, sdk.GetFullBIP44Path())
if err != nil {
return nil, err
var mnemonic string
if i < len(cfg.Mnemonics) {
mnemonic = cfg.Mnemonics[i]
}

// if PrintMnemonic is set to true, we print the first validator node's secret to the network's logger
// for debugging and manual testing
if cfg.PrintMnemonic && i == 0 {
printMnemonic(l, secret)
}
addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, mnemonic, true, algo)
require.NoError(t, err)

info := map[string]string{"secret": secret}
infoBz, err := json.Marshal(info)
Expand Down

0 comments on commit 5a986d9

Please sign in to comment.