diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index 064ec8e49..c3929f0fe 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -515,15 +515,6 @@ OK: 23/23 Fail: 0/23 Skip: 0/23 + default initialization of signatures OK ``` OK: 3/3 Fail: 0/3 Skip: 0/3 -## [Unit - Spec - Block processing] Deposits [Preset: mainnet] -```diff -+ Deposit at MAX_EFFECTIVE_BALANCE balance (32 ETH) OK -+ Deposit over MAX_EFFECTIVE_BALANCE balance (32 ETH) OK -+ Deposit under MAX_EFFECTIVE_BALANCE balance (32 ETH) OK -+ Invalid deposit at MAX_EFFECTIVE_BALANCE balance (32 ETH) OK -+ Validator top-up OK -``` -OK: 5/5 Fail: 0/5 Skip: 0/5 ## [Unit - Spec - Epoch processing] Justification and Finalization [Preset: mainnet] ```diff + Rule I - 234 finalization with enough support OK @@ -623,4 +614,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 344/349 Fail: 0/349 Skip: 5/349 +OK: 339/344 Fail: 0/344 Skip: 5/344 diff --git a/tests/all_tests.nim b/tests/all_tests.nim index 696815e15..d949d94f6 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -52,7 +52,6 @@ import # Unit test import # Refactor state transition unit tests # In mainnet these take 2 minutes and are empty TODOs - ./spec_block_processing/test_process_deposits, ./spec_epoch_processing/test_process_justification_and_finalization when not defined(i386): diff --git a/tests/spec_block_processing/test_process_deposits.nim b/tests/spec_block_processing/test_process_deposits.nim deleted file mode 100644 index b13c557d2..000000000 --- a/tests/spec_block_processing/test_process_deposits.nim +++ /dev/null @@ -1,148 +0,0 @@ -# beacon_chain -# Copyright (c) 2018-2022 Status Research & Development GmbH -# Licensed and distributed under either of -# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). -# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). -# at your option. This file may not be copied, modified, or distributed except according to those terms. - - -# process_deposit (beaconstate.nim) -# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#deposits -# --------------------------------------------------------------- - -{.used.} - -import - # Standard library - std/math, - # Specs - ../../beacon_chain/spec/[forks, state_transition_block], - ../../beacon_chain/spec/datatypes/base, - # Internals - # Mock helpers - ../mocking/[mock_deposits, mock_genesis], - ../testutil, ../helpers/math_helpers - -suite "[Unit - Spec - Block processing] Deposits " & preset(): - - const NumValidators = uint64 5 * SLOTS_PER_EPOCH - let genesisState = newClone(initGenesisState(NumValidators).phase0Data) - doAssert genesisState.data.validators.lenu64 == NumValidators - - template valid_deposit(deposit_amount: uint64, name: string): untyped = - test "Deposit " & name & " MAX_EFFECTIVE_BALANCE balance (" & - $(MAX_EFFECTIVE_BALANCE div 10'u64^9) & " ETH)": - let state = assignClone(genesisState[]) - - # Test configuration - # ---------------------------------------- - let validator_index = state.data.validators.len - let deposit = mockUpdateStateForNewDeposit( - state.data, - uint64 validator_index, - deposit_amount, - flags = {} - ) - - # Params for sanity checks - # ---------------------------------------- - let pre_val_count = state.data.validators.len - let pre_balance = if validator_index < pre_val_count: - state.data.balances.item(validator_index) - else: - 0 - - # State transition - # ---------------------------------------- - check: process_deposit(defaultRuntimeConfig, state.data, deposit, {}).isOk - - # Check invariants - # ---------------------------------------- - check: - state.data.validators.len == pre_val_count + 1 - state.data.balances.len == pre_val_count + 1 - state.data.balances.item(validator_index) == pre_balance + deposit.data.amount - state.data.validators.item(validator_index).effective_balance == - round_multiple_down( - min(MAX_EFFECTIVE_BALANCE, state.data.balances.item(validator_index)), - EFFECTIVE_BALANCE_INCREMENT - ) - - valid_deposit(MAX_EFFECTIVE_BALANCE - 1, "under") - valid_deposit(MAX_EFFECTIVE_BALANCE, "at") - valid_deposit(MAX_EFFECTIVE_BALANCE + 1, "over") - - test "Validator top-up": - let state = assignClone(genesisState[]) - - # Test configuration - # ---------------------------------------- - let validator_index = 0 - let deposit_amount = MAX_EFFECTIVE_BALANCE div 4 - let deposit = mockUpdateStateForNewDeposit( - state.data, - uint64 validator_index, - deposit_amount, - flags = {} - ) - - # Params for sanity checks - # ---------------------------------------- - let pre_val_count = state.data.validators.len - let pre_balance = if validator_index < pre_val_count: - state.data.balances.mitem(validator_index) - else: - 0 - - # State transition - # ---------------------------------------- - check: process_deposit(defaultRuntimeConfig, state.data, deposit, {}).isOk - - # Check invariants - # ---------------------------------------- - check: - state.data.validators.len == pre_val_count - state.data.balances.len == pre_val_count - state.data.balances.item(validator_index) == pre_balance + deposit.data.amount - state.data.validators.item(validator_index).effective_balance == - round_multiple_down( - min(MAX_EFFECTIVE_BALANCE, state.data.balances.item(validator_index)), - EFFECTIVE_BALANCE_INCREMENT - ) - - template invalid_signature(deposit_amount: uint64, name: string): untyped = - test "Invalid deposit " & name & " MAX_EFFECTIVE_BALANCE balance (" & - $(MAX_EFFECTIVE_BALANCE div 10'u64^9) & " ETH)": - let state = assignClone(genesisState[]) - - # Test configuration - # ---------------------------------------- - let validator_index = state.data.validators.len - let deposit = mockUpdateStateForNewDeposit( - state.data, - uint64 validator_index, - deposit_amount, - flags = {skipBlsValidation} - ) - - # Params for sanity checks - # ---------------------------------------- - let pre_val_count = state.data.validators.len - - # State transition - # ---------------------------------------- - check: - process_deposit(defaultRuntimeConfig, state.data, deposit, {}).isOk - - # Check invariants - # ---------------------------------------- - check: - state.data.validators.len == pre_val_count - state.data.balances.len == pre_val_count - - invalid_signature(MAX_EFFECTIVE_BALANCE, "at") - - # TODO, tests with: - # - invalid withdrawal credential - # - invalid deposit root - # - invalid merkle proof