mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
cdd1d819df
* refactor batch verifier to share with pending queue * unit test for batch verifier --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
64 lines
2.0 KiB
Go
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, PendingQueueSidecarRequirements}
|
|
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())
|
|
}
|
|
}
|