Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Oct 18, 2024
1 parent 084c150 commit 52ad370
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions erigon-lib/commitment/hex_patricia_hashed_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package commitment
import (
"bytes"
"context"
"encoding/binary"
"encoding/hex"
"math"
"math/rand"
Expand Down Expand Up @@ -80,32 +79,23 @@ func Fuzz_ProcessUpdate(f *testing.F) {
})
}

// go test -trimpath -v -fuzz=Fuzz_ProcessUpdates_ArbitraryUpdateCount -fuzztime=300s ./commitment
// go test -trimpath -v -fuzz=Fuzz_ProcessUpdates_ArbitraryUpdateCount2 -fuzztime=300s ./commitment

func Fuzz_ProcessUpdates_ArbitraryUpdateCount(f *testing.F) {
ha, _ := hex.DecodeString("0008852883b2850c7a48f4b0eea3ccc4c04e6cb6025e9e8f7db2589c7dae81517c514790cfd6f668903161349e")
func Fuzz_ProcessUpdates_ArbitraryUpdateCount2(f *testing.F) {
//ha, _ := hex.DecodeString("0008852883b2850c7a48f4b0eea3ccc4c04e6cb6025e9e8f7db2589c7dae81517c514790cfd6f668903161349e")
ctx := context.Background()
f.Add(ha)
f.Add(uint16(10_000), uint32(1), uint32(2))

f.Fuzz(func(t *testing.T, build []byte) {
if len(build) < 12 {
t.Skip()
}
i := 0
keysCount := binary.BigEndian.Uint32(build[i : i+4])
i += 4
ks := binary.BigEndian.Uint32(build[i : i+4])
f.Fuzz(func(t *testing.T, keysCount uint16, ks, us uint32) {
keysSeed := rand.New(rand.NewSource(int64(ks)))
i += 4
us := binary.BigEndian.Uint32(build[i : i+4])
updateSeed := rand.New(rand.NewSource(int64(us)))

t.Logf("fuzzing %d keys keysSeed=%d updateSeed=%d", keysCount, ks, us)

plainKeys := make([][]byte, keysCount)
updates := make([]Update, keysCount)

for k := uint32(0); k < keysCount; k++ {
for k := uint16(0); k < keysCount; k++ {

aux := make([]byte, 32)

Expand Down

0 comments on commit 52ad370

Please sign in to comment.