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: int in-place testnet creation #4297

Merged
merged 40 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
490cb6f
int in-place testnet creation
likesToEatFish Aug 9, 2024
7867c87
merge main
likesToEatFish Aug 9, 2024
6e51b12
takes many arguments for command and move dependencies to testnet file
likesToEatFish Aug 12, 2024
01b6af7
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 12, 2024
21bc6c2
changelog
likesToEatFish Aug 12, 2024
6e3c919
add command testnet inplace
likesToEatFish Aug 13, 2024
8ccfebc
Merge pull request #1 from likesToEatFish/dong/cmdignitetestnet
likesToEatFish Aug 13, 2024
9a1bd7f
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 13, 2024
376beb4
updates
likesToEatFish Aug 13, 2024
6976bc3
minor
likesToEatFish Aug 16, 2024
27d7fdd
split InPlaceOption to another file
likesToEatFish Aug 16, 2024
2a19044
remove OperatorAddress and use normal accounts
likesToEatFish Aug 16, 2024
6ad2f1f
Merge pull request #2 from likesToEatFish/duong/3000
likesToEatFish Aug 16, 2024
6faece1
minor
likesToEatFish Aug 16, 2024
48ae91a
updates
likesToEatFish Aug 16, 2024
75c5016
minor
likesToEatFish Aug 16, 2024
99dcc09
Merge pull request #3 from likesToEatFish/duong/3000
likesToEatFish Aug 16, 2024
52bc3d1
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 16, 2024
88aca11
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 19, 2024
7bd3490
updates docs
likesToEatFish Aug 28, 2024
882780d
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 28, 2024
0f4b8c6
minor typo
likesToEatFish Aug 29, 2024
7b93ce1
revert baseappOptions
likesToEatFish Aug 29, 2024
a12e78a
minor
likesToEatFish Aug 29, 2024
6e27849
display the logging
likesToEatFish Aug 29, 2024
751aa8d
minor
likesToEatFish Aug 29, 2024
fc295c9
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 29, 2024
5130a8c
Merge branch 'main' into duong/in-place-testnet
Pantani Aug 29, 2024
81e1e7c
Update ignite/cmd/testnet_inplace.go
likesToEatFish Aug 30, 2024
cd06599
Update ignite/services/chain/testnet.go
likesToEatFish Aug 30, 2024
b98ff33
Update ignite/services/chain/testnet.go
likesToEatFish Aug 30, 2024
4cfa9e0
Update ignite/cmd/testnet_inplace.go
likesToEatFish Aug 30, 2024
5d09ef5
updates
likesToEatFish Aug 30, 2024
b86f129
moves method TestnetInPlaceCommand to testnet file
likesToEatFish Aug 30, 2024
2a4a60d
Merge branch 'main' into duong/in-place-testnet
Pantani Aug 30, 2024
f618081
make format
likesToEatFish Aug 30, 2024
b0759a1
remove setting slashing in testnet
likesToEatFish Aug 30, 2024
2579a64
setting slashing
likesToEatFish Aug 31, 2024
67dd7f1
Merge branch 'main' into duong/in-place-testnet
likesToEatFish Aug 31, 2024
66e4032
Merge branch 'main' into duong/in-place-testnet
julienrbrt Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation
- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands
- [#4297](https://github.com/ignite/cli/pull/4297) Add in-place testnet creation command for apps.
- [#4300](https://github.com/ignite/cli/pull/4300) Only panics the module in the most top function level
- [#4327](https://github.com/ignite/cli/pull/4327) Use the TxConfig from simState instead create a new one
- [#4326](https://github.com/ignite/cli/pull/4326) fAdd `buf.build` version to `ignite version` command
Expand Down
70 changes: 70 additions & 0 deletions docs/docs/03-CLI-Commands/01-cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To get started, create a blockchain:
* [ignite relayer](#ignite-relayer) - Connect blockchains with an IBC relayer
* [ignite scaffold](#ignite-scaffold) - Create a new blockchain, module, message, query, and more
* [ignite version](#ignite-version) - Print the current build information
* [ignite testnet](#ignite-testnet) - Start a testnet local


## ignite account
Expand Down Expand Up @@ -3658,3 +3659,72 @@ ignite version [flags]

* [ignite](#ignite) - Ignite CLI offers everything you need to scaffold, test, build, and launch your blockchain


## ignite testnet

Start a testnet local

**Synopsis**

The commands in this namespace allow you to start your local testnet for development purposes. Currently there is only one feature to create a testnet from any state network (including mainnet).


The "in-place" command is used to create and start a testnet from current local net state(including mainnet).
After using this command in the repo containing the config.yml file, the network will start.
We can create a testnet from the local network state and mint additional coins for the desired accounts from the config.yml file.

During development, in-place allows you to quickly reboot the chain from a multi-node network state to a node you have full control over.

**SEE ALSO**

* [ignite testnet in-place](#ignite-testnet-in-place) - Create and start a testnet from current local net state


## ignite testnet in-place

Create and start a testnet from current local net state

**Synopsis**

The "in-place" command is used to create and start a testnet from current local net state(including mainnet).

We can create a testnet from the local network state and mint additional coins for the desired accounts from the config.yml file.

During development, in-place allows you to quickly reboot the chain from a multi-node network state to a node you have full control over.

By default, the data directory will be initialized in $HOME/.mychain, where "mychain" is the name of the project. To set a custom data directory use the --home flag or set the value in config.yml:

validators:
- name: alice
bonded: '100000000stake'
home: "~/.customdir"

Get mint coin just add account in config.yml file:

accounts:
- name: charlie
coins:
- 20000token
- 200000000stake


```
ignite chain debug [flags]
```

**Options**

```
-h, --help help for debug
-p, --path string path of the app (default ".")
```

**Options inherited from parent commands**

```
-c, --config string path to Ignite config file (default: ./config.yml)
```

**SEE ALSO**

* [ignite](#ignite) - Ignite CLI offers everything you need to scaffold, test, build, start testnet and launch your blockchain
1 change: 1 addition & 0 deletions ignite/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
NewApp(),
NewDoctor(),
NewCompletionCmd(),
NewTestnet(),

Check warning on line 92 in ignite/cmd/cmd.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/cmd.go#L92

Added line #L92 was not covered by tests
)
c.AddCommand(deprecated()...)
c.SetContext(ctx)
Expand Down
24 changes: 24 additions & 0 deletions ignite/cmd/testnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ignitecmd

import (
"github.com/spf13/cobra"
)

// NewTestnet returns a command that groups scaffolding related sub commands.
func NewTestnet() *cobra.Command {
c := &cobra.Command{
Use: "testnet [command]",
Short: "Start a testnet local",
Long: `Start a testnet local

Check warning on line 12 in ignite/cmd/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet.go#L8-L12

Added lines #L8 - L12 were not covered by tests

`,
Aliases: []string{"s"},
Args: cobra.ExactArgs(1),

Check warning on line 16 in ignite/cmd/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet.go#L14-L16

Added lines #L14 - L16 were not covered by tests
}

c.AddCommand(
NewTestnetInPlace(),
)

Check warning on line 21 in ignite/cmd/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet.go#L19-L21

Added lines #L19 - L21 were not covered by tests

return c

Check warning on line 23 in ignite/cmd/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet.go#L23

Added line #L23 was not covered by tests
}
128 changes: 128 additions & 0 deletions ignite/cmd/testnet_inplace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package ignitecmd

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/ignite/cli/v29/ignite/pkg/cliui"
likesToEatFish marked this conversation as resolved.
Show resolved Hide resolved
"github.com/ignite/cli/v29/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/chain"
"github.com/spf13/cobra"
)

func NewTestnetInPlace() *cobra.Command {
c := &cobra.Command{
Use: "in-place",
Short: "Create and start a testnet from current local net state",
Long: `Testnet in-place command is used to create and start a testnet from current local net state(including mainnet).
After using this command in the repo containing the config.yml file, the network will start.
We can create a testnet from the local network state and mint additional coins for the desired accounts from the config.yml file.`,
Args: cobra.NoArgs,
RunE: testnetInPlaceHandler,

Check warning on line 21 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L13-L21

Added lines #L13 - L21 were not covered by tests
}
flagSetPath(c)
flagSetClearCache(c)
c.Flags().AddFlagSet(flagSetHome())
c.Flags().AddFlagSet(flagSetCheckDependencies())
c.Flags().AddFlagSet(flagSetSkipProto())
c.Flags().AddFlagSet(flagSetVerbose())

Check warning on line 28 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L23-L28

Added lines #L23 - L28 were not covered by tests

c.Flags().Bool(flagQuitOnFail, false, "quit program if the app fails to start")
return c

Check warning on line 31 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L30-L31

Added lines #L30 - L31 were not covered by tests
}

func testnetInPlaceHandler(cmd *cobra.Command, _ []string) error {
session := cliui.New(
cliui.WithVerbosity(getVerbosity(cmd)),
)
defer session.End()

Check warning on line 38 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L34-L38

Added lines #L34 - L38 were not covered by tests

// Otherwise run the serve command directly
return testnetInplace(cmd, session)

Check warning on line 41 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L41

Added line #L41 was not covered by tests
}

func testnetInplace(cmd *cobra.Command, session *cliui.Session) error {
chainOption := []chain.Option{
chain.WithOutputer(session),
chain.CollectEvents(session.EventBus()),
chain.CheckCosmosSDKVersion(),

Check warning on line 48 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L44-L48

Added lines #L44 - L48 were not covered by tests
}

if flagGetCheckDependencies(cmd) {
chainOption = append(chainOption, chain.CheckDependencies())

Check warning on line 52 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L51-L52

Added lines #L51 - L52 were not covered by tests
}

// check if custom config is defined
config, _ := cmd.Flags().GetString(flagConfig)
if config != "" {
chainOption = append(chainOption, chain.ConfigFile(config))

Check warning on line 58 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L56-L58

Added lines #L56 - L58 were not covered by tests
}

c, err := chain.NewWithHomeFlags(cmd, chainOption...)
if err != nil {
return err

Check warning on line 63 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L61-L63

Added lines #L61 - L63 were not covered by tests
}

cfg, err := c.Config()
if err != nil {
return err

Check warning on line 68 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L66-L68

Added lines #L66 - L68 were not covered by tests
}
home, err := c.Home()
if err != nil {
return err

Check warning on line 72 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L70-L72

Added lines #L70 - L72 were not covered by tests
}
keyringBackend, err := c.KeyringBackend()
if err != nil {
return err

Check warning on line 76 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L74-L76

Added lines #L74 - L76 were not covered by tests
}
ca, err := cosmosaccount.New(
cosmosaccount.WithKeyringBackend(cosmosaccount.KeyringBackend(keyringBackend)),
cosmosaccount.WithHome(home),
)
if err != nil {
return err

Check warning on line 83 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L78-L83

Added lines #L78 - L83 were not covered by tests
}

var (
operatorAddress sdk.ValAddress
accounts string
accErr *cosmosaccount.AccountDoesNotExistError
)
for _, acc := range cfg.Accounts {
sdkAcc, err := ca.GetByName(acc.Name)
if errors.As(err, &accErr) {
sdkAcc, _, err = ca.Create(acc.Name)

Check warning on line 94 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L86-L94

Added lines #L86 - L94 were not covered by tests
}
if err != nil {
return err

Check warning on line 97 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L96-L97

Added lines #L96 - L97 were not covered by tests
}

sdkAddr, err := sdkAcc.Address(getAddressPrefix(cmd))
if err != nil {
return err

Check warning on line 102 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L100-L102

Added lines #L100 - L102 were not covered by tests
}
if len(cfg.Validators) == 0 {
return errors.Errorf("no validators found for account %s", sdkAcc.Name)

Check warning on line 105 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L104-L105

Added lines #L104 - L105 were not covered by tests
}
if cfg.Validators[0].Name == acc.Name {
accAddr, err := sdk.AccAddressFromBech32(sdkAddr)
if err != nil {
return err

Check warning on line 110 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L107-L110

Added lines #L107 - L110 were not covered by tests
}
operatorAddress = sdk.ValAddress(accAddr)

Check warning on line 112 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L112

Added line #L112 was not covered by tests
}
accounts = accounts + "," + sdkAddr

Check warning on line 114 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L114

Added line #L114 was not covered by tests
}

chainID, err := c.ID()
if err != nil {
return err

Check warning on line 119 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L117-L119

Added lines #L117 - L119 were not covered by tests
}

args := chain.InPlaceArgs{
NewChainID: chainID,
NewOperatorAddress: operatorAddress.String(),
AccountsToFund: accounts,

Check warning on line 125 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L122-L125

Added lines #L122 - L125 were not covered by tests
}
return c.TestnetInPlace(cmd.Context(), args)

Check warning on line 127 in ignite/cmd/testnet_inplace.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/testnet_inplace.go#L127

Added line #L127 was not covered by tests
}
4 changes: 4 additions & 0 deletions ignite/pkg/chaincmd/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
commandUnsafeReset = "unsafe-reset-all"
commandExport = "export"
commandTendermint = "tendermint"
commandTestnetInPlace = "in-place-testnet"

optionHome = "--home"
optionNode = "--node"
Expand Down Expand Up @@ -55,6 +56,9 @@ const (
optionBroadcastMode = "--broadcast-mode"
optionAccount = "--account"
optionIndex = "--index"
optionValidatorPrivateKey = "--validator-privkey"
optionAccountToFund = "--accounts-to-fund"
optionSkipConfirmation = "--skip-confirmation"

constTendermint = "tendermint"
constJSON = "json"
Expand Down
47 changes: 47 additions & 0 deletions ignite/pkg/chaincmd/in-place-testnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package chaincmd
likesToEatFish marked this conversation as resolved.
Show resolved Hide resolved

import (
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
)

type InPlaceOption func([]string) []string

func InPlaceWithPrvKey(prvKey string) InPlaceOption {
return func(s []string) []string {
if len(prvKey) > 0 {
return append(s, optionValidatorPrivateKey, prvKey)

Check warning on line 12 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L9-L12

Added lines #L9 - L12 were not covered by tests
}
return s

Check warning on line 14 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L14

Added line #L14 was not covered by tests
}
}

func InPlaceWithAccountToFund(accounts string) InPlaceOption {
return func(s []string) []string {
if len(accounts) > 0 {
return append(s, optionAccountToFund, accounts)

Check warning on line 21 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L18-L21

Added lines #L18 - L21 were not covered by tests
}
return s

Check warning on line 23 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L23

Added line #L23 was not covered by tests
}
}

func InPlaceWithSkipConfirmation() InPlaceOption {
return func(s []string) []string {
return append(s, optionSkipConfirmation)

Check warning on line 29 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L27-L29

Added lines #L27 - L29 were not covered by tests
}
}

// TestnetInPlaceCommand return command to start testnet in-place.
func (c ChainCmd) TestnetInPlaceCommand(newChainID, newOperatorAddress string, options ...InPlaceOption) step.Option {
command := []string{
commandTestnetInPlace,
newChainID,
newOperatorAddress,

Check warning on line 38 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L34-L38

Added lines #L34 - L38 were not covered by tests
}

// Apply the options provided by the user
for _, apply := range options {
command = apply(command)

Check warning on line 43 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L42-L43

Added lines #L42 - L43 were not covered by tests
}

return c.daemonCommand(command)

Check warning on line 46 in ignite/pkg/chaincmd/in-place-testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/in-place-testnet.go#L46

Added line #L46 was not covered by tests
}
12 changes: 12 additions & 0 deletions ignite/pkg/chaincmd/runner/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@

var gentxRe = regexp.MustCompile(`(?m)"(.+?)"`)

func (r Runner) InPlace(ctx context.Context, newChainID, newOperatorAddress string, options ...chaincmd.InPlaceOption) error {
runOptions := runOptions{
stdout: os.Stdout,
stderr: os.Stderr,

Check warning on line 51 in ignite/pkg/chaincmd/runner/chain.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/runner/chain.go#L48-L51

Added lines #L48 - L51 were not covered by tests
}
return r.run(
ctx,
runOptions,
r.chainCmd.TestnetInPlaceCommand(newChainID, newOperatorAddress, options...),
)

Check warning on line 57 in ignite/pkg/chaincmd/runner/chain.go

View check run for this annotation

Codecov / codecov/patch

ignite/pkg/chaincmd/runner/chain.go#L53-L57

Added lines #L53 - L57 were not covered by tests
}

// Gentx generates a genesis tx carrying a self delegation.
func (r Runner) Gentx(
ctx context.Context,
Expand Down
11 changes: 11 additions & 0 deletions ignite/services/chain/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
)
}

func (c Chain) InPlace(ctx context.Context, runner chaincmdrunner.Runner, args InPlaceArgs) error {
err := runner.InPlace(ctx,
args.NewChainID,
args.NewOperatorAddress,
chaincmd.InPlaceWithPrvKey(args.PrvKeyValidator),
chaincmd.InPlaceWithAccountToFund(args.AccountsToFund),
chaincmd.InPlaceWithSkipConfirmation(),
)
return err

Check warning on line 48 in ignite/services/chain/runtime.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/runtime.go#L40-L48

Added lines #L40 - L48 were not covered by tests
}

// Start wraps the "appd start" command to begin running a chain from the daemon.
func (c Chain) Start(ctx context.Context, runner chaincmdrunner.Runner, cfg *chainconfig.Config) error {
validator, err := chainconfig.FirstValidator(cfg)
Expand Down
36 changes: 36 additions & 0 deletions ignite/services/chain/testnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package chain

import (
"context"
chainconfig "github.com/ignite/cli/v29/ignite/config/chain"
"os"
)

type InPlaceArgs struct {
NewChainID string
NewOperatorAddress string
PrvKeyValidator string
AccountsToFund string
}

func (c Chain) TestnetInPlace(ctx context.Context, args InPlaceArgs) error {
commands, err := c.Commands(ctx)
if err != nil {
return err

Check warning on line 19 in ignite/services/chain/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/testnet.go#L16-L19

Added lines #L16 - L19 were not covered by tests
}

// make sure that config.yml exists
if c.options.ConfigFile != "" {
if _, err := os.Stat(c.options.ConfigFile); err != nil {
return err

Check warning on line 25 in ignite/services/chain/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/testnet.go#L23-L25

Added lines #L23 - L25 were not covered by tests
}
} else if _, err := chainconfig.LocateDefault(c.app.Path); err != nil {
return err

Check warning on line 28 in ignite/services/chain/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/testnet.go#L27-L28

Added lines #L27 - L28 were not covered by tests
}

err = c.InPlace(ctx, commands, args)
if err != nil {
return err

Check warning on line 33 in ignite/services/chain/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/testnet.go#L31-L33

Added lines #L31 - L33 were not covered by tests
}
return nil

Check warning on line 35 in ignite/services/chain/testnet.go

View check run for this annotation

Codecov / codecov/patch

ignite/services/chain/testnet.go#L35

Added line #L35 was not covered by tests
}
2 changes: 1 addition & 1 deletion ignite/templates/app/files/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,4 @@ func BlockedAddresses() map[string]bool {
}
}
return result
}
}
Loading
Loading