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
4 changes: 2 additions & 2 deletions agreement/credentialArrivalHistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package agreement

import (
"sort"
"slices"
"time"
)

Expand Down Expand Up @@ -78,6 +78,6 @@ func (history *credentialArrivalHistory) orderStatistics(idx int) time.Duration
// the linear time order statistics algorithm.
sortedArrivals := make([]time.Duration, len(history.history))
copy(sortedArrivals[:], history.history[:])
sort.Slice(sortedArrivals, func(i, j int) bool { return sortedArrivals[i] < sortedArrivals[j] })
slices.Sort(sortedArrivals)
return sortedArrivals[idx]
}
8 changes: 2 additions & 6 deletions agreement/state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"os"
"slices"
"strings"

"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -158,12 +159,7 @@ func (t ioTrace) CountEvent(b event) (count int) {

// for each event, passes it into the given fn; if returns true, returns true.
func (t ioTrace) ContainsFn(compareFn func(b event) bool) bool {
for _, ev := range t.events {
if compareFn(ev) {
return true
}
}
return false
return slices.ContainsFunc(t.events, compareFn)
}

func (t ioTrace) countAction() (count int) {
Expand Down
9 changes: 4 additions & 5 deletions data/basics/fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package basics_test

import (
"reflect"
"slices"
"testing"

"github.com/algorand/go-algorand/data/basics"
Expand All @@ -35,11 +36,9 @@ func makeTypeCheckFunction(t *testing.T, exceptions []reflectionhelpers.TypePath
return func(path reflectionhelpers.TypePath, stack []reflect.Type) bool {
currentType := stack[len(stack)-1]

for _, exception := range exceptions {
if path.Equals(exception) {
t.Logf("Skipping exception for path: %s", path)
return true
}
if slices.ContainsFunc(exceptions, path.Equals) {
t.Logf("Skipping exception for path: %s", path)
return true
}

switch currentType.Kind() {
Expand Down
8 changes: 2 additions & 6 deletions gen/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"os"
"path/filepath"
"slices"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -171,12 +172,7 @@ func TestGenesisJsonCreation(t *testing.T) {
deterministicAddresses := []string{"FeeSink", "RewardsPool"}

isNondeterministicAddress := func(name string) bool {
for _, address := range deterministicAddresses {
if name == address {
return false
}
}
return true
return !slices.Contains(deterministicAddresses, name)
}

for i := range as {
Expand Down
14 changes: 4 additions & 10 deletions ledger/simulation/simulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package simulation

import (
"reflect"
"slices"
"testing"

"github.com/algorand/go-algorand/crypto"
Expand Down Expand Up @@ -59,17 +60,10 @@ func TestNonOverridenDataLedgerMethodsUseRoundParameter(t *testing.T) {
}

methodIsSkipped := func(methodName string) bool {
for _, overridenMethod := range overridenMethods {
if overridenMethod == methodName {
return true
}
}
for _, excludedMethod := range excludedMethods {
if excludedMethod == methodName {
return true
}
if slices.Contains(overridenMethods, methodName) {
return true
}
return false
return slices.Contains(excludedMethods, methodName)
}

methodExistsInEvalLedger := func(methodName string) bool {
Expand Down
8 changes: 3 additions & 5 deletions network/wsNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -2392,11 +2392,9 @@ func (wn *WebsocketNetwork) addPeer(peer *wsPeer) {
}
// simple duplicate *pointer* check. should never trigger given the callers to addPeer
// TODO: remove this after making sure it is safe to do so
for _, p := range wn.peers {
if p == peer {
wn.log.Errorf("dup peer added %#v", peer)
return
}
if slices.Contains(wn.peers, peer) {
wn.log.Errorf("dup peer added %#v", peer)
return
}
heap.Push(peersHeap{wn}, peer)
wn.prioTracker.setPriority(peer, peer.prioAddress, peer.prioWeight)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e-go/features/catchup/catchpointCatchup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ func downloadCatchpointFile(t *testing.T, a *require.Assertions, baseURL string,
var chunks []ledger.CatchpointSnapshotChunkV6
for _, d := range tarData {
t.Logf("tar filename: %s, size %d", d.headerName, len(d.data))
if strings.HasPrefix(d.headerName, "balances.") { // chunk file
idxStr := strings.TrimSuffix(strings.TrimPrefix(d.headerName, "balances."), ".msgpack")
if after, ok := strings.CutPrefix(d.headerName, "balances."); ok { // chunk file
idxStr := strings.TrimSuffix(after, ".msgpack")
idx, err := strconv.Atoi(idxStr)
a.NoError(err)
var c ledger.CatchpointSnapshotChunkV6
Expand Down
Loading