Submodule official tests (#238)
* Remove eth2.0-tests submodule * Remove files * Add submodule https://github.com/status-im/nim-eth2-official-tests * Update tests path * update submodule version * Move beacon-chain specific datastructures out of the submodule
This commit is contained in:
parent
9a2f3176f7
commit
ad1803bdd6
|
@ -1,3 +1,3 @@
|
|||
[submodule "tests/official/eth2.0-tests"]
|
||||
path = tests/official/eth2.0-tests
|
||||
url = https://github.com/ethereum/eth2.0-tests
|
||||
[submodule "tests/official/fixtures"]
|
||||
path = tests/official/fixtures
|
||||
url = https://github.com/status-im/nim-eth2-official-tests
|
||||
|
|
|
@ -29,7 +29,8 @@ requires "nim >= 0.19.0",
|
|||
"json_rpc",
|
||||
"chronos",
|
||||
"yaml",
|
||||
"libp2p"
|
||||
"libp2p",
|
||||
"byteutils" # test only
|
||||
|
||||
### Helper functions
|
||||
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
Note on serialization hacks:
|
||||
|
||||
### FAR_FUTURE_SLOT (18446744073709551615)
|
||||
|
||||
The FAR_FUTURE_SLOT (18446744073709551615) has been rewritten as a string **in the YAML file**
|
||||
as it's 2^64-1 and Nim by default try to parse it into a int64 (which can represents up to 2^63-1).
|
||||
|
||||
The YAML file is then converted to JSON for easy input to the json serialization/deserialization
|
||||
with beacon chain type support.
|
||||
|
||||
"18446744073709551615" is then replaced again by uint64 18446744073709551615.
|
||||
|
||||
### Compressed signature
|
||||
|
||||
In `latest_block_header` field, the signatures and randao_reveals are
|
||||
`"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"`
|
||||
but that is not a valid compressed BLS signature, the zero signature should be:
|
||||
`"0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"`
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 3ec28295b0c8365f0ec7ad79cfe933755021ee1b
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6517fe82f9b1a8a8d7b6f4eefdf1a3fb00d1ffab
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +1,9 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
# Standard lib
|
||||
json, streams, strutils,
|
||||
# Dependencies
|
||||
yaml.tojson,
|
||||
# Status libs
|
||||
blscurve, nimcrypto, byteutils,
|
||||
eth/common, serialization, json_serialization,
|
||||
# Beacon chain internals
|
||||
# submodule in nim-beacon-chain/tests/official/fixtures/
|
||||
../../beacon_chain/spec/[datatypes, crypto, digest]
|
||||
|
||||
export nimcrypto.toHex
|
||||
|
@ -109,45 +99,4 @@ proc parseStateTests*(jsonPath: string): StateTest =
|
|||
writeStackTrace()
|
||||
stderr.write "Json load issue for file \"", jsonPath, "\"\n"
|
||||
stderr.write err.formatMsg(jsonPath), "\n"
|
||||
quit 1
|
||||
|
||||
# #######################
|
||||
# Yaml to JSON conversion
|
||||
|
||||
proc yamlToJson*(file: string): seq[JsonNode] =
|
||||
try:
|
||||
let fs = openFileStream(file)
|
||||
defer: fs.close()
|
||||
result = fs.loadToJson()
|
||||
except IOError:
|
||||
echo "Exception when reading file: " & file
|
||||
raise
|
||||
except OverflowError:
|
||||
echo "Overflow exception when parsing. Did you stringify 18446744073709551615 (-1)?"
|
||||
raise
|
||||
|
||||
when isMainModule:
|
||||
# Do not forget to stringify FAR_EPOCH_SLOT = 18446744073709551615 (-1) in the YAML file
|
||||
# And unstringify it in the produced JSON file
|
||||
|
||||
import os, typetraits
|
||||
|
||||
const
|
||||
DefaultYML = "tests/official/sanity-check_default-config_100-vals-first_test.yaml"
|
||||
DefaultOutputPath = "tests/official/sanity-check_default-config_100-vals-first_test.json"
|
||||
|
||||
var fileName, outputPath: string
|
||||
if paramCount() == 0:
|
||||
fileName = DefaultYML
|
||||
outputPath = DefaultOutputPath
|
||||
elif paramCount() == 1:
|
||||
fileName = paramStr(1)
|
||||
outputPath = DefaultOutputPath
|
||||
elif paramCount() >= 2:
|
||||
fileName = paramStr(1)
|
||||
outputPath = paramStr(2)
|
||||
|
||||
let jsonString = $DefaultYML.yamlToJson[0]
|
||||
DefaultOutputPath.writeFile jsonString
|
||||
|
||||
|
||||
quit 1
|
|
@ -12,10 +12,10 @@ import
|
|||
../../beacon_chain/spec/[datatypes, crypto, digest, beaconstate],
|
||||
../../beacon_chain/ssz,
|
||||
# Test utilities
|
||||
./fixtures_utils
|
||||
./state_test_utils
|
||||
|
||||
const TestFolder = currentSourcePath.rsplit(DirSep, 1)[0]
|
||||
const TestsPath = "/sanity-check_default-config_100-vals-first_test.json"
|
||||
const TestsPath = "/fixtures/json_tests/state/sanity-check_default-config_100-vals-first_test.json"
|
||||
|
||||
suite "Official - State tests": # Initializing a beacon state from the deposits
|
||||
var stateTests: StateTest
|
||||
|
|
Loading…
Reference in New Issue