Skip to content

Commit

Permalink
catch a fringe case where we parse in a core.ip, but also an empty co…
Browse files Browse the repository at this point in the history
…nfig with no defaults (likely never happen)
  • Loading branch information
ramin committed Jun 25, 2024
1 parent b1913a7 commit 4d39d57
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nodebuilder/core/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ func ParseFlags(
return nil
}

if cmd.Flag(coreRPCFlag).Changed {
// in the case that the RPC port is not set, use the default port
// or in the case a value has been set via flag,
// set that as highest precedence
if cfg.RPCPort == "" || cmd.Flag(coreRPCFlag).Changed {
rpc := cmd.Flag(coreRPCFlag).Value.String()
cfg.RPCPort = rpc
}
if cmd.Flag(coreGRPCFlag).Changed {
if cfg.GRPCPort == "" || cmd.Flag(coreGRPCFlag).Changed {
grpc := cmd.Flag(coreGRPCFlag).Value.String()
cfg.GRPCPort = grpc
}
Expand Down
11 changes: 11 additions & 0 deletions nodebuilder/core/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ func TestParseFlags(t *testing.T) {
},
expectError: false,
},
{
name: "only core.ip, empty port values",
args: []string{"--core.ip=127.0.0.1"},
inputCfg: Config{},
expectedCfg: Config{
IP: "127.0.0.1",
RPCPort: DefaultRPCPort,
GRPCPort: DefaultGRPCPort,
},
expectError: false,
},
{
name: "no flags, values from input config.toml ",
args: []string{},
Expand Down

0 comments on commit 4d39d57

Please sign in to comment.