Skip to content

Commit

Permalink
using fuzz test in same package to avoid exporting interface
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm committed Jul 19, 2024
1 parent 704bee6 commit 686f2e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions proto/engine/v1/execution_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package enginev1

import "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"

type Copier[T any] interface {
type copier[T any] interface {
Copy() T
}

func copySlice[T any, C Copier[T]](original []C) []T {
func copySlice[T any, C copier[T]](original []C) []T {
// Create a new slice with the same length as the original
newSlice := make([]T, len(original))
for i := 0; i < len(newSlice); i++ {
Expand Down
7 changes: 3 additions & 4 deletions proto/engine/v1/execution_engine_fuzz_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package enginev1_test
package enginev1

import (
"fmt"
"testing"

fuzz "github.com/google/gofuzz"
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
"github.com/prysmaticlabs/prysm/v5/testing/require"
)

func TestCopyExecutionPayload_Fuzz(t *testing.T) {
fuzzCopies(t, &enginev1.ExecutionPayloadElectra{})
fuzzCopies(t, &ExecutionPayloadElectra{})
}

func fuzzCopies[T any, C enginev1.Copier[T]](t *testing.T, obj C) {
func fuzzCopies[T any, C copier[T]](t *testing.T, obj C) {
fuzzer := fuzz.NewWithSeed(0)
amount := 1000
t.Run(fmt.Sprintf("%T", obj), func(t *testing.T) {
Expand Down

0 comments on commit 686f2e0

Please sign in to comment.