Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 2 additions & 7 deletions pkg/docker/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -283,12 +284,6 @@ func HasRemoteComposeService(host *models.Host, composeFile string, service stri
if err != nil {
return false, err
}
found := false
for _, s := range services {
if s == service {
found = true
break
}
}
found := slices.Contains(services, service)
return found, nil
}
7 changes: 3 additions & 4 deletions pkg/docker/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"

"github.com/ava-labs/avalanche-cli/pkg/constants"
Expand All @@ -28,10 +29,8 @@ func DockerLocalImageExists(host *models.Host, image string) (bool, error) {
if err != nil {
return false, err
}
for _, localImage := range parseDockerImageListOutput(output) {
if localImage == image {
return true, nil
}
if slices.Contains(parseDockerImageListOutput(output), image) {
return true, nil
}
return false, nil
}
Expand Down
8 changes: 1 addition & 7 deletions pkg/prompts/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,7 @@ func CheckSubnetAuthKeys(walletKeys []string, subnetAuthKeys []string, controlKe
return fmt.Errorf("number of given auth keys differs from the threshold")
}
for _, subnetAuthKey := range subnetAuthKeys {
found := false
for _, controlKey := range controlKeys {
if subnetAuthKey == controlKey {
found = true
break
}
}
found := slices.Contains(controlKeys, subnetAuthKey)
if !found {
return fmt.Errorf("auth key %s does not belong to control keys", subnetAuthKey)
}
Expand Down
15 changes: 3 additions & 12 deletions pkg/prompts/prompts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"testing"

"github.com/ava-labs/avalanche-cli/pkg/key"
Expand Down Expand Up @@ -669,12 +670,7 @@ func TestPromptChain(t *testing.T) {
mockPrompt := &mocks.Prompter{}
mockPrompt.On("CaptureListWithSize", prompt, mock.MatchedBy(func(options []string) bool {
// Should contain "Custom" option
for _, opt := range options {
if opt == Custom {
return true
}
}
return false
return slices.Contains(options, Custom)
}), 11).Return(Custom, nil).Once()
mockPrompt.On("CaptureString", "Blockchain ID/Alias").Return("custom-blockchain-id", nil).Once()
notListed, pChain, xChain, cChain, subnetName, blockchainID, err := PromptChain(
Expand All @@ -693,12 +689,7 @@ func TestPromptChain(t *testing.T) {
mockPrompt := &mocks.Prompter{}
mockPrompt.On("CaptureListWithSize", prompt, mock.MatchedBy(func(options []string) bool {
// Should contain "My blockchain isn't listed" option
for _, opt := range options {
if opt == "My blockchain isn't listed" {
return true
}
}
return false
return slices.Contains(options, "My blockchain isn't listed")
}), 11).Return("My blockchain isn't listed", nil).Once()
notListed, pChain, xChain, cChain, subnetName, blockchainID, err := PromptChain(
mockPrompt, prompt, subnetNames, true, true, true, avoidBlockchainName, false)
Expand Down
9 changes: 2 additions & 7 deletions pkg/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os/exec"
"os/user"
"regexp"
"slices"
"strconv"
"strings"
"syscall"
Expand All @@ -32,7 +33,6 @@ import (
"github.com/ava-labs/subnet-evm/core"

"github.com/aws/aws-sdk-go-v2/service/ec2/types"
"golang.org/x/exp/slices"
"golang.org/x/mod/semver"
)

Expand Down Expand Up @@ -88,12 +88,7 @@ func GetRealFilePath(path string) string {
}

func Any[T any](input []T, f func(T) bool) bool {
for _, e := range input {
if f(e) {
return true
}
}
return false
return slices.ContainsFunc(input, f)
}

func Find[T any](input []T, f func(T) bool) *T {
Expand Down
9 changes: 2 additions & 7 deletions pkg/vm/precompiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package vm

import (
"slices"
"testing"

"github.com/ava-labs/avalanche-cli/internal/testutils"
Expand Down Expand Up @@ -173,13 +174,7 @@ func TestAddAddressToAllowed(t *testing.T) {
// Check if the address was added to enabled list when expected
if tt.shouldAddToEnabled {
expectedAddress := common.HexToAddress(tt.addressToAdd)
found := false
for _, addr := range result.EnabledAddresses {
if addr == expectedAddress {
found = true
break
}
}
found := slices.Contains(result.EnabledAddresses, expectedAddress)
require.True(t, found, "Address should have been added to enabled list")
}

Expand Down