GetCmd uses the provided chainID and operatorAddress as well as the local private validator key to control the network represented in the data folder. This is useful to create testnets nearly identical to your mainnet environment.
(testnetAppCreator types.AppCreator)
| 47 | // control the network represented in the data folder. This is useful to create testnets nearly identical to your |
| 48 | // mainnet environment. |
| 49 | func GetCmd(testnetAppCreator types.AppCreator) *cobra.Command { |
| 50 | opts := sdksrv.StartCmdOptions{} |
| 51 | if opts.DBOpener == nil { |
| 52 | opts.DBOpener = openDB |
| 53 | } |
| 54 | |
| 55 | cmd := &cobra.Command{ |
| 56 | Use: "testnetify", |
| 57 | Short: "Create a testnet from current local state", |
| 58 | Long: `Create a testnet from current local state. |
| 59 | After utilizing this command the network will start. If the network is stopped, |
| 60 | the normal "start" command should be used. Re-using this command on state that |
| 61 | has already been modified by this command could result in unexpected behavior. |
| 62 | |
| 63 | Additionally, the first block may take a few minutes to be committed, depending |
| 64 | on how old the block is. For instance, if a snapshot was taken weeks ago and we want |
| 65 | to turn this into a testnet, it is possible lots of pending state needs to be committed |
| 66 | (expiring locks, etc.). It is recommended that you should wait for this block to be committed |
| 67 | before stopping the daemon. |
| 68 | |
| 69 | If the --trigger-testnet-upgrade flag is set, the upgrade handler specified by the flag will be run |
| 70 | on the first block of the testnet. |
| 71 | |
| 72 | Regardless of whether the flag is set or not, if any new stores are introduced in the daemon being run, |
| 73 | those stores will be registered in order to prevent panics. Therefore, you only need to set the flag if |
| 74 | you want to test the upgrade handler itself. |
| 75 | `, |
| 76 | Example: "testnetify", |
| 77 | Args: cobra.NoArgs, |
| 78 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 79 | sctx := sdksrv.GetServerContextFromCmd(cmd) |
| 80 | cctx, err := client.GetClientQueryContext(cmd) |
| 81 | if err != nil { |
| 82 | return err |
| 83 | } |
| 84 | |
| 85 | _, err = sdksrv.GetPruningOptionsFromFlags(sctx.Viper) |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | |
| 90 | sctx.Logger.Info("testnetifying blockchain state") |
| 91 | cfg := TestnetConfig{} |
| 92 | |
| 93 | cfgFilePath, err := cmd.Flags().GetString(cflags.KeyTestnetConfig) |
| 94 | if err != nil { |
| 95 | return err |
| 96 | } |
| 97 | cfgFile, err := os.Open(cfgFilePath) //nolint: gosec |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | defer func() { |
| 103 | _ = cfgFile.Close() |
| 104 | }() |
| 105 | |
| 106 | cfgData, err := io.ReadAll(cfgFile) |
no test coverage detected