diff --git a/tests/mocking/mock_attestations.nim b/tests/mocking/mock_attestations.nim index 46b3cbbb4..098a8c7e8 100644 --- a/tests/mocking/mock_attestations.nim +++ b/tests/mocking/mock_attestations.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). @@ -84,8 +84,7 @@ proc signMockAttestation*(state: BeaconState, attestation: var Attestation) = proc mockAttestationImpl( state: BeaconState, - slot: Slot, - flags: UpdateFlags): Attestation = + slot: Slot): Attestation = var cache = StateCache() @@ -105,19 +104,16 @@ proc mockAttestationImpl( for i in 0 ..< beacon_committee.len: result.aggregation_bits[i] = true - if skipBlsValidation notin flags: - signMockAttestation(state, result) + signMockAttestation(state, result) + +proc mockAttestation*( + state: BeaconState): Attestation = + mockAttestationImpl(state, state.slot) proc mockAttestation*( state: BeaconState, - flags: UpdateFlags = {}): Attestation = - mockAttestationImpl(state, state.slot, flags) - -proc mockAttestation*( - state: BeaconState, - slot: Slot, - flags: UpdateFlags = {}): Attestation = - mockAttestationImpl(state, slot, flags) + slot: Slot): Attestation = + mockAttestationImpl(state, slot) func fillAggregateAttestation*(state: BeaconState, attestation: var Attestation) = var cache = StateCache() diff --git a/tests/mocking/mock_blocks.nim b/tests/mocking/mock_blocks.nim index c730c5781..50ab7c0ee 100644 --- a/tests/mocking/mock_blocks.nim +++ b/tests/mocking/mock_blocks.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). @@ -10,7 +10,7 @@ import # Specs ../../beacon_chain/spec/[datatypes, helpers, signatures, validator], # Internals - ../../beacon_chain/[ssz, extras], + ../../beacon_chain/ssz, # Mock helpers ./mock_validator_keys @@ -39,11 +39,9 @@ proc signMockBlock*(state: BeaconState, signedBlock: var SignedBeaconBlock) = proc mockBlock( state: BeaconState, - slot: Slot, - flags: UpdateFlags = {}): SignedBeaconBlock = + slot: Slot): SignedBeaconBlock = ## TODO don't do this gradual construction, for exception safety ## Mock a BeaconBlock for the specific slot - ## Skip signature creation if block should not be signed (skipBlsValidation present) var emptyCache = StateCache() let proposer_index = get_beacon_proposer_index(state, emptyCache) @@ -56,9 +54,7 @@ proc mockBlock( previous_block_header.state_root = state.hash_tree_root() result.message.parent_root = previous_block_header.hash_tree_root() - if skipBlsValidation notin flags: - signMockBlock(state, result) + signMockBlock(state, result) -proc mockBlockForNextSlot*(state: BeaconState, flags: UpdateFlags = {}): - SignedBeaconBlock = - mockBlock(state, state.slot + 1, flags) +proc mockBlockForNextSlot*(state: BeaconState): SignedBeaconBlock = + mockBlock(state, state.slot + 1) diff --git a/tests/official/test_fixture_operations_deposits.nim b/tests/official/test_fixture_operations_deposits.nim index 57d8021c7..432d62940 100644 --- a/tests/official/test_fixture_operations_deposits.nim +++ b/tests/official/test_fixture_operations_deposits.nim @@ -14,7 +14,7 @@ import stew/results, # Beacon chain internals ../../beacon_chain/spec/[datatypes, beaconstate, presets], - ../../beacon_chain/[ssz, extras], + ../../beacon_chain/ssz, # Test utilities ../testutil, ./fixtures_utils, @@ -32,10 +32,7 @@ proc runTest(identifier: string) = proc `testImpl _ operations_deposits _ identifier`() = - var flags: UpdateFlags var prefix: string - if not existsFile(testDir/"meta.yaml"): - flags.incl skipBlsValidation if existsFile(testDir/"post.ssz"): prefix = "[Valid] " else: @@ -47,10 +44,10 @@ proc runTest(identifier: string) = if existsFile(testDir/"post.ssz"): let postState = newClone(parseTest(testDir/"post.ssz", SSZ, BeaconState)) - discard process_deposit(defaultRuntimePreset, preState[], deposit, flags) + discard process_deposit(defaultRuntimePreset, preState[], deposit) reportDiff(preState, postState) else: - check process_deposit(defaultRuntimePreset, preState[], deposit, flags).isErr + check process_deposit(defaultRuntimePreset, preState[], deposit).isErr `testImpl _ operations_deposits _ identifier`() diff --git a/tests/test_attestation_pool.nim b/tests/test_attestation_pool.nim index 726f9a35b..c81118697 100644 --- a/tests/test_attestation_pool.nim +++ b/tests/test_attestation_pool.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2020 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). @@ -19,7 +19,7 @@ import ../beacon_chain/fork_choice/[fork_choice_types, fork_choice], ../beacon_chain/block_pools/[chain_dag, clearance] -func combine(tgt: var Attestation, src: Attestation, flags: UpdateFlags) = +func combine(tgt: var Attestation, src: Attestation) = ## Combine the signature and participation bitfield, with the assumption that ## the same data is being signed - if the signatures overlap, they are not ## combined. @@ -32,11 +32,10 @@ func combine(tgt: var Attestation, src: Attestation, flags: UpdateFlags) = if not tgt.aggregation_bits.overlaps(src.aggregation_bits): tgt.aggregation_bits.combine(src.aggregation_bits) - if skipBlsValidation notin flags: - var agg {.noInit.}: AggregateSignature - agg.init(tgt.signature) - agg.aggregate(src.signature) - tgt.signature = agg.finish() + var agg {.noInit.}: AggregateSignature + agg.init(tgt.signature) + agg.aggregate(src.signature) + tgt.signature = agg.finish() template wrappedTimedTest(name: string, body: untyped) = # `check` macro takes a copy of whatever it's checking, on the stack! @@ -151,7 +150,7 @@ suiteReport "Attestation pool processing" & preset(): attestation1 = makeAttestation( state.data.data, state.blck.root, bc0[1], cache) - attestation0.combine(attestation1, {}) + attestation0.combine(attestation1) pool[].addAttestation( attestation0, [bc0[0]].toHashSet, attestation0.data.slot) @@ -177,7 +176,7 @@ suiteReport "Attestation pool processing" & preset(): attestation1 = makeAttestation( state.data.data, state.blck.root, bc0[1], cache) - attestation0.combine(attestation1, {}) + attestation0.combine(attestation1) pool[].addAttestation( attestation1, [bc0[1]].toHashSet, attestation1.data.slot) diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index 4ab15082f..12514711d 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2020 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). @@ -57,10 +57,10 @@ proc makeInitialDeposits*( for i in 0..