Skip to content

Commit

Permalink
Require configs and chains in ICTEST_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Jul 29, 2023
1 parent 51530bb commit eff98a1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion local-interchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Follow [this guide](./docs/WINDOWS.md) to setup the Windows OS environment for i
- *(optional)* Edit `./configs/relayer.json`
- Copy: `cp ./configs/base_ibc.json ./configs/mytest1_ignored.json`
- Run: `local-ic start mytest1_ignored.json`
- Change directory `ICTEST_HOME=/root/example/local-interchain local-ic start myother_ignored.json`
- Run in different directory: `ICTEST_HOME=/root/local-interchain local-ic start myother_ignored.json`

**NOTE** The ICTEST_HOME path must contain the directories `chains` and `configs` to be valid.

*(Default: `make install` links to the cloned directory. `go install .` will use your home directory /local-interchain)*

Expand Down
16 changes: 15 additions & 1 deletion local-interchain/cmd/local-ic/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"os"
"path"
Expand Down Expand Up @@ -29,7 +30,6 @@ func GetDirectory() string {
// Config variable override for the ICTEST_HOME
if res := os.Getenv("ICTEST_HOME"); res != "" {
MakeFileInstallDirectory = res
return res
}

if MakeFileInstallDirectory == "" {
Expand All @@ -41,5 +41,19 @@ func GetDirectory() string {
MakeFileInstallDirectory = path.Join(dirname, "local-interchain")
}

if err := directoryRequirementChecks(MakeFileInstallDirectory, "configs", "chains"); err != nil {
log.Fatal(err)
}

return MakeFileInstallDirectory
}

func directoryRequirementChecks(parent string, subDirectories ...string) error {
for _, subDirectory := range subDirectories {
if _, err := os.Stat(path.Join(parent, subDirectory)); os.IsNotExist(err) {
return fmt.Errorf("%s/ folder not found in %s", subDirectory, parent)
}
}

return nil
}
3 changes: 0 additions & 3 deletions local-interchain/cmd/local-ic/start_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ var startCmd = &cobra.Command{
configPath := args[0]
parentDir := GetDirectory()

// base.json
// /abs/path/here/base.json

if path.IsAbs(configPath) {
dir, err := filepath.Abs(configPath)
if err != nil {
Expand Down

0 comments on commit eff98a1

Please sign in to comment.