diff --git a/hathor/builder/cli_builder.py b/hathor/builder/cli_builder.py index fc897867b..0e9ea9d04 100644 --- a/hathor/builder/cli_builder.py +++ b/hathor/builder/cli_builder.py @@ -37,7 +37,8 @@ from hathor.pubsub import PubSubManager from hathor.stratum import StratumFactory from hathor.util import Random, Reactor, not_none -from hathor.verification.verification_service import VerificationService, VertexVerifiers +from hathor.verification.verification_service import VerificationService +from hathor.verification.vertex_verifiers import VertexVerifiers from hathor.wallet import BaseWallet, HDWallet, Wallet logger = get_logger() diff --git a/hathor/simulator/patches.py b/hathor/simulator/patches.py index 1f9fdd1d3..3c056249e 100644 --- a/hathor/simulator/patches.py +++ b/hathor/simulator/patches.py @@ -18,41 +18,16 @@ from hathor.mining.cpu_mining_service import CpuMiningService from hathor.transaction import BaseTransaction -from hathor.verification.block_verifier import BlockVerifier -from hathor.verification.merge_mined_block_verifier import MergeMinedBlockVerifier -from hathor.verification.token_creation_transaction_verifier import TokenCreationTransactionVerifier -from hathor.verification.transaction_verifier import TransactionVerifier +from hathor.verification.vertex_verifier import VertexVerifier logger = get_logger() -def _verify_pow(vertex: BaseTransaction) -> None: - assert vertex.hash is not None - logger.new().debug('Skipping VertexVerifier.verify_pow() for simulator') - - -class SimulatorBlockVerifier(BlockVerifier): - @classmethod - def verify_pow(cls, vertex: BaseTransaction, *, override_weight: Optional[float] = None) -> None: - _verify_pow(vertex) - - -class SimulatorMergeMinedBlockVerifier(MergeMinedBlockVerifier): - @classmethod - def verify_pow(cls, vertex: BaseTransaction, *, override_weight: Optional[float] = None) -> None: - _verify_pow(vertex) - - -class SimulatorTransactionVerifier(TransactionVerifier): - @classmethod - def verify_pow(cls, vertex: BaseTransaction, *, override_weight: Optional[float] = None) -> None: - _verify_pow(vertex) - - -class SimulatorTokenCreationTransactionVerifier(TokenCreationTransactionVerifier): +class SimulatorVertexVerifier(VertexVerifier): @classmethod def verify_pow(cls, vertex: BaseTransaction, *, override_weight: Optional[float] = None) -> None: - _verify_pow(vertex) + assert vertex.hash is not None + logger.new().debug('Skipping VertexVerifier.verify_pow() for simulator') class SimulatorCpuMiningService(CpuMiningService): diff --git a/hathor/simulator/simulator.py b/hathor/simulator/simulator.py index e8dc4c087..b6c546a3f 100644 --- a/hathor/simulator/simulator.py +++ b/hathor/simulator/simulator.py @@ -29,16 +29,10 @@ from hathor.p2p.peer_id import PeerId from hathor.simulator.clock import HeapClock, MemoryReactorHeapClock from hathor.simulator.miner.geometric_miner import GeometricMiner -from hathor.simulator.patches import ( - SimulatorBlockVerifier, - SimulatorCpuMiningService, - SimulatorMergeMinedBlockVerifier, - SimulatorTokenCreationTransactionVerifier, - SimulatorTransactionVerifier, -) +from hathor.simulator.patches import SimulatorCpuMiningService, SimulatorVertexVerifier from hathor.simulator.tx_generator import RandomTransactionGenerator from hathor.util import Random -from hathor.verification.verification_service import VertexVerifiers +from hathor.verification.vertex_verifiers import VertexVerifiers from hathor.wallet import HDWallet if TYPE_CHECKING: @@ -257,9 +251,9 @@ def _build_vertex_verifiers( """ A custom VertexVerifiers builder to be used by the simulator. """ - return VertexVerifiers( - block=SimulatorBlockVerifier(settings=settings, daa=daa, feature_service=feature_service), - merge_mined_block=SimulatorMergeMinedBlockVerifier(), - tx=SimulatorTransactionVerifier(settings=settings, daa=daa), - token_creation_tx=SimulatorTokenCreationTransactionVerifier(settings=settings), + return VertexVerifiers.create( + settings=settings, + vertex_verifier=SimulatorVertexVerifier(settings=settings, daa=daa), + daa=daa, + feature_service=feature_service, ) diff --git a/hathor/transaction/resources/create_tx.py b/hathor/transaction/resources/create_tx.py index e347cbf78..3357554af 100644 --- a/hathor/transaction/resources/create_tx.py +++ b/hathor/transaction/resources/create_tx.py @@ -18,6 +18,7 @@ from hathor.cli.openapi_files.register import register_resource from hathor.crypto.util import decode_address from hathor.exception import InvalidNewTransaction +from hathor.manager import HathorManager from hathor.transaction import Transaction, TxInput, TxOutput from hathor.transaction.scripts import create_output_script from hathor.util import api_catch_exceptions, json_dumpb, json_loadb @@ -49,7 +50,7 @@ class CreateTxResource(Resource): """ isLeaf = True - def __init__(self, manager): + def __init__(self, manager: HathorManager) -> None: # Important to have the manager so we can know the tx_storage self.manager = manager @@ -107,15 +108,16 @@ def render_POST(self, request): def _verify_unsigned_skip_pow(self, tx: Transaction) -> None: """ Same as .verify but skipping pow and signature verification.""" assert type(tx) is Transaction - verifier = self.manager.verification_service.verifiers.tx - verifier.verify_number_of_inputs(tx) - verifier.verify_number_of_outputs(tx) - verifier.verify_outputs(tx) - verifier.verify_sigops_output(tx) - verifier.verify_sigops_input(tx) - verifier.verify_inputs(tx, skip_script=True) # need to run verify_inputs first to check if all inputs exist - verifier.verify_parents(tx) - verifier.verify_sum(tx) + verifiers = self.manager.verification_service.verifiers + verifiers.tx.verify_number_of_inputs(tx) + verifiers.vertex.verify_number_of_outputs(tx) + verifiers.tx.verify_outputs(tx) + verifiers.vertex.verify_sigops_output(tx) + verifiers.tx.verify_sigops_input(tx) + # need to run verify_inputs first to check if all inputs exist + verifiers.tx.verify_inputs(tx, skip_script=True) + verifiers.vertex.verify_parents(tx) + verifiers.tx.verify_sum(tx) CreateTxResource.openapi = { diff --git a/hathor/verification/block_verifier.py b/hathor/verification/block_verifier.py index 99f4bf124..6a2a4af10 100644 --- a/hathor/verification/block_verifier.py +++ b/hathor/verification/block_verifier.py @@ -15,7 +15,7 @@ from hathor.conf.settings import HathorSettings from hathor.daa import DifficultyAdjustmentAlgorithm from hathor.feature_activation.feature_service import BlockIsMissingSignal, BlockIsSignaling, FeatureService -from hathor.transaction import BaseTransaction, Block +from hathor.transaction import Block from hathor.transaction.exceptions import ( BlockMustSignalError, BlockWithInputs, @@ -28,17 +28,20 @@ from hathor.verification.vertex_verifier import VertexVerifier -class BlockVerifier(VertexVerifier): - __slots__ = ('_feature_service', ) +class BlockVerifier: + __slots__ = ('_settings', '_vertex_verifier', '_daa', '_feature_service') def __init__( self, *, settings: HathorSettings, + vertex_verifier: VertexVerifier, daa: DifficultyAdjustmentAlgorithm, feature_service: FeatureService | None = None ) -> None: - super().__init__(settings=settings, daa=daa) + self._settings = settings + self._vertex_verifier = vertex_verifier + self._daa = daa self._feature_service = feature_service def verify_height(self, block: Block) -> None: @@ -71,9 +74,8 @@ def verify_no_inputs(self, block: Block) -> None: if inputs: raise BlockWithInputs('number of inputs {}'.format(len(inputs))) - def verify_outputs(self, block: BaseTransaction) -> None: - assert isinstance(block, Block) - super().verify_outputs(block) + def verify_outputs(self, block: Block) -> None: + self._vertex_verifier.verify_outputs(block) for output in block.outputs: if output.get_token_index() > 0: raise BlockWithTokensError('in output: {}'.format(output.to_human_readable())) diff --git a/hathor/verification/transaction_verifier.py b/hathor/verification/transaction_verifier.py index e8dddf4a7..3afc7e16a 100644 --- a/hathor/verification/transaction_verifier.py +++ b/hathor/verification/transaction_verifier.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from hathor.conf.settings import HathorSettings +from hathor.daa import DifficultyAdjustmentAlgorithm from hathor.profiler import get_cpu_profiler from hathor.transaction import BaseTransaction, Transaction, TxInput from hathor.transaction.exceptions import ( @@ -39,8 +41,19 @@ cpu = get_cpu_profiler() -class TransactionVerifier(VertexVerifier): - __slots__ = () +class TransactionVerifier: + __slots__ = ('_settings', '_vertex_verifier', '_daa') + + def __init__( + self, + *, + settings: HathorSettings, + vertex_verifier: VertexVerifier, + daa: DifficultyAdjustmentAlgorithm, + ) -> None: + self._settings = settings + self._vertex_verifier = vertex_verifier + self._daa = daa def verify_parents_basic(self, tx: Transaction) -> None: """Verify number and non-duplicity of parents.""" @@ -164,13 +177,12 @@ def verify_number_of_inputs(self, tx: Transaction) -> None: if not tx.is_genesis: raise NoInputError('Transaction must have at least one input') - def verify_outputs(self, tx: BaseTransaction) -> None: + def verify_outputs(self, tx: Transaction) -> None: """Verify outputs reference an existing token uid in the tokens list :raises InvalidToken: output references non existent token uid """ - assert isinstance(tx, Transaction) - super().verify_outputs(tx) + self._vertex_verifier.verify_outputs(tx) for output in tx.outputs: # check index is valid if output.get_token_index() > len(tx.tokens): diff --git a/hathor/verification/verification_service.py b/hathor/verification/verification_service.py index 6428b8322..1c1c3cb7e 100644 --- a/hathor/verification/verification_service.py +++ b/hathor/verification/verification_service.py @@ -12,52 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import NamedTuple - from typing_extensions import assert_never -from hathor.conf.settings import HathorSettings -from hathor.daa import DifficultyAdjustmentAlgorithm -from hathor.feature_activation.feature_service import FeatureService from hathor.profiler import get_cpu_profiler from hathor.transaction import BaseTransaction, Block, MergeMinedBlock, Transaction, TxVersion from hathor.transaction.token_creation_tx import TokenCreationTransaction from hathor.transaction.validation_state import ValidationState -from hathor.verification.block_verifier import BlockVerifier -from hathor.verification.merge_mined_block_verifier import MergeMinedBlockVerifier -from hathor.verification.token_creation_transaction_verifier import TokenCreationTransactionVerifier -from hathor.verification.transaction_verifier import TransactionVerifier +from hathor.verification.vertex_verifiers import VertexVerifiers cpu = get_cpu_profiler() -class VertexVerifiers(NamedTuple): - """A group of verifier instances, one for each vertex type.""" - block: BlockVerifier - merge_mined_block: MergeMinedBlockVerifier - tx: TransactionVerifier - token_creation_tx: TokenCreationTransactionVerifier - - @classmethod - def create_defaults( - cls, - *, - settings: HathorSettings, - daa: DifficultyAdjustmentAlgorithm, - feature_service: FeatureService | None = None, - ) -> 'VertexVerifiers': - """ - Create a VertexVerifiers instance using the default verifier for each vertex type, - from all required dependencies. - """ - return VertexVerifiers( - block=BlockVerifier(settings=settings, daa=daa, feature_service=feature_service), - merge_mined_block=MergeMinedBlockVerifier(), - tx=TransactionVerifier(settings=settings, daa=daa), - token_creation_tx=TokenCreationTransactionVerifier(settings=settings), - ) - - class VerificationService: __slots__ = ('verifiers', ) @@ -192,7 +157,7 @@ def _verify_block(self, block: Block) -> None: self.verify_without_storage(block) # (1) and (4) - self.verifiers.block.verify_parents(block) + self.verifiers.vertex.verify_parents(block) self.verifiers.block.verify_height(block) @@ -220,7 +185,7 @@ def _verify_tx(self, tx: Transaction, *, reject_locked_reward: bool) -> None: self.verify_without_storage(tx) self.verifiers.tx.verify_sigops_input(tx) self.verifiers.tx.verify_inputs(tx) # need to run verify_inputs first to check if all inputs exist - self.verifiers.tx.verify_parents(tx) + self.verifiers.vertex.verify_parents(tx) self.verifiers.tx.verify_sum(tx) if reject_locked_reward: self.verifiers.tx.verify_reward_locked(tx) @@ -255,11 +220,11 @@ def verify_without_storage(self, vertex: BaseTransaction) -> None: def _verify_without_storage_block(self, block: Block) -> None: """ Run all verifications that do not need a storage. """ - self.verifiers.block.verify_pow(block) + self.verifiers.vertex.verify_pow(block) self.verifiers.block.verify_no_inputs(block) self.verifiers.block.verify_outputs(block) self.verifiers.block.verify_data(block) - self.verifiers.block.verify_sigops_output(block) + self.verifiers.vertex.verify_sigops_output(block) def _verify_without_storage_merge_mined_block(self, block: MergeMinedBlock) -> None: self.verifiers.merge_mined_block.verify_aux_pow(block) @@ -268,10 +233,10 @@ def _verify_without_storage_merge_mined_block(self, block: MergeMinedBlock) -> N def _verify_without_storage_tx(self, tx: Transaction) -> None: """ Run all verifications that do not need a storage. """ - self.verifiers.tx.verify_pow(tx) + self.verifiers.vertex.verify_pow(tx) self.verifiers.tx.verify_number_of_inputs(tx) self.verifiers.tx.verify_outputs(tx) - self.verifiers.tx.verify_sigops_output(tx) + self.verifiers.vertex.verify_sigops_output(tx) def _verify_without_storage_token_creation_tx(self, tx: TokenCreationTransaction) -> None: self._verify_without_storage_tx(tx) diff --git a/hathor/verification/vertex_verifiers.py b/hathor/verification/vertex_verifiers.py new file mode 100644 index 000000000..aab861ecf --- /dev/null +++ b/hathor/verification/vertex_verifiers.py @@ -0,0 +1,84 @@ +# Copyright 2023 Hathor Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import NamedTuple + +from hathor.conf.settings import HathorSettings +from hathor.daa import DifficultyAdjustmentAlgorithm +from hathor.feature_activation.feature_service import FeatureService +from hathor.verification.block_verifier import BlockVerifier +from hathor.verification.merge_mined_block_verifier import MergeMinedBlockVerifier +from hathor.verification.token_creation_transaction_verifier import TokenCreationTransactionVerifier +from hathor.verification.transaction_verifier import TransactionVerifier +from hathor.verification.vertex_verifier import VertexVerifier + + +class VertexVerifiers(NamedTuple): + """A group of verifier instances, one for each vertex type.""" + vertex: VertexVerifier + block: BlockVerifier + merge_mined_block: MergeMinedBlockVerifier + tx: TransactionVerifier + token_creation_tx: TokenCreationTransactionVerifier + + @classmethod + def create_defaults( + cls, + *, + settings: HathorSettings, + daa: DifficultyAdjustmentAlgorithm, + feature_service: FeatureService | None = None, + ) -> 'VertexVerifiers': + """ + Create a VertexVerifiers instance using the default verifier for each vertex type, + from all required dependencies. + """ + vertex_verifier = VertexVerifier(settings=settings, daa=daa) + + return cls.create( + settings=settings, + vertex_verifier=vertex_verifier, + daa=daa, + feature_service=feature_service + ) + + @classmethod + def create( + cls, + *, + settings: HathorSettings, + vertex_verifier: VertexVerifier, + daa: DifficultyAdjustmentAlgorithm, + feature_service: FeatureService | None = None, + ) -> 'VertexVerifiers': + """ + Create a VertexVerifiers instance using a custom vertex_verifier. + """ + block_verifier = BlockVerifier( + settings=settings, + vertex_verifier=vertex_verifier, + daa=daa, + feature_service=feature_service + ) + merge_mined_block_verifier = MergeMinedBlockVerifier() + tx_verifier = TransactionVerifier(settings=settings, vertex_verifier=vertex_verifier, daa=daa) + token_creation_tx_verifier = TokenCreationTransactionVerifier(settings=settings) + + return VertexVerifiers( + vertex=vertex_verifier, + block=block_verifier, + merge_mined_block=merge_mined_block_verifier, + tx=tx_verifier, + token_creation_tx=token_creation_tx_verifier, + ) diff --git a/tests/tx/test_block.py b/tests/tx/test_block.py index a363cfb78..39b397c7c 100644 --- a/tests/tx/test_block.py +++ b/tests/tx/test_block.py @@ -147,7 +147,7 @@ def test_verify_must_signal_when_feature_activation_is_disabled(is_signaling_man settings.FEATURE_ACTIVATION.enable_usage = False feature_service = Mock(spec_set=FeatureService) feature_service.is_signaling_mandatory_features = Mock(return_value=is_signaling_mandatory_features) - verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock()) + verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock(), vertex_verifier=Mock()) block = Block() verifier.verify_mandatory_signaling(block) @@ -160,7 +160,7 @@ def test_verify_must_signal() -> None: feature_service.is_signaling_mandatory_features = Mock( return_value=BlockIsMissingSignal(feature=Feature.NOP_FEATURE_1) ) - verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock()) + verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock(), vertex_verifier=Mock()) block = Block() with pytest.raises(BlockMustSignalError) as e: @@ -174,7 +174,7 @@ def test_verify_must_not_signal() -> None: settings.FEATURE_ACTIVATION.enable_usage = True feature_service = Mock(spec_set=FeatureService) feature_service.is_signaling_mandatory_features = Mock(return_value=BlockIsSignaling()) - verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock()) + verifier = BlockVerifier(settings=settings, feature_service=feature_service, daa=Mock(), vertex_verifier=Mock()) block = Block() verifier.verify_mandatory_signaling(block) diff --git a/tests/tx/test_genesis.py b/tests/tx/test_genesis.py index eecabd7fa..885395fa7 100644 --- a/tests/tx/test_genesis.py +++ b/tests/tx/test_genesis.py @@ -1,8 +1,9 @@ from hathor.conf import HathorSettings from hathor.daa import DifficultyAdjustmentAlgorithm, TestMode from hathor.transaction.storage import TransactionMemoryStorage -from hathor.verification.verification_service import VerificationService, VertexVerifiers +from hathor.verification.verification_service import VerificationService from hathor.verification.vertex_verifier import VertexVerifier +from hathor.verification.vertex_verifiers import VertexVerifiers from tests import unittest settings = HathorSettings() diff --git a/tests/tx/test_tx.py b/tests/tx/test_tx.py index 8e748b17c..439e70078 100644 --- a/tests/tx/test_tx.py +++ b/tests/tx/test_tx.py @@ -143,7 +143,7 @@ def test_too_many_outputs(self): tx = Transaction(outputs=outputs, storage=self.tx_storage) with self.assertRaises(TooManyOutputs): - self._verifiers.tx.verify_number_of_outputs(tx) + self._verifiers.vertex.verify_number_of_outputs(tx) def _gen_tx_spending_genesis_block(self): parents = [tx.hash for tx in self.genesis_txs] @@ -677,17 +677,17 @@ def test_tx_methods(self): self.assertFalse(tx_equal.is_genesis) # Pow error - self._verifiers.tx.verify_pow(tx2) + self._verifiers.vertex.verify_pow(tx2) tx2.weight = 100 with self.assertRaises(PowError): - self._verifiers.tx.verify_pow(tx2) + self._verifiers.vertex.verify_pow(tx2) # Verify parent timestamps - self._verifiers.tx.verify_parents(tx2) + self._verifiers.vertex.verify_parents(tx2) tx2_timestamp = tx2.timestamp tx2.timestamp = 2 with self.assertRaises(TimestampError): - self._verifiers.tx.verify_parents(tx2) + self._verifiers.vertex.verify_parents(tx2) tx2.timestamp = tx2_timestamp # Verify inputs timestamps @@ -701,10 +701,10 @@ def test_tx_methods(self): block = blocks[0] block2 = blocks[1] block2.timestamp = block.timestamp + self._settings.MAX_DISTANCE_BETWEEN_BLOCKS - self._verifiers.block.verify_parents(block2) + self._verifiers.vertex.verify_parents(block2) block2.timestamp += 1 with self.assertRaises(TimestampError): - self._verifiers.block.verify_parents(block2) + self._verifiers.vertex.verify_parents(block2) def test_block_big_nonce(self): block = self.genesis_blocks[0] @@ -1058,7 +1058,7 @@ def test_sigops_output_single_below_limit(self) -> None: output3 = TxOutput(value, hscript) tx = Transaction(inputs=[_input], outputs=[output3], storage=self.tx_storage) tx.update_hash() - self._verifiers.tx.verify_sigops_output(tx) + self._verifiers.vertex.verify_sigops_output(tx) def test_sigops_output_multi_below_limit(self) -> None: genesis_block = self.genesis_blocks[0] @@ -1070,7 +1070,7 @@ def test_sigops_output_multi_below_limit(self) -> None: output4 = TxOutput(value, hscript) tx = Transaction(inputs=[_input], outputs=[output4]*num_outputs, storage=self.tx_storage) tx.update_hash() - self._verifiers.tx.verify_sigops_output(tx) + self._verifiers.vertex.verify_sigops_output(tx) def test_sigops_input_single_above_limit(self) -> None: genesis_block = self.genesis_blocks[0] diff --git a/tests/tx/test_tx_deserialization.py b/tests/tx/test_tx_deserialization.py index c45603b54..4e878c802 100644 --- a/tests/tx/test_tx_deserialization.py +++ b/tests/tx/test_tx_deserialization.py @@ -1,7 +1,8 @@ from hathor.daa import DifficultyAdjustmentAlgorithm from hathor.transaction import Block, MergeMinedBlock, Transaction, TxVersion from hathor.transaction.token_creation_tx import TokenCreationTransaction -from hathor.verification.verification_service import VerificationService, VertexVerifiers +from hathor.verification.verification_service import VerificationService +from hathor.verification.vertex_verifiers import VertexVerifiers from tests import unittest diff --git a/tests/tx/test_verification.py b/tests/tx/test_verification.py index dea767b32..4ce4bfccb 100644 --- a/tests/tx/test_verification.py +++ b/tests/tx/test_verification.py @@ -24,6 +24,7 @@ from hathor.verification.merge_mined_block_verifier import MergeMinedBlockVerifier from hathor.verification.token_creation_transaction_verifier import TokenCreationTransactionVerifier from hathor.verification.transaction_verifier import TransactionVerifier +from hathor.verification.vertex_verifier import VertexVerifier from tests import unittest from tests.utils import add_blocks_unlock_reward, create_tokens, get_genesis_key @@ -122,23 +123,29 @@ def test_block_verify_basic(self) -> None: def test_block_verify_without_storage(self) -> None: block = self._get_valid_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.verify_without_storage(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -150,29 +157,35 @@ def test_block_verify_without_storage(self) -> None: def test_block_verify(self) -> None: block = self._get_valid_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) - verify_parents_wrapped = Mock(wraps=self.verifiers.block.verify_parents) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_height_wrapped = Mock(wraps=self.verifiers.block.verify_height) verify_mandatory_signaling_wrapped = Mock(wraps=self.verifiers.block.verify_mandatory_signaling) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), - patch.object(BlockVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(BlockVerifier, 'verify_height', verify_height_wrapped), patch.object(BlockVerifier, 'verify_mandatory_signaling', verify_mandatory_signaling_wrapped), ): self.manager.verification_service.verify(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -227,26 +240,29 @@ def test_block_validate_basic(self) -> None: def test_block_validate_full(self) -> None: block = self._get_valid_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) - verify_parents_wrapped = Mock(wraps=self.verifiers.block.verify_parents) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_height_wrapped = Mock(wraps=self.verifiers.block.verify_height) verify_weight_wrapped = Mock(wraps=self.verifiers.block.verify_weight) verify_reward_wrapped = Mock(wraps=self.verifiers.block.verify_reward) verify_mandatory_signaling_wrapped = Mock(wraps=self.verifiers.block.verify_mandatory_signaling) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), - patch.object(BlockVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(BlockVerifier, 'verify_height', verify_height_wrapped), patch.object(BlockVerifier, 'verify_weight', verify_weight_wrapped), patch.object(BlockVerifier, 'verify_reward', verify_reward_wrapped), @@ -254,6 +270,9 @@ def test_block_validate_full(self) -> None: ): self.manager.verification_service.validate_full(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -286,26 +305,32 @@ def test_merge_mined_block_verify_basic(self) -> None: def test_merge_mined_block_verify_without_storage(self) -> None: block = self._get_valid_merge_mined_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) verify_aux_pow_wrapped = Mock(wraps=self.verifiers.merge_mined_block.verify_aux_pow) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), patch.object(MergeMinedBlockVerifier, 'verify_aux_pow', verify_aux_pow_wrapped), ): self.manager.verification_service.verify_without_storage(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -320,32 +345,38 @@ def test_merge_mined_block_verify_without_storage(self) -> None: def test_merge_mined_block_verify(self) -> None: block = self._get_valid_merge_mined_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) - verify_parents_wrapped = Mock(wraps=self.verifiers.block.verify_parents) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_height_wrapped = Mock(wraps=self.verifiers.block.verify_height) verify_mandatory_signaling_wrapped = Mock(wraps=self.verifiers.block.verify_mandatory_signaling) verify_aux_pow_wrapped = Mock(wraps=self.verifiers.merge_mined_block.verify_aux_pow) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), - patch.object(BlockVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(BlockVerifier, 'verify_height', verify_height_wrapped), patch.object(BlockVerifier, 'verify_mandatory_signaling', verify_mandatory_signaling_wrapped), patch.object(MergeMinedBlockVerifier, 'verify_aux_pow', verify_aux_pow_wrapped), ): self.manager.verification_service.verify(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -403,13 +434,15 @@ def test_merge_mined_block_validate_basic(self) -> None: def test_merge_mined_block_validate_full(self) -> None: block = self._get_valid_merge_mined_block() - verify_pow_wrapped = Mock(wraps=self.verifiers.block.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_no_inputs_wrapped = Mock(wraps=self.verifiers.block.verify_no_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.block.verify_number_of_outputs) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) verify_data_wrapped = Mock(wraps=self.verifiers.block.verify_data) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.block.verify_sigops_output) - verify_parents_wrapped = Mock(wraps=self.verifiers.block.verify_parents) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_height_wrapped = Mock(wraps=self.verifiers.block.verify_height) verify_weight_wrapped = Mock(wraps=self.verifiers.block.verify_weight) verify_reward_wrapped = Mock(wraps=self.verifiers.block.verify_reward) @@ -418,13 +451,14 @@ def test_merge_mined_block_validate_full(self) -> None: verify_aux_pow_wrapped = Mock(wraps=self.verifiers.merge_mined_block.verify_aux_pow) with ( - patch.object(BlockVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(BlockVerifier, 'verify_no_inputs', verify_no_inputs_wrapped), patch.object(BlockVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(BlockVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), patch.object(BlockVerifier, 'verify_data', verify_data_wrapped), - patch.object(BlockVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), - patch.object(BlockVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(BlockVerifier, 'verify_height', verify_height_wrapped), patch.object(BlockVerifier, 'verify_weight', verify_weight_wrapped), patch.object(BlockVerifier, 'verify_reward', verify_reward_wrapped), @@ -433,6 +467,9 @@ def test_merge_mined_block_validate_full(self) -> None: ): self.manager.verification_service.validate_full(block) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Block methods verify_pow_wrapped.assert_called_once() verify_no_inputs_wrapped.assert_called_once() @@ -452,25 +489,31 @@ def test_merge_mined_block_validate_full(self) -> None: def test_transaction_verify_basic(self) -> None: tx = self._get_valid_tx() + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.verify_basic(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once() @@ -483,21 +526,27 @@ def test_transaction_verify_basic(self) -> None: def test_transaction_verify_without_storage(self) -> None: tx = self._get_valid_tx() - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.verify_without_storage(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_pow_wrapped.assert_called_once() verify_number_of_inputs_wrapped.assert_called_once() @@ -509,33 +558,39 @@ def test_transaction_verify(self) -> None: add_blocks_unlock_reward(self.manager) tx = self._get_valid_tx() - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) verify_sigops_input_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_input) verify_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_inputs) verify_script_wrapped = Mock(wraps=self.verifiers.tx.verify_script) - verify_parents_wrapped = Mock(wraps=self.verifiers.tx.verify_parents) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_sum_wrapped = Mock(wraps=self.verifiers.tx.verify_sum) verify_reward_locked_wrapped = Mock(wraps=self.verifiers.tx.verify_reward_locked) with ( - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), patch.object(TransactionVerifier, 'verify_sigops_input', verify_sigops_input_wrapped), patch.object(TransactionVerifier, 'verify_inputs', verify_inputs_wrapped), patch.object(TransactionVerifier, 'verify_script', verify_script_wrapped), - patch.object(TransactionVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(TransactionVerifier, 'verify_sum', verify_sum_wrapped), patch.object(TransactionVerifier, 'verify_reward_locked', verify_reward_locked_wrapped), ): self.manager.verification_service.verify(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_pow_wrapped.assert_called_once() verify_number_of_inputs_wrapped.assert_called_once() @@ -554,25 +609,31 @@ def test_transaction_validate_basic(self) -> None: add_blocks_unlock_reward(self.manager) tx = self._get_valid_tx() + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.validate_basic(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once() @@ -592,20 +653,20 @@ def test_transaction_validate_basic(self) -> None: # and if running basic validation again it shouldn't validate or change the validation state verify_parents_basic_wrapped2 = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped2 = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped2 = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped2), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped2), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped2), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped2), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped2), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), ): self.manager.verification_service.validate_basic(tx) @@ -625,37 +686,43 @@ def test_transaction_validate_full(self) -> None: add_blocks_unlock_reward(self.manager) tx = self._get_valid_tx() + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) verify_sigops_input_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_input) verify_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_inputs) verify_script_wrapped = Mock(wraps=self.verifiers.tx.verify_script) - verify_parents_wrapped = Mock(wraps=self.verifiers.tx.verify_parents) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_sum_wrapped = Mock(wraps=self.verifiers.tx.verify_sum) verify_reward_locked_wrapped = Mock(wraps=self.verifiers.tx.verify_reward_locked) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), patch.object(TransactionVerifier, 'verify_sigops_input', verify_sigops_input_wrapped), patch.object(TransactionVerifier, 'verify_inputs', verify_inputs_wrapped), patch.object(TransactionVerifier, 'verify_script', verify_script_wrapped), - patch.object(TransactionVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(TransactionVerifier, 'verify_sum', verify_sum_wrapped), patch.object(TransactionVerifier, 'verify_reward_locked', verify_reward_locked_wrapped), ): self.manager.verification_service.validate_full(tx) + # Vertex methods + assert vertex_verify_outputs_wrapped.call_count == 2 + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once() @@ -677,20 +744,20 @@ def test_transaction_validate_full(self) -> None: # and if running full validation again it shouldn't validate or change the validation state verify_parents_basic_wrapped2 = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped2 = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped2 = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped2), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped2), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped2), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped2), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped2), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), ): self.manager.verification_service.validate_basic(tx) @@ -709,25 +776,31 @@ def test_transaction_validate_full(self) -> None: def test_token_creation_transaction_verify_basic(self) -> None: tx = self._get_valid_token_creation_tx() + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.verify_basic(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once() @@ -740,21 +813,27 @@ def test_token_creation_transaction_verify_basic(self) -> None: def test_token_creation_transaction_verify_without_storage(self) -> None: tx = self._get_valid_token_creation_tx() - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.verify_without_storage(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_pow_wrapped.assert_called_once() verify_number_of_inputs_wrapped.assert_called_once() @@ -765,15 +844,17 @@ def test_token_creation_transaction_verify_without_storage(self) -> None: def test_token_creation_transaction_verify(self) -> None: tx = self._get_valid_token_creation_tx() - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) verify_sigops_input_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_input) verify_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_inputs) verify_script_wrapped = Mock(wraps=self.verifiers.tx.verify_script) - verify_parents_wrapped = Mock(wraps=self.verifiers.tx.verify_parents) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_sum_wrapped = Mock(wraps=self.verifiers.tx.verify_sum) verify_reward_locked_wrapped = Mock(wraps=self.verifiers.tx.verify_reward_locked) @@ -781,15 +862,16 @@ def test_token_creation_transaction_verify(self) -> None: verify_minted_tokens_wrapped = Mock(wraps=self.verifiers.token_creation_tx.verify_minted_tokens) with ( - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), patch.object(TransactionVerifier, 'verify_sigops_input', verify_sigops_input_wrapped), patch.object(TransactionVerifier, 'verify_inputs', verify_inputs_wrapped), patch.object(TransactionVerifier, 'verify_script', verify_script_wrapped), - patch.object(TransactionVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(TransactionVerifier, 'verify_sum', verify_sum_wrapped), patch.object(TransactionVerifier, 'verify_reward_locked', verify_reward_locked_wrapped), patch.object(TokenCreationTransactionVerifier, 'verify_token_info', verify_token_info_wrapped), @@ -797,6 +879,9 @@ def test_token_creation_transaction_verify(self) -> None: ): self.manager.verification_service.verify(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_pow_wrapped.assert_called_once() verify_number_of_inputs_wrapped.assert_called_once() @@ -818,25 +903,31 @@ def test_token_creation_transaction_validate_basic(self) -> None: tx = self._get_valid_token_creation_tx() tx.get_metadata().validation = ValidationState.INITIAL + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), ): self.manager.verification_service.validate_basic(tx) + # Vertex methods + vertex_verify_outputs_wrapped.assert_called_once() + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once() @@ -856,20 +947,20 @@ def test_token_creation_transaction_validate_basic(self) -> None: # and if running basic validation again it shouldn't validate or change the validation state verify_parents_basic_wrapped2 = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped2 = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped2 = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped2 = Mock(wraps=self.verifiers.vertex.verify_sigops_output) with ( patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped2), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped2), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped2), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped2), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped2), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped2), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped2), ): self.manager.verification_service.validate_basic(tx) @@ -889,17 +980,19 @@ def test_token_creation_transaction_validate_full(self) -> None: tx = self._get_valid_token_creation_tx() tx.get_metadata().validation = ValidationState.INITIAL + vertex_verify_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_outputs) + verify_parents_basic_wrapped = Mock(wraps=self.verifiers.tx.verify_parents_basic) verify_weight_wrapped = Mock(wraps=self.verifiers.tx.verify_weight) - verify_pow_wrapped = Mock(wraps=self.verifiers.tx.verify_pow) + verify_pow_wrapped = Mock(wraps=self.verifiers.vertex.verify_pow) verify_number_of_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_inputs) verify_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_outputs) - verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.tx.verify_number_of_outputs) - verify_sigops_output_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_output) + verify_number_of_outputs_wrapped = Mock(wraps=self.verifiers.vertex.verify_number_of_outputs) + verify_sigops_output_wrapped = Mock(wraps=self.verifiers.vertex.verify_sigops_output) verify_sigops_input_wrapped = Mock(wraps=self.verifiers.tx.verify_sigops_input) verify_inputs_wrapped = Mock(wraps=self.verifiers.tx.verify_inputs) verify_script_wrapped = Mock(wraps=self.verifiers.tx.verify_script) - verify_parents_wrapped = Mock(wraps=self.verifiers.tx.verify_parents) + verify_parents_wrapped = Mock(wraps=self.verifiers.vertex.verify_parents) verify_sum_wrapped = Mock(wraps=self.verifiers.tx.verify_sum) verify_reward_locked_wrapped = Mock(wraps=self.verifiers.tx.verify_reward_locked) @@ -907,17 +1000,18 @@ def test_token_creation_transaction_validate_full(self) -> None: verify_minted_tokens_wrapped = Mock(wraps=self.verifiers.token_creation_tx.verify_minted_tokens) with ( + patch.object(VertexVerifier, 'verify_outputs', vertex_verify_outputs_wrapped), patch.object(TransactionVerifier, 'verify_parents_basic', verify_parents_basic_wrapped), patch.object(TransactionVerifier, 'verify_weight', verify_weight_wrapped), - patch.object(TransactionVerifier, 'verify_pow', verify_pow_wrapped), + patch.object(VertexVerifier, 'verify_pow', verify_pow_wrapped), patch.object(TransactionVerifier, 'verify_number_of_inputs', verify_number_of_inputs_wrapped), patch.object(TransactionVerifier, 'verify_outputs', verify_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), - patch.object(TransactionVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), + patch.object(VertexVerifier, 'verify_number_of_outputs', verify_number_of_outputs_wrapped), + patch.object(VertexVerifier, 'verify_sigops_output', verify_sigops_output_wrapped), patch.object(TransactionVerifier, 'verify_sigops_input', verify_sigops_input_wrapped), patch.object(TransactionVerifier, 'verify_inputs', verify_inputs_wrapped), patch.object(TransactionVerifier, 'verify_script', verify_script_wrapped), - patch.object(TransactionVerifier, 'verify_parents', verify_parents_wrapped), + patch.object(VertexVerifier, 'verify_parents', verify_parents_wrapped), patch.object(TransactionVerifier, 'verify_sum', verify_sum_wrapped), patch.object(TransactionVerifier, 'verify_reward_locked', verify_reward_locked_wrapped), patch.object(TokenCreationTransactionVerifier, 'verify_token_info', verify_token_info_wrapped), @@ -925,6 +1019,9 @@ def test_token_creation_transaction_validate_full(self) -> None: ): self.manager.verification_service.validate_full(tx) + # Vertex methods + assert vertex_verify_outputs_wrapped.call_count == 2 + # Transaction methods verify_parents_basic_wrapped.assert_called_once() verify_weight_wrapped.assert_called_once()