Skip to content

Commit

Permalink
Fix Validators on minimal and mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Nov 18, 2019
1 parent a6f88e3 commit 513fd9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions tests/helpers/debug_ssz.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import
const
FixturesDir = currentSourcePath.rsplit(DirSep, 1)[0] / ".." / "official"/"fixtures"
SSZDir = FixturesDir/"tests-v0.9.1"/const_preset/"phase0"/"ssz_static"
UnitTestDir = SSZDir/"IndexedAttestation"/"ssz_zero"/"case_0"
UnitTestDir = SSZDir/"Validator"/"ssz_zero"/"case_0"

type
SSZHashTreeRoot = object
Expand Down Expand Up @@ -72,11 +72,11 @@ proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot =
echo "Current preset: ", const_preset

let hash = loadExpectedHashTreeRoot(UnitTestDir)
checkSSZ(IndexedAttestation, UnitTestDir, hash)
checkSSZ(Validator, UnitTestDir, hash)

echo "\n\n"
var deserialized: ref IndexedAttestation
var deserialized: ref Validator
new deserialized
deserialized[] = SSZ.loadFile(UnitTestDir/"serialized.ssz", IndexedAttestation)
deserialized[] = SSZ.loadFile(UnitTestDir/"serialized.ssz", Validator)

echo deserialized.data.hashTreeRoot()
echo deserialized[].hashTreeRoot()
9 changes: 4 additions & 5 deletions tests/official/test_fixture_ssz_consensus_objects.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ const Unsupported = toHashSet([
# "BeaconBlock", #
# "BeaconBlockBody", #
# "BeaconBlockHeader", #
# "BeaconState", # OK on minimal, KO on mainnet
# "BeaconState", #
# "Checkpoint", #
# "Deposit", #
# "DepositData", #
# "Eth1Data", #
# "Fork", #
# "HistoricalBatch", #
# "IndexedAttestation", #
# "PendingAttestation", # OK on minimal, KO on mainnet
# "PendingAttestation", #
# "ProposerSlashing", #
"Validator", # HashTreeRoot KO
# "Validator", # HashTreeRoot KO
# "VoluntaryExit" #
])

Expand All @@ -84,7 +84,6 @@ proc checkSSZ(T: typedesc, dir: string, expectedHash: SSZHashTreeRoot, skip = Sk
new deserialized
deserialized[] = SSZ.loadFile(dir/"serialized.ssz", T)

# echo "Dir: ", dir
if not(skip == SkipHashTreeRoot):
check: expectedHash.root == "0x" & toLowerASCII($deserialized.hashTreeRoot())
if expectedHash.signing_root != "" and not(skip == SkipSigningRoot):
Expand Down Expand Up @@ -142,7 +141,7 @@ proc runSSZtests() =
of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash)
of "PendingAttestation": checkSSZ(PendingAttestation, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "Validator": checkSSZ(VoluntaryExit, path, hash)
of "Validator": checkSSZ(Validator, path, hash)
of "VoluntaryExit": checkSSZ(VoluntaryExit, path, hash)
else:
raise newException(ValueError, "Unsupported test: " & sszType)
Expand Down

0 comments on commit 513fd9d

Please sign in to comment.