Update spectests to v1.1.0-beta.1 from hf1 branch (#9403)

* Update spectests to v1.1.0-beta.1 from hf1 branch

* fix params loading
This commit is contained in:
Preston Van Loon 2021-08-17 16:23:38 -05:00 committed by GitHub
parent bdb09ca9ea
commit 4966300c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 20 deletions

View File

@ -197,6 +197,8 @@ filegroup(
url = "https://github.com/eth2-clients/slashing-protection-interchange-tests/archive/b8413ca42dc92308019d0d4db52c87e9e125c4e9.tar.gz",
)
eth2_spec_version = "v1.1.0-beta.1"
http_archive(
name = "eth2_spec_tests_general",
build_file_content = """
@ -209,8 +211,8 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "deacc076365c727d653ac064894ecf0d1b0a675d86704dc8de271259f6a7314b",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.1.0-alpha.3/general.tar.gz",
sha256 = "e9b4cc60a3e676c6b4a9348424e44cff1ebada603ffb31b0df600dbd70e7fbf6",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/%s/general.tar.gz" % eth2_spec_version,
)
http_archive(
@ -225,8 +227,8 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "6e9886af3d2f024e563249d70388129e28e3e92f742f289238ed9b7ec7a7f930",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.1.0-alpha.3/minimal.tar.gz",
sha256 = "cf82dc729ffe7b924f852e57d1973e1a6377c5b52acc903c953277fa9b4e6de8",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/%s/minimal.tar.gz" % eth2_spec_version,
)
http_archive(
@ -241,8 +243,24 @@ filegroup(
visibility = ["//visibility:public"],
)
""",
sha256 = "a7b3d0ffc02a567250f424d69b2474fdc9477cd56eada60af7474560b46a8527",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v1.1.0-alpha.3/mainnet.tar.gz",
sha256 = "6c6792375b81858037014e282d28a64b0cf12e12daf16054265c85403b8b329f",
url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/%s/mainnet.tar.gz" % eth2_spec_version,
)
http_archive(
name = "eth2_spec",
build_file_content = """
filegroup(
name = "spec_data",
srcs = glob([
"**/*.yaml",
]),
visibility = ["//visibility:public"],
)
""",
sha256 = "16094dad1bab4e8ab3adb60c10e311cd1e294cd7bbf5a89505f24bebd3d0e513",
strip_prefix = "eth2.0-specs-" + eth2_spec_version[1:],
url = "https://github.com/ethereum/eth2.0-specs/archive/refs/tags/%s.tar.gz" % eth2_spec_version,
)
http_archive(

View File

@ -39,6 +39,7 @@ go_test(
"loader_test.go",
],
data = glob(["*.yaml"]) + [
"@eth2_spec//:spec_data",
"@eth2_spec_tests_mainnet//:test_data",
"@eth2_spec_tests_minimal//:test_data",
],

View File

@ -25,7 +25,7 @@ func LoadChainConfigFile(chainConfigFileName string) {
if strings.HasPrefix(line, "DEPOSIT_CONTRACT_ADDRESS") {
continue
}
if strings.HasPrefix(line, "PRESET_BASE: 'minimal'") {
if strings.HasPrefix(line, "PRESET_BASE: 'minimal'") || strings.HasPrefix(line, "# Minimal preset") {
conf = MinimalSpecConfig().Copy()
}

View File

@ -125,14 +125,14 @@ func TestLoadConfigFileMainnet(t *testing.T) {
}
t.Run("mainnet", func(t *testing.T) {
mainnetConfigFile := deprecatedConfigFilePath(t, "mainnet")
mainnetConfigFile := presetsFilePath(t, "mainnet")
LoadChainConfigFile(mainnetConfigFile)
fields := fieldsFromYaml(t, mainnetConfigFile)
assertVals("mainnet", fields, MainnetConfig(), BeaconConfig())
})
t.Run("minimal", func(t *testing.T) {
minimalConfigFile := deprecatedConfigFilePath(t, "minimal")
minimalConfigFile := presetsFilePath(t, "minimal")
LoadChainConfigFile(minimalConfigFile)
fields := fieldsFromYaml(t, minimalConfigFile)
assertVals("minimal", fields, MinimalSpecConfig(), BeaconConfig())
@ -246,17 +246,6 @@ func presetsFilePath(t *testing.T, config string) string {
return configFilePath
}
// Deprecated: This sets the proper config and returns the relevant
// config file path from eth2-spec-tests directory. From altair onwards
// we use the other methods to retrieve the spec config.
func deprecatedConfigFilePath(t *testing.T, config string) string {
configFolderPath := path.Join("tests", config)
filepath, err := bazel.Runfile(configFolderPath)
require.NoError(t, err)
configFilePath := path.Join(filepath, "config", "phase0.yaml")
return configFilePath
}
func fieldsFromYaml(t *testing.T, fp string) []string {
yamlFile, err := ioutil.ReadFile(fp)
require.NoError(t, err)

View File

@ -5,6 +5,7 @@ import (
"path"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/pkg/errors"
)
// BazelDirectoryNonEmpty returns true if directory exists and is not empty.
@ -30,5 +31,8 @@ func BazelFileBytes(filePaths ...string) ([]byte, error) {
if err != nil {
return nil, err
}
if len(fileBytes) == 0 {
return nil, errors.New("empty file")
}
return fileBytes, nil
}

View File

@ -38,5 +38,9 @@ func TestFolders(t testing.TB, config, forkOrPhase, folderPath string) ([]os.Fil
testFolders, err := ioutil.ReadDir(filepath)
require.NoError(t, err)
if len(testFolders) == 0 {
t.Fatalf("No test folders found at %s", testsFolderPath)
}
return testFolders, testsFolderPath
}