Skip to content
Merged
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
11 changes: 5 additions & 6 deletions cmd/util/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import (
"fmt"
"slices"
"strings"
)

Expand Down Expand Up @@ -49,12 +50,10 @@

// Set sets a value and fails if it is not allowed
func (c *CobraStringValue) Set(other string) error {
for _, s := range c.allowed {
if other == s {
c.value = other
c.isSet = true
return nil
}
if slices.Contains(c.allowed, other) {
c.value = other
c.isSet = true
return nil

Check warning on line 56 in cmd/util/cmd.go

View check run for this annotation

Codecov / codecov/patch

cmd/util/cmd.go#L53-L56

Added lines #L53 - L56 were not covered by tests
}
return fmt.Errorf("value %s not allowed", other)
}
Expand Down
17 changes: 3 additions & 14 deletions network/phonebook/phonebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package phonebook

import (
"slices"
"testing"
"time"

Expand All @@ -27,25 +28,13 @@ import (
func testPhonebookAll(t *testing.T, set []string, ph Phonebook) {
actual := ph.GetAddresses(len(set), RelayRole)
for _, got := range actual {
ok := false
for _, known := range set {
if got == known {
ok = true
break
}
}
ok := slices.Contains(set, got)
if !ok {
t.Errorf("get returned junk %#v", got)
}
}
for _, known := range set {
ok := false
for _, got := range actual {
if got == known {
ok = true
break
}
}
ok := slices.Contains(actual, known)
if !ok {
t.Errorf("get missed %#v; actual=%#v; set=%#v", known, actual, set)
}
Expand Down
Loading