Skip to content
Open
Changes from 1 commit
Commits
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
22 changes: 22 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ func initCommon(args []string) error {
return err
}

if err := validateRemoteNodeVsBlockChainNodeFlags(initOptions.RemoteNodeURL, initOptions.BlockchainNodeProvider); err != nil {
return err
}

if err := validateRemoteNodeDeployVsContractAddressFlags(initOptions.RemoteNodeDeploy, initOptions.ContractAddress); err != nil {
return err
}

fmt.Println("initializing new FireFly stack...")

if len(args) > 0 {
Expand Down Expand Up @@ -260,6 +268,20 @@ func validatePrivateTransactionManagerBlockchainConnectorCombination(privateTran
return nil
}

func validateRemoteNodeVsBlockChainNodeFlags(remoteNodeUrl, blockchainNodePorvider string) error {
if len(remoteNodeUrl) != 0 && blockchainNodePorvider != "geth" {
return errors.New("`remote-noted-url` and `blockchain-node` can't both be specified")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.New("`remote-noted-url` and `blockchain-node` can't both be specified")
return errors.New("Both flags `remote-node-url` and `blockchain-node` can't be specified")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @EnriqueL8, thanks for your review. I will correct the text and look for a place where to place the test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @EnriqueL8, now that I took a deeper look, I remembered why I didn't provide tests initially. I didn't find any of the initCommon behavior to have been tested. Can you please let me know if I'm mistaken, or if not - and still a test needs to be written for this part - where, according to the practices of this repo, shall it be?

Thanks in advance for your help.

@EnriqueL8 EnriqueL8 Nov 19, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay this might be more significant work to establish a test framework for these

}
return nil
}

func validateRemoteNodeDeployVsContractAddressFlags(remoteNodeDeploy bool, contractAddress string) error {
if remoteNodeDeploy && len(contractAddress) != 0 {
return errors.New("`contract-address` and `remote-node-deploy` can't both be specified")
}
return nil
}

func validateTokensProvider(input []string, blockchainNodeProviderInput string) error {
tokenProviders := make([]fftypes.FFEnum, len(input))
for i, t := range input {
Expand Down