prysm-pulse/encoding/ssz/htrutils_fuzz_test.go
Raul Jordan d077483577
Add V3 Suffix to All Prysm Packages (#11083)
* v3 import renamings

* tidy

* fmt

* rev

* Update beacon-chain/core/epoch/precompute/reward_penalty_test.go

* Update beacon-chain/core/helpers/validators_test.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/iface/BUILD.bazel

* Update beacon-chain/db/kv/kv.go

* Update beacon-chain/db/kv/state.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/sync/initial-sync/service.go

* fix deps

* fix bad replacements

* fix bad replacements

* change back

* gohashtree version

* fix deps

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
2022-08-16 12:20:13 +00:00

55 lines
1.1 KiB
Go

//go:build fuzz && go1.18
package ssz_test
import (
"testing"
"github.com/pkg/errors"
fssz "github.com/prysmaticlabs/fastssz"
"github.com/prysmaticlabs/prysm/v3/config/params"
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
pb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
)
func FuzzUint64Root(f *testing.F) {
f.Fuzz(func(t *testing.T, i uint64) {
_ = ssz.Uint64Root(i)
})
}
func FuzzForkRoot(f *testing.F) {
frk := &pb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().AltairForkVersion,
Epoch: 100,
}
example, err := frk.MarshalSSZ()
if err != nil {
f.Fatal(err)
}
f.Add(example)
f.Fuzz(func(t *testing.T, b []byte) {
frk := &pb.Fork{}
if err := frk.UnmarshalSSZ(b); err != nil {
if errors.Is(err, fssz.ErrSize) {
return
}
t.Fatal(err)
}
if _, err := ssz.ForkRoot(frk); err != nil {
t.Fatal(err)
}
})
}
func FuzzPackChunks(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
if _, err := ssz.PackByChunk([][]byte{b}); err != nil {
t.Fatal(err)
}
})
}