testnetCmd gets the cmd to initialize all files for tendermint testnet and application.
(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator)
| 50 | |
| 51 | // testnetCmd gets the cmd to initialize all files for tendermint testnet and application. |
| 52 | func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { |
| 53 | cmd := &cobra.Command{ |
| 54 | Use: "testnet", |
| 55 | Short: "Initialize files for a simapp testnet", |
| 56 | Long: `testnet will create "v" number of directories and populate each with |
| 57 | necessary files (private validator, genesis, config, etc.). |
| 58 | |
| 59 | Note, strict routability for addresses is turned off in the config file. |
| 60 | |
| 61 | Example: |
| 62 | osmosisd testnet --v 4 --output-dir ./output --starting-ip-address 192.168.10.2 |
| 63 | `, |
| 64 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 65 | clientCtx, err := client.GetClientQueryContext(cmd) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | serverCtx := server.GetServerContextFromCmd(cmd) |
| 70 | config := serverCtx.Config |
| 71 | |
| 72 | outputDir, _ := cmd.Flags().GetString(flagOutputDir) |
| 73 | keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) |
| 74 | chainID, _ := cmd.Flags().GetString(flags.FlagChainID) |
| 75 | minGasPrices, _ := cmd.Flags().GetString(server.FlagMinGasPrices) |
| 76 | nodeDirPrefix, _ := cmd.Flags().GetString(flagNodeDirPrefix) |
| 77 | nodeDaemonHome, _ := cmd.Flags().GetString(flagNodeDaemonHome) |
| 78 | startingIPAddress, _ := cmd.Flags().GetString(flagStartingIPAddress) |
| 79 | numValidators, _ := cmd.Flags().GetInt(flagNumValidators) |
| 80 | algo, _ := cmd.Flags().GetString(flagKeyAlgorithm) |
| 81 | |
| 82 | if chainID == "" { |
| 83 | chainID = "chain-" + tmrand.NewRand().Str(6) |
| 84 | } |
| 85 | |
| 86 | // get testnet genesis params |
| 87 | genesisParams := TestnetGenesisParams() |
| 88 | |
| 89 | return InitTestnet( |
| 90 | clientCtx, cmd, config, mbm, genBalIterator, genesisParams, chainID, outputDir, minGasPrices, |
| 91 | nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators, |
| 92 | ) |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with") |
| 97 | cmd.Flags().StringP(flagOutputDir, "o", "./mytestnet", "Directory to store initialization data for the testnet") |
| 98 | cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") |
| 99 | cmd.Flags().String(flagNodeDaemonHome, "osmosisd", "Home directory of the node's daemon configuration") |
| 100 | cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") |
| 101 | cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") |
| 102 | cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", TestnetGenesisParams().NativeCoinMetadatas[0].Base), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.001uakt)") |
| 103 | cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") |
| 104 | cmd.Flags().String(flagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") |
| 105 | |
| 106 | return cmd |
| 107 | } |
| 108 | |
| 109 | const nodeDirPerm = 0o755 |
no test coverage detected