Skip to content

Commit

Permalink
fix: corrections in reading config from file
Browse files Browse the repository at this point in the history
  • Loading branch information
riyasng12 committed Jan 8, 2024
1 parent 0016146 commit 276d244
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
7 changes: 6 additions & 1 deletion cli/cmd/chains/kusama/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func RunKusama(cli *common.Cli) (*common.DiveMultipleServiceResponse, error) {
}

result := &common.DiveMultipleServiceResponse{}
if noRelay {

if serviceConfig.RelayChain.Name == "" {
result, err = startParaChains(cli, enclaveContext, serviceConfig, encodedServiceConfigDataString, "")
if err != nil {
return nil, err
Expand Down Expand Up @@ -257,6 +258,10 @@ func configureService(serviceConfig *utils.PolkadotServiceConfig) error {
serviceConfig.RelayChain = utils.RelayChainConfig{}
}

if serviceConfig.ChainType == localChain && serviceConfig.RelayChain.Name == "" && len(serviceConfig.Para) != 0 {
return common.WrapMessageToError(common.ErrEmptyFields, "Cannot start a Parachain in local without Relay Chain")
}

return nil
}

Expand Down
24 changes: 12 additions & 12 deletions cli/cmd/chains/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,17 @@ func (psc *PolkadotServiceConfig) IsEmpty() error {
return common.WrapMessageToError(common.ErrEmptyFields, "Missing Fields In PolkadotServiceConfig")
}

if psc.Explorer != true && psc.Explorer != false {
return common.WrapMessageToError(common.ErrEmptyFields, "Missing Fields In PolkadotServiceConfig")
}

if err := psc.RelayChain.IsEmpty(); err != nil {
return err
}

for _, para := range psc.Para {
if err := para.IsEmpty(); err != nil {
return err
if len(psc.Para) == 0 {
return nil
} else {
for _, para := range psc.Para {
if err := para.IsEmpty(); err != nil {
return err
}
}
}

Expand All @@ -251,7 +251,11 @@ func (psc *PolkadotServiceConfig) IsEmpty() error {

func (rcc *RelayChainConfig) IsEmpty() error {

if rcc == nil || rcc.Name == "" || len(rcc.Nodes) == 0 {
if rcc.Name == "" && len(rcc.Nodes) == 0 {
return nil
}

if rcc.Name == "" || len(rcc.Nodes) == 0 {
return common.WrapMessageToError(common.ErrEmptyFields, "Missing Fields In RelayChainConfig")
}

Expand Down Expand Up @@ -285,9 +289,5 @@ func (nc *NodeConfig) IsEmpty() error {
return common.WrapMessageToError(common.ErrEmptyFields, "Missing Fields In NodeConfig")
}

if nc.Prometheus != true && nc.Prometheus != false {
return common.WrapMessageToError(common.ErrEmptyFields, "Missing Fields In PolkadotServiceConfig")
}

return nil
}

0 comments on commit 276d244

Please sign in to comment.