2019-08-28 12:07:00 +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.
|
|
|
|
|
|
|
|
|
|
|
|
# initialize_beacon_state_from_eth1 (beaconstate.nim)
|
2019-11-22 08:29:04 +00:00
|
|
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#genesis
|
2019-08-28 12:07:00 +00:00
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2019-11-14 10:47:55 +00:00
|
|
|
{.used.}
|
|
|
|
|
2019-08-28 12:07:00 +00:00
|
|
|
import
|
|
|
|
# Standard library
|
|
|
|
unittest,
|
|
|
|
# Specs
|
2019-11-14 10:47:55 +00:00
|
|
|
../../beacon_chain/spec/datatypes,
|
2019-08-28 12:07:00 +00:00
|
|
|
# Internals
|
2019-11-14 10:47:55 +00:00
|
|
|
../../beacon_chain/ssz,
|
2019-08-28 12:07:00 +00:00
|
|
|
# Mock helpers
|
2019-11-14 10:47:55 +00:00
|
|
|
../mocking/mock_genesis,
|
2019-08-28 12:07:00 +00:00
|
|
|
../testutil
|
|
|
|
|
|
|
|
|
|
|
|
# TODO:
|
|
|
|
# - MIN_GENESIS_ACTIVE_VALIDATOR_COUNT is not implemented
|
|
|
|
# - MIN_GENESIS_TIME is not implemented
|
|
|
|
# - is_valid_genesis_state is not implemented
|
|
|
|
|
|
|
|
suite "[Unit - Spec - Genesis] Genesis block checks " & preset():
|
|
|
|
test "is_valid_genesis_state for a valid state":
|
2019-11-14 17:37:51 +00:00
|
|
|
discard initGenesisState(
|
2019-08-28 12:07:00 +00:00
|
|
|
num_validators = MIN_GENESIS_ACTIVE_VALIDATOR_COUNT,
|
|
|
|
genesis_time = MIN_GENESIS_TIME
|
|
|
|
)
|
|
|
|
discard "TODO"
|
|
|
|
|
|
|
|
test "Invalid genesis time":
|
2019-11-14 17:37:51 +00:00
|
|
|
discard initGenesisState(
|
2019-08-28 12:07:00 +00:00
|
|
|
num_validators = MIN_GENESIS_ACTIVE_VALIDATOR_COUNT,
|
|
|
|
genesis_time = MIN_GENESIS_TIME.uint64 - 1
|
|
|
|
)
|
|
|
|
discard "TODO"
|
|
|
|
|
2019-11-21 11:56:41 +00:00
|
|
|
test "Validators with more than 32 ETH":
|
|
|
|
discard "TODO"
|
|
|
|
|
|
|
|
test "More validators than minimum":
|
|
|
|
discard "TODO"
|
|
|
|
|
|
|
|
when false:
|
|
|
|
# TODO causes possible stack overflow in mainnet
|
2019-08-28 12:07:00 +00:00
|
|
|
test "Not enough validators":
|
2019-11-14 17:37:51 +00:00
|
|
|
discard initGenesisState(
|
2019-08-28 12:07:00 +00:00
|
|
|
num_validators = MIN_GENESIS_ACTIVE_VALIDATOR_COUNT.uint64 - 1,
|
|
|
|
genesis_time = MIN_GENESIS_TIME.uint64 - 1
|
|
|
|
)
|
|
|
|
discard "TODO"
|