prysm-pulse/beacon-chain/verification/result_test.go
kasey 07a0a95ee7
Blob verification spectest (#13707)
* use real blob verifier in forkchoice spectest

* wip

* Use real blob sidecar for test

* Set file db correctly

* correctly handle blob cases where valid=false

* work-around spectest's weird Fork in genesis state

* gaz

* revert T-money's log level change

* rm whitespace

* unskip minimal test

* Preston's feedback

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2024-03-08 18:20:38 +00:00

64 lines
2.0 KiB
Go

package verification
import (
"math"
"testing"
"github.com/prysmaticlabs/prysm/v5/testing/require"
)
func TestResultList(t *testing.T) {
const (
a Requirement = iota
b
c
d
e
f
g
h
)
// leave out h to test excluding non-existent item
all := []Requirement{a, b, c, d, e, f, g}
alsoAll := requirementList(all).excluding()
require.DeepEqual(t, all, alsoAll)
missingFirst := requirementList(all).excluding(a)
require.Equal(t, len(all)-1, len(missingFirst))
require.DeepEqual(t, all[1:], missingFirst)
missingLast := requirementList(all).excluding(g)
require.Equal(t, len(all)-1, len(missingLast))
require.DeepEqual(t, all[0:len(all)-1], missingLast)
missingEnds := requirementList(missingLast).excluding(a)
require.Equal(t, len(missingLast)-1, len(missingEnds))
require.DeepEqual(t, all[1:len(all)-1], missingEnds)
excludeNonexist := requirementList(missingEnds).excluding(h)
require.Equal(t, len(missingEnds), len(excludeNonexist))
require.DeepEqual(t, missingEnds, excludeNonexist)
}
func TestExportedBlobSanityCheck(t *testing.T) {
// make sure all requirement lists contain the bare minimum checks
sanity := []Requirement{RequireValidProposerSignature, RequireSidecarKzgProofVerified, RequireBlobIndexInBounds, RequireSidecarInclusionProven}
reqs := [][]Requirement{GossipSidecarRequirements, SpectestSidecarRequirements, InitsyncSidecarRequirements, BackfillSidecarRequirements}
for i := range reqs {
r := reqs[i]
reqMap := make(map[Requirement]struct{})
for ii := range r {
reqMap[r[ii]] = struct{}{}
}
for ii := range sanity {
_, ok := reqMap[sanity[ii]]
require.Equal(t, true, ok)
}
}
require.DeepEqual(t, allSidecarRequirements, GossipSidecarRequirements)
}
func TestAllBlobRequirementsHaveStrings(t *testing.T) {
var derp Requirement = math.MaxInt
require.Equal(t, unknownRequirementName, derp.String())
for i := range allSidecarRequirements {
require.NotEqual(t, unknownRequirementName, allSidecarRequirements[i].String())
}
}