2019-05-10 08:14:01 +00:00
|
|
|
# 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
|
2019-05-27 12:48:13 +00:00
|
|
|
# Standard library
|
2019-05-10 08:14:01 +00:00
|
|
|
ospaths, strutils, json, unittest,
|
|
|
|
# Third parties
|
|
|
|
|
|
|
|
# Beacon chain internals
|
2019-05-27 12:48:13 +00:00
|
|
|
../../beacon_chain/spec/[datatypes, validator],
|
2019-05-10 08:14:01 +00:00
|
|
|
# Test utilities
|
2019-05-27 12:48:13 +00:00
|
|
|
../testutil,
|
2019-05-10 08:14:01 +00:00
|
|
|
./fixtures_utils
|
|
|
|
|
|
|
|
const TestFolder = currentSourcePath.rsplit(DirSep, 1)[0]
|
2019-05-27 12:48:13 +00:00
|
|
|
|
|
|
|
when const_preset == "mainnet":
|
|
|
|
const TestsPath = "fixtures" / "json_tests" / "shuffling" / "core" / "shuffling_full.json"
|
|
|
|
elif const_preset == "minimal":
|
|
|
|
const TestsPath = "fixtures" / "json_tests" / "shuffling" / "core" / "shuffling_minimal.json"
|
2019-05-10 08:14:01 +00:00
|
|
|
|
2019-05-23 07:41:17 +00:00
|
|
|
var shufflingTests: Tests[Shuffling]
|
2019-05-10 08:14:01 +00:00
|
|
|
|
2019-05-27 12:48:13 +00:00
|
|
|
suite "Official - Shuffling tests [Preset: " & preset():
|
|
|
|
test "Parsing the official shuffling tests [Preset: " & preset():
|
2019-05-23 07:41:17 +00:00
|
|
|
shufflingTests = parseTestsShuffling(TestFolder / TestsPath)
|
2019-05-10 08:14:01 +00:00
|
|
|
|
2019-05-27 12:48:13 +00:00
|
|
|
test "Shuffling a sequence of N validators" & preset():
|
2019-05-10 08:14:01 +00:00
|
|
|
for t in shufflingTests.test_cases:
|
|
|
|
let implResult = get_shuffled_seq(t.seed, t.count)
|
2019-05-27 12:48:13 +00:00
|
|
|
check: implResult == t.shuffled
|