mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
* Migrate Prysm repo to Offchain Labs organization ahead of Pectra upgrade v6 * Replace prysmaticlabs with OffchainLabs on general markdowns * Update mock * Gazelle and add mock.go to excluded generated mock file
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package enginev1_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
enginev1 "github.com/OffchainLabs/prysm/v6/proto/engine/v1"
|
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
|
fuzz "github.com/google/gofuzz"
|
|
)
|
|
|
|
func TestCopyExecutionPayload_Fuzz(t *testing.T) {
|
|
fuzzCopies(t, &enginev1.ExecutionPayloadDeneb{})
|
|
fuzzCopies(t, &enginev1.ExecutionPayloadCapella{})
|
|
fuzzCopies(t, &enginev1.ExecutionPayload{})
|
|
}
|
|
|
|
func TestCopyExecutionPayloadHeader_Fuzz(t *testing.T) {
|
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeaderDeneb{})
|
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeaderCapella{})
|
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeader{})
|
|
}
|
|
|
|
func fuzzCopies[T any, C enginev1.Copier[T]](t *testing.T, obj C) {
|
|
fuzzer := fuzz.NewWithSeed(0)
|
|
amount := 1000
|
|
t.Run(fmt.Sprintf("%T", obj), func(t *testing.T) {
|
|
for i := 0; i < amount; i++ {
|
|
fuzzer.Fuzz(obj) // Populate thing with random values
|
|
got := obj.Copy()
|
|
require.DeepEqual(t, obj, got)
|
|
// check shallow copy working
|
|
fuzzer.Fuzz(got)
|
|
require.DeepNotEqual(t, obj, got)
|
|
// TODO: think of deeper not equal fuzzing
|
|
}
|
|
})
|
|
}
|