github.com/ledgerwatch/erigon-lib@v1.0.0/state/aggregator_fuzz_test.go (about)

     1  //go:build !nofuzz
     2  
     3  package state
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Fuzz_BtreeIndex_Allocation(f *testing.F) {
    12  	f.Add(uint64(1_000_000), uint64(1024))
    13  	f.Fuzz(func(t *testing.T, keyCount, M uint64) {
    14  		if keyCount < M*4 || M < 4 {
    15  			t.Skip()
    16  		}
    17  		bt := newBtAlloc(keyCount, M, false)
    18  		bt.traverseDfs()
    19  		require.GreaterOrEqual(t, bt.N, keyCount)
    20  
    21  		require.LessOrEqual(t, float64(bt.N-keyCount)/float64(bt.N), 0.05)
    22  
    23  	})
    24  }