diff --git a/internal/blockchain/ethereum/besu/besu_provider.go b/internal/blockchain/ethereum/besu/besu_provider.go index d4670dac..b82b1d07 100644 --- a/internal/blockchain/ethereum/besu/besu_provider.go +++ b/internal/blockchain/ethereum/besu/besu_provider.go @@ -148,9 +148,9 @@ func (p *BesuProvider) GetDockerServiceDefinitions() []*docker.ServiceDefinition addresses := "" for i, member := range p.stack.Members { account := member.Account.(*ethereum.Account) - addresses = addresses + account.Address + addresses += account.Address if i+1 < len(p.stack.Members) { - addresses = addresses + "," + addresses += "," } } besuCommand := fmt.Sprintf(`--genesis-file=/data/genesis.json --network-id %d --rpc-http-enabled --rpc-http-api=ETH,NET,CLIQUE --host-allowlist="*" --rpc-http-cors-origins="all" --sync-mode=FULL --discovery-enabled=false --node-private-key-file=/data/nodeKey --min-gas-price=0`, p.stack.ChainID()) diff --git a/internal/blockchain/ethereum/besu/genesis.go b/internal/blockchain/ethereum/besu/genesis.go index 9990cf89..9976ef20 100644 --- a/internal/blockchain/ethereum/besu/genesis.go +++ b/internal/blockchain/ethereum/besu/genesis.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "os" - "path/filepath" "strings" ) @@ -64,7 +63,7 @@ type Alloc struct { func (g *Genesis) WriteGenesisJson(filename string) error { genesisJsonBytes, _ := json.MarshalIndent(g, "", " ") - if err := os.WriteFile(filepath.Join(filename), genesisJsonBytes, 0755); err != nil { + if err := os.WriteFile(filename, genesisJsonBytes, 0755); err != nil { return err } return nil @@ -80,7 +79,7 @@ func CreateGenesis(addresses []string, blockPeriod int, chainID int64) *Genesis alloc[address] = &Alloc{ Balance: "0x200000000000000000000000000000000000000000000000000000000000000", } - extraData = extraData + address + extraData += extraData } extraData = strings.ReplaceAll(fmt.Sprintf("%-236s", extraData), " ", "0") return &Genesis{ diff --git a/internal/blockchain/ethereum/connector/ethconnect/config.go b/internal/blockchain/ethereum/connector/ethconnect/config.go index 1276c82c..b95aaadf 100644 --- a/internal/blockchain/ethereum/connector/ethconnect/config.go +++ b/internal/blockchain/ethereum/connector/ethconnect/config.go @@ -19,7 +19,6 @@ package ethconnect import ( "fmt" "os" - "path/filepath" "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector" "github.com/hyperledger/firefly-cli/pkg/types" @@ -59,7 +58,7 @@ type HTTP struct { func (e *Config) WriteConfig(filename string, extraConnectorConfigPath string) error { configYamlBytes, _ := yaml.Marshal(e) - if err := os.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil { + if err := os.WriteFile(filename, configYamlBytes, 0755); err != nil { return err } if extraConnectorConfigPath != "" { diff --git a/internal/blockchain/ethereum/connector/evmconnect/config.go b/internal/blockchain/ethereum/connector/evmconnect/config.go index 48ed4887..2cf25c67 100644 --- a/internal/blockchain/ethereum/connector/evmconnect/config.go +++ b/internal/blockchain/ethereum/connector/evmconnect/config.go @@ -19,7 +19,6 @@ package evmconnect import ( "fmt" "os" - "path/filepath" "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector" "github.com/hyperledger/firefly-cli/pkg/types" @@ -76,7 +75,7 @@ type GasOracleConfig struct { func (e *Config) WriteConfig(filename string, extraEvmconnectConfigPath string) error { configYamlBytes, _ := yaml.Marshal(e) - if err := os.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil { + if err := os.WriteFile(filename, configYamlBytes, 0755); err != nil { return err } if extraEvmconnectConfigPath != "" { diff --git a/internal/blockchain/ethereum/ethsigner/config.go b/internal/blockchain/ethereum/ethsigner/config.go index 9a8de2d4..1980cbee 100644 --- a/internal/blockchain/ethereum/ethsigner/config.go +++ b/internal/blockchain/ethereum/ethsigner/config.go @@ -18,7 +18,6 @@ package ethsigner import ( "os" - "path/filepath" "gopkg.in/yaml.v2" ) @@ -65,7 +64,7 @@ type Config struct { func (e *Config) WriteConfig(filename string) error { configYamlBytes, _ := yaml.Marshal(e) - return os.WriteFile(filepath.Join(filename), configYamlBytes, 0755) + return os.WriteFile(filename, configYamlBytes, 0755) } func GenerateSignerConfig(chainID int64, rpcURL string) *Config { diff --git a/internal/blockchain/ethereum/geth/genesis.go b/internal/blockchain/ethereum/geth/genesis.go index c3413a6b..3e5efaa8 100644 --- a/internal/blockchain/ethereum/geth/genesis.go +++ b/internal/blockchain/ethereum/geth/genesis.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "os" - "path/filepath" "strings" ) @@ -72,7 +71,7 @@ func CreateGenesis(addresses []string, blockPeriod int, chainID int64) *Genesis alloc[address] = &Alloc{ Balance: "0x200000000000000000000000000000000000000000000000000000000000000", } - extraData = extraData + address + extraData += address } extraData = strings.ReplaceAll(fmt.Sprintf("%-236s", extraData), " ", "0") @@ -108,7 +107,7 @@ func CreateGenesis(addresses []string, blockPeriod int, chainID int64) *Genesis func (g *Genesis) WriteGenesisJson(filename string) error { genesisJsonBytes, _ := json.MarshalIndent(g, "", " ") - if err := os.WriteFile(filepath.Join(filename), genesisJsonBytes, 0755); err != nil { + if err := os.WriteFile(filename, genesisJsonBytes, 0755); err != nil { return err } return nil diff --git a/internal/blockchain/tezos/connector/tezosconnect/config.go b/internal/blockchain/tezos/connector/tezosconnect/config.go index e1ae7762..37effdde 100644 --- a/internal/blockchain/tezos/connector/tezosconnect/config.go +++ b/internal/blockchain/tezos/connector/tezosconnect/config.go @@ -19,7 +19,6 @@ package tezosconnect import ( "fmt" "os" - "path/filepath" "strings" "github.com/hyperledger/firefly-cli/internal/blockchain/tezos/connector" @@ -73,7 +72,7 @@ type ConfirmationsConfig struct { func (c *Config) WriteConfig(filename string, extraTezosconnectConfigPath string) error { configYamlBytes, _ := yaml.Marshal(c) - if err := os.WriteFile(filepath.Join(filename), configYamlBytes, 0755); err != nil { + if err := os.WriteFile(filename, configYamlBytes, 0755); err != nil { return err } if extraTezosconnectConfigPath != "" { diff --git a/internal/blockchain/tezos/tezossigner/config.go b/internal/blockchain/tezos/tezossigner/config.go index a3f3bcc5..1c482bd6 100644 --- a/internal/blockchain/tezos/tezossigner/config.go +++ b/internal/blockchain/tezos/tezossigner/config.go @@ -18,7 +18,6 @@ package tezossigner import ( "os" - "path/filepath" "gopkg.in/yaml.v2" ) @@ -61,7 +60,7 @@ type AllowedTransactionsConfig struct { func (c *Config) WriteConfig(filename string) error { configYamlBytes, _ := yaml.Marshal(c) - return os.WriteFile(filepath.Join(filename), configYamlBytes, 0755) + return os.WriteFile(filename, configYamlBytes, 0755) } func GenerateSignerConfig(accountsAddresses []string) *Config { diff --git a/internal/core/manifest_test.go b/internal/core/manifest_test.go index 42424c7a..c2c8b119 100644 --- a/internal/core/manifest_test.go +++ b/internal/core/manifest_test.go @@ -23,26 +23,26 @@ import ( "github.com/stretchr/testify/assert" ) -func TestGetFireFlyManifest(T *testing.T) { +func TestGetFireFlyManifest(t *testing.T) { manifest, err := GetManifestForRelease("main") - assert.NoError(T, err) - assert.NotNil(T, manifest) - assert.NotNil(T, manifest.FireFly) - assert.NotNil(T, manifest.Ethconnect) - assert.NotNil(T, manifest.Fabconnect) - assert.NotNil(T, manifest.DataExchange) - assert.NotNil(T, manifest.TokensERC1155) - assert.NotNil(T, manifest.TokensERC20ERC721) + assert.NoError(t, err) + assert.NotNil(t, manifest) + assert.NotNil(t, manifest.FireFly) + assert.NotNil(t, manifest.Ethconnect) + assert.NotNil(t, manifest.Fabconnect) + assert.NotNil(t, manifest.DataExchange) + assert.NotNil(t, manifest.TokensERC1155) + assert.NotNil(t, manifest.TokensERC20ERC721) } -func TestGetLatestReleaseManifest(T *testing.T) { +func TestGetLatestReleaseManifest(t *testing.T) { manifest, err := GetManifestForChannel(types.ReleaseChannelStable) - assert.NoError(T, err) - assert.NotNil(T, manifest) - assert.NotNil(T, manifest.FireFly) - assert.NotNil(T, manifest.Ethconnect) - assert.NotNil(T, manifest.Fabconnect) - assert.NotNil(T, manifest.DataExchange) - assert.NotNil(T, manifest.TokensERC1155) - assert.NotNil(T, manifest.TokensERC20ERC721) + assert.NoError(t, err) + assert.NotNil(t, manifest) + assert.NotNil(t, manifest.FireFly) + assert.NotNil(t, manifest.Ethconnect) + assert.NotNil(t, manifest.Fabconnect) + assert.NotNil(t, manifest.DataExchange) + assert.NotNil(t, manifest.TokensERC1155) + assert.NotNil(t, manifest.TokensERC20ERC721) } diff --git a/internal/docker/docker.go b/internal/docker/docker.go index d95a17ef..0b67b0c0 100644 --- a/internal/docker/docker.go +++ b/internal/docker/docker.go @@ -101,7 +101,7 @@ func RunDockerComposeCommand(ctx context.Context, workingDir string, command ... _, err := runCommand(ctx, dockerCmd) return err default: - return fmt.Errorf("No version for docker-compose has been detected.") + return fmt.Errorf("no version for docker-compose has been detected") } } diff --git a/internal/stacks/stack_manager.go b/internal/stacks/stack_manager.go index 74791125..ccefa6ce 100644 --- a/internal/stacks/stack_manager.go +++ b/internal/stacks/stack_manager.go @@ -379,7 +379,7 @@ func (s *StackManager) writeStackStateJSON(directory string) error { func (s *StackManager) ensureInitDirectories() error { configDir := filepath.Join(s.Stack.InitDir, "config") - if err := os.MkdirAll(filepath.Join(configDir), 0755); err != nil { + if err := os.MkdirAll(configDir, 0755); err != nil { return err } @@ -566,7 +566,6 @@ func (s *StackManager) createMember(id string, index int, options *types.InitOpt if options.SandboxEnabled { member.ExposedSandboxPort = nextPort - nextPort++ } return member, nil } @@ -1057,39 +1056,39 @@ func replaceVersions(oldManifest, newManifest *types.VersionManifest, filename s old := oldManifest.FireFly.GetDockerImageString() new := newManifest.FireFly.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.Ethconnect.GetDockerImageString() new = newManifest.Ethconnect.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.Evmconnect.GetDockerImageString() new = newManifest.Evmconnect.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.Tezosconnect.GetDockerImageString() new = newManifest.Tezosconnect.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.Fabconnect.GetDockerImageString() new = newManifest.Fabconnect.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.DataExchange.GetDockerImageString() new = newManifest.DataExchange.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.TokensERC1155.GetDockerImageString() new = newManifest.TokensERC1155.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.TokensERC20ERC721.GetDockerImageString() new = newManifest.TokensERC20ERC721.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) old = oldManifest.Signer.GetDockerImageString() new = newManifest.Signer.GetDockerImageString() - s = strings.Replace(s, old, new, -1) + s = strings.ReplaceAll(s, old, new) return os.WriteFile(filename, []byte(s), 0755) }