From f21107f2855e79528011bd0f489a0e2e90b2249d Mon Sep 17 00:00:00 2001 From: gpsanant Date: Wed, 28 Feb 2024 16:18:43 -0800 Subject: [PATCH] make tests really check --- benchmark_test.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/benchmark_test.go b/benchmark_test.go index 2aad3dea..d9e19001 100644 --- a/benchmark_test.go +++ b/benchmark_test.go @@ -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) { @@ -36,5 +59,4 @@ func BenchmarkComputeValidatorTree(b *testing.B) { } assert.Equal(b, computed, cached) - }