From 6ec59867ef8eb56329e8ae10437f72edc0f0976d Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 30 May 2019 09:53:46 +0800 Subject: [PATCH] Fix linter errors --- scripts/phase0/build_spec.py | 12 ++++++++++-- specs/core/0_beacon-chain.md | 3 ++- .../test/block_processing/test_process_transfer.py | 10 ++++++++-- test_libs/pyspec/eth2spec/test/conftest.py | 1 + test_libs/pyspec/eth2spec/test/helpers/block.py | 1 - test_libs/pyspec/eth2spec/test/sanity/test_slots.py | 1 - 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/phase0/build_spec.py b/scripts/phase0/build_spec.py index 36d039c2c..457a13da0 100644 --- a/scripts/phase0/build_spec.py +++ b/scripts/phase0/build_spec.py @@ -13,9 +13,17 @@ from typing import ( NewType, Tuple, ) -from eth2spec.utils.minimal_ssz import * +from eth2spec.utils.minimal_ssz import ( + SSZType, + hash_tree_root, + signing_root, +) from eth2spec.utils.hash_function import hash -from eth2spec.utils.bls import * +from eth2spec.utils.bls import ( + bls_aggregate_pubkeys, + bls_verify, + bls_verify_multiple, +) # stub, will get overwritten by real var diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 9dc052ec4..a01ba785d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1776,7 +1776,8 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None: validator_pubkeys = [v.pubkey for v in state.validator_registry] if pubkey not in validator_pubkeys: # Verify the deposit signature (proof of possession). - # Invalid signatures are allowed by the deposit contract, and hence included on-chain, but must not be processed. + # Invalid signatures are allowed by the deposit contract, + # and hence included on-chain, but must not be processed. # Note: deposits are valid across forks, hence the deposit domain is retrieved directly from `bls_domain` if not bls_verify( pubkey, signing_root(deposit.data), deposit.data.signature, bls_domain(DOMAIN_DEPOSIT) diff --git a/test_libs/pyspec/eth2spec/test/block_processing/test_process_transfer.py b/test_libs/pyspec/eth2spec/test/block_processing/test_process_transfer.py index 83af75574..bd435d67a 100644 --- a/test_libs/pyspec/eth2spec/test/block_processing/test_process_transfer.py +++ b/test_libs/pyspec/eth2spec/test/block_processing/test_process_transfer.py @@ -89,7 +89,7 @@ def test_invalid_signature(state): transfer = get_valid_transfer(state) # un-activate so validator can transfer state.validator_registry[transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH - + yield from run_transfer_processing(state, transfer, False) @@ -140,7 +140,13 @@ def test_insufficient_balance(state): def test_no_dust_sender(state): sender_index = get_active_validator_indices(state, get_current_epoch(state))[-1] balance = state.balances[sender_index] - transfer = get_valid_transfer(state, sender_index=sender_index, amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1, fee=0, signed=True) + transfer = get_valid_transfer( + state, + sender_index=sender_index, + amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1, + fee=0, + signed=True, + ) # un-activate so validator can transfer state.validator_registry[transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH diff --git a/test_libs/pyspec/eth2spec/test/conftest.py b/test_libs/pyspec/eth2spec/test/conftest.py index dadb0d5d0..5e8ec708a 100644 --- a/test_libs/pyspec/eth2spec/test/conftest.py +++ b/test_libs/pyspec/eth2spec/test/conftest.py @@ -3,6 +3,7 @@ from eth2spec.phase0 import spec # We import pytest only when it's present, i.e. when we are running tests. # The test-cases themselves can be generated without installing pytest. + def module_exists(module_name): try: __import__(module_name) diff --git a/test_libs/pyspec/eth2spec/test/helpers/block.py b/test_libs/pyspec/eth2spec/test/helpers/block.py index c557e0245..715cf82db 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/block.py +++ b/test_libs/pyspec/eth2spec/test/helpers/block.py @@ -77,4 +77,3 @@ def build_empty_block(state, slot=None, signed=False): def build_empty_block_for_next_slot(state, signed=False): return build_empty_block(state, state.slot + 1, signed=signed) - diff --git a/test_libs/pyspec/eth2spec/test/sanity/test_slots.py b/test_libs/pyspec/eth2spec/test/sanity/test_slots.py index 92e0251ca..4c3897a6c 100644 --- a/test_libs/pyspec/eth2spec/test/sanity/test_slots.py +++ b/test_libs/pyspec/eth2spec/test/sanity/test_slots.py @@ -55,4 +55,3 @@ def test_over_epoch_boundary(state): yield 'slots', slots process_slots(state, state.slot + slots) yield 'post', state -