Skip to content

Commit

Permalink
make tests really check
Browse files Browse the repository at this point in the history
  • Loading branch information
gpsanant committed Feb 29, 2024
1 parent 256479b commit f21107f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,45 @@ package eigenpodproofs
import (
"testing"

"github.com/Layr-Labs/eigenpod-proofs-generation/beacon"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/stretchr/testify/assert"
)

func BenchmarkComputeBeaconStateRoot(b *testing.B) {
computed, err := epp.ComputeBeaconStateRoot(&oracleState)
if err != nil {
b.Fatal(err)
}

var cached phase0.Root
for i := 0; i < b.N; i++ {
_, _ = epp.ComputeBeaconStateRoot(&oracleState)
cached, err = epp.ComputeBeaconStateRoot(&oracleState)
if err != nil {
b.Fatal(err)
}
}

assert.Equal(b, computed, cached)
}

func BenchmarkComputeBeaconStateTopLevelRoots(b *testing.B) {
computed, err := epp.ComputeBeaconStateTopLevelRoots(&spec.VersionedBeaconState{Deneb: &oracleState})
if err != nil {
b.Fatal(err)
}

var cached *beacon.BeaconStateTopLevelRoots
for i := 0; i < b.N; i++ {
_, _ = epp.ComputeBeaconStateTopLevelRoots(&spec.VersionedBeaconState{Deneb: &oracleState})
cached, err = epp.ComputeBeaconStateTopLevelRoots(&spec.VersionedBeaconState{Deneb: &oracleState})
if err != nil {
b.Fatal(err)
}

}

assert.Equal(b, computed, cached)
}

func BenchmarkComputeValidatorTree(b *testing.B) {
Expand All @@ -36,5 +59,4 @@ func BenchmarkComputeValidatorTree(b *testing.B) {
}

assert.Equal(b, computed, cached)

}

0 comments on commit f21107f

Please sign in to comment.