Skip to content

Commit

Permalink
Merge branch 'master' into tmpnet-check-rpcchain-version
Browse files Browse the repository at this point in the history
  • Loading branch information
marun authored Aug 12, 2024
2 parents 0978d1c + b181671 commit f8d5078
Show file tree
Hide file tree
Showing 4 changed files with 593 additions and 180 deletions.
18 changes: 2 additions & 16 deletions snow/engine/snowman/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ava-labs/avalanchego/snow/engine/snowman/getter"
"github.com/ava-labs/avalanchego/snow/snowtest"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/version"
)
Expand Down Expand Up @@ -3078,7 +3079,7 @@ func TestShouldIssueBlock(t *testing.T) {
chain4Through6 = snowmantest.BuildDescendants(chain0Through3[0], 3)
chain7Through10 = snowmantest.BuildDescendants(snowmantest.Genesis, 4)
chain11Through11 = snowmantest.BuildDescendants(chain7Through10[1], 1)
blocks = join(chain0Through3, chain4Through6, chain7Through10, chain11Through11)
blocks = utils.Join(chain0Through3, chain4Through6, chain7Through10, chain11Through11)
)

require.NoError(t, blocks[0].Accept(context.Background()))
Expand Down Expand Up @@ -3181,18 +3182,3 @@ func TestShouldIssueBlock(t *testing.T) {
})
}
}

// join the provided slices into a single slice.
//
// TODO: Use slices.Concat once the minimum go version is 1.22.
func join[T any](slices ...[]T) []T {
size := 0
for _, s := range slices {
size += len(s)
}
newSlice := make([]T, 0, size)
for _, s := range slices {
newSlice = append(newSlice, s...)
}
return newSlice
}
19 changes: 19 additions & 0 deletions utils/slice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package utils

// Join merges the provided slices into a single slice.
//
// TODO: Use slices.Concat once the minimum go version is 1.22.
func Join[T any](slices ...[]T) []T {
size := 0
for _, s := range slices {
size += len(s)
}
newSlice := make([]T, 0, size)
for _, s := range slices {
newSlice = append(newSlice, s...)
}
return newSlice
}
Loading

0 comments on commit f8d5078

Please sign in to comment.