erigon-pulse/cmd/ef-tests-cl/spectest/suite.go
a 30430d585a
begin refactor of beacon state (#7433)
this first major move separates the transient beacon state cache from
the underlying tree.

leaf updates are enforced in the setters, which should make programming
easier.

all exported methods of the raw.BeaconState should be safe to call
(without disrupting internal state)

changes many functions to consume *raw.BeaconState in perparation for
interface


beyond refactor it also:

adds a pool for the leaves of the validator ssz hash 

adds a pool for the snappy writers
  
removed the parallel hash experiment (high memory use)
2023-05-04 15:18:42 +02:00

86 lines
2.2 KiB
Go

package spectest
import (
"io/fs"
"path/filepath"
"testing"
"gfx.cafe/util/go/generic"
"github.com/stretchr/testify/require"
)
func RunCases(t *testing.T, app Appendix, root fs.FS) {
cases, err := ReadTestCases(root)
require.Nil(t, err, "reading cases")
// prepare for gore.....
type (
K1 = string
K2 = string
K3 = string
K4 = string
K5 = string
V = TestCase
)
// welcome to hell
cases.tree.Range0(func(s string, m *generic.Map5[K1, K2, K3, K4, K5, V]) bool {
t.Run(s, func(t *testing.T) {
t.Parallel()
m.Range0(func(s string, m *generic.Map4[K1, K2, K3, K4, V]) bool {
t.Run(s, func(t *testing.T) {
t.Parallel()
m.Range0(func(s string, m *generic.Map3[K1, K2, K3, V]) bool {
t.Run(s, func(t *testing.T) {
t.Parallel()
m.Range0(func(s string, m *generic.Map2[K1, K2, V]) bool {
t.Run(s, func(t *testing.T) {
t.Parallel()
m.Range0(func(s string, m *generic.Map1[K1, V]) bool {
t.Run(s, func(t *testing.T) {
t.Parallel()
m.Range0(func(key string, value TestCase) bool {
t.Run(key, func(t *testing.T) {
require.NotPanics(t, func() {
t.Parallel()
runner, ok := app[value.RunnerName]
if !ok {
t.Skipf("runner not found: %s", value.RunnerName)
return
}
handler, err := runner.GetHandler(value.HandlerName)
if err != nil {
t.Skipf("handler not found: %s/%s", value.RunnerName, value.HandlerName)
return
}
subfs, err := fs.Sub(root, filepath.Join(
value.ConfigName,
value.ForkPhaseName,
value.RunnerName,
value.HandlerName,
value.SuiteName,
value.CaseName,
))
require.NoError(t, err)
err = handler.Run(t, subfs, value)
require.NoError(t, err)
})
})
return true
})
})
return true
})
})
return true
})
})
return true
})
})
return true
})
})
return true
})
}