Skip to content

Commit

Permalink
Make the genesis path absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Apr 25, 2024
1 parent eb5a3a2 commit e1a5d32
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gno.land/cmd/gnoland/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (c *startCfg) RegisterFlags(fs *flag.FlagSet) {
&c.genesisFile,
"genesis",
"genesis.json",
"path to genesis file",
"the path to the genesis.json",
)

fs.StringVar(
Expand Down Expand Up @@ -208,6 +208,12 @@ func execStart(c *startCfg, io commands.IO) error {
return fmt.Errorf("unable to get absolute path for data directory, %w", err)
}

// Get the absolute path to the node's genesis.json
genesisPath, err := filepath.Abs(c.genesisFile)
if err != nil {
return fmt.Errorf("unable to get absolute path for the genesis.json, %w", err)

Check warning on line 214 in gno.land/cmd/gnoland/start.go

View check run for this annotation

Codecov / codecov/patch

gno.land/cmd/gnoland/start.go#L214

Added line #L214 was not covered by tests
}

var (
cfg *config.Config
loadCfgErr error
Expand Down Expand Up @@ -251,7 +257,7 @@ func execStart(c *startCfg, io commands.IO) error {
// Write genesis file if missing.
// NOTE: this will be dropped in a PR that resolves issue #1886:
// https://github.com/gnolang/gno/issues/1886
if !osm.FileExists(c.genesisFile) {
if !osm.FileExists(genesisPath) {
// Create priv validator first.
// Need it to generate genesis.json
newPrivValKey := cfg.PrivValidatorKeyFile()
Expand All @@ -260,7 +266,7 @@ func execStart(c *startCfg, io commands.IO) error {
pk := priv.GetPubKey()

// Generate genesis.json file
if err := generateGenesisFile(c.genesisFile, pk, c); err != nil {
if err := generateGenesisFile(genesisPath, pk, c); err != nil {
return fmt.Errorf("unable to generate genesis file: %w", err)
}
}
Expand All @@ -283,7 +289,7 @@ func execStart(c *startCfg, io commands.IO) error {
io.Println(startGraphic)
}

gnoNode, err := node.DefaultNewNode(cfg, c.genesisFile, logger)
gnoNode, err := node.DefaultNewNode(cfg, genesisPath, logger)
if err != nil {
return fmt.Errorf("error in creating node: %w", err)
}
Expand Down

0 comments on commit e1a5d32

Please sign in to comment.