Skip to content

Commit

Permalink
refactor: remove multi-sync test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jansegre committed Dec 23, 2024
1 parent 4eb58dd commit 745f933
Show file tree
Hide file tree
Showing 91 changed files with 175 additions and 2,021 deletions.
17 changes: 1 addition & 16 deletions tests/cli/test_multisig_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
from tests.utils import add_blocks_unlock_reward, add_new_transactions


class BaseSignatureTest(unittest.TestCase):
__test__ = False

class SignatureTest(unittest.TestCase):
def setUp(self):
super().setUp()

Expand Down Expand Up @@ -61,16 +59,3 @@ def test_generate_signature(self):
data_to_sign = tx.get_sighash_all()
hashed_data = hashlib.sha256(data_to_sign).digest()
self.assertIsNone(public_key.verify(signature, hashed_data, ec.ECDSA(hashes.SHA256())))


class SyncV1SignatureTest(unittest.SyncV1Params, BaseSignatureTest):
pass


class SyncV2SignatureTest(unittest.SyncV2Params, BaseSignatureTest):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeSignatureTest(unittest.SyncBridgeParams, SyncV2SignatureTest):
pass
17 changes: 1 addition & 16 deletions tests/cli/test_multisig_spend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
from tests.utils import add_blocks_unlock_reward


class BaseMultiSigSpendTest(unittest.TestCase):
__test__ = False

class MultiSigSpendTest(unittest.TestCase):
def setUp(self):
super().setUp()

Expand Down Expand Up @@ -121,16 +119,3 @@ def test_spend_multisig(self):

tx = Transaction.create_from_struct(bytes.fromhex(tx_raw))
self.assertTrue(self.manager.propagate_tx(tx, False))


class SyncV1MultiSigSpendTest(unittest.SyncV1Params, BaseMultiSigSpendTest):
pass


class SyncV2MultiSigSpendTest(unittest.SyncV2Params, BaseMultiSigSpendTest):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeMultiSigSpendTest(unittest.SyncBridgeParams, SyncV2MultiSigSpendTest):
pass
17 changes: 1 addition & 16 deletions tests/cli/test_twin_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
)


class BaseTwinTxTest(unittest.TestCase):
__test__ = False

class TwinTxTest(unittest.TestCase):
def setUp(self):
super().setUp()

Expand Down Expand Up @@ -167,16 +165,3 @@ def test_parameter_error(self):
output = f.getvalue().strip().splitlines()

self.assertEqual('The command expects raw_tx or hash and url as parameters', output[0])


class SyncV1TwinTxTest(unittest.SyncV1Params, BaseTwinTxTest):
pass


class SyncV2TwinTxTest(unittest.SyncV2Params, BaseTwinTxTest):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeTwinTxTest(unittest.SyncBridgeParams, SyncV2TwinTxTest):
pass
17 changes: 1 addition & 16 deletions tests/consensus/test_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from tests.utils import add_blocks_unlock_reward, add_new_double_spending, add_new_transactions


class BaseConsensusTestCase(unittest.TestCase):
__test__ = False

class ConsensusTestCase(unittest.TestCase):
def setUp(self) -> None:
super().setUp()
self.tx_storage = TransactionMemoryStorage(settings=self._settings)
Expand Down Expand Up @@ -269,16 +267,3 @@ def test_dont_revert_block_high_weight_verify_both(self) -> None:
self.assertIsNone(meta.voided_by)

self.assertConsensusValid(manager)


class SyncV1ConsensusTestCase(unittest.SyncV1Params, BaseConsensusTestCase):
pass


class SyncV2ConsensusTestCase(unittest.SyncV2Params, BaseConsensusTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeConsensusTestCase(unittest.SyncBridgeParams, SyncV2ConsensusTestCase):
pass
16 changes: 1 addition & 15 deletions tests/consensus/test_consensus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
from hathor.simulator.utils import gen_new_tx
from hathor.transaction import Transaction
from hathor.util import not_none
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import add_custom_tx


class BaseConsensusSimulatorTestCase(SimulatorTestCase):
class ConsensusSimulatorTestCase(SimulatorTestCase):
def checkConflict(self, tx1: Transaction, tx2: Transaction) -> None:
meta1 = tx1.get_metadata()
meta2 = tx2.get_metadata()
Expand Down Expand Up @@ -130,16 +129,3 @@ def test_two_conflicts_intertwined_multiple_times(self) -> None:
# Uncomment lines below to visualize the DAG and the blockchain.
# dot = self.graphviz.dot()
# dot.render('dot0')


class SyncV1ConsensusSimulatorTestCase(unittest.SyncV1Params, BaseConsensusSimulatorTestCase):
pass


class SyncV2ConsensusSimulatorTestCase(unittest.SyncV2Params, BaseConsensusSimulatorTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeConsensusSimulatorTestCase(unittest.SyncBridgeParams, SyncV2ConsensusSimulatorTestCase):
pass
17 changes: 1 addition & 16 deletions tests/consensus/test_consensus4.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
from hathor.manager import HathorManager
from hathor.transaction import Block
from hathor.types import VertexId
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import gen_custom_tx


class BaseConsensusSimulatorTestCase(SimulatorTestCase):

class ConsensusSimulatorTestCase(SimulatorTestCase):
def create_chain(
self,
manager: HathorManager,
Expand Down Expand Up @@ -82,16 +80,3 @@ def test_conflict_with_parent_tx(self) -> None:
# Uncomment lines below to visualize the DAG and the blockchain.
# dot = self.graphviz.dot()
# dot.render('dot0')


class SyncV1ConsensusSimulatorTestCase(unittest.SyncV1Params, BaseConsensusSimulatorTestCase):
pass


class SyncV2ConsensusSimulatorTestCase(unittest.SyncV2Params, BaseConsensusSimulatorTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeConsensusSimulatorTestCase(unittest.SyncBridgeParams, SyncV2ConsensusSimulatorTestCase):
pass
17 changes: 1 addition & 16 deletions tests/consensus/test_consensus5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
from hathor.manager import HathorManager
from hathor.transaction import Block
from hathor.types import VertexId
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import gen_custom_tx


class BaseConsensusSimulatorTestCase(SimulatorTestCase):

class ConsensusSimulatorTestCase(SimulatorTestCase):
def create_chain(
self,
manager: HathorManager,
Expand Down Expand Up @@ -84,16 +82,3 @@ def test_conflict_with_parent_tx(self) -> None:
# Uncomment lines below to visualize the DAG and the blockchain.
# dot = self.graphviz.dot()
# dot.render('dot0')


class SyncV1ConsensusSimulatorTestCase(unittest.SyncV1Params, BaseConsensusSimulatorTestCase):
pass


class SyncV2ConsensusSimulatorTestCase(unittest.SyncV2Params, BaseConsensusSimulatorTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeConsensusSimulatorTestCase(unittest.SyncBridgeParams, SyncV2ConsensusSimulatorTestCase):
pass
16 changes: 1 addition & 15 deletions tests/consensus/test_soft_voided.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from hathor.simulator.utils import gen_new_tx
from hathor.transaction import Block
from hathor.types import VertexId
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import add_custom_tx


class BaseSoftVoidedTestCase(SimulatorTestCase):
class SoftVoidedTestCase(SimulatorTestCase):
seed_config = 5988775361793628170

def assertNoParentsAreSoftVoided(self, tx: Block) -> None:
Expand Down Expand Up @@ -156,16 +155,3 @@ def test_soft_voided(self) -> None:
])
for _ in self._run_test(self.simulator, soft_voided_tx_ids):
pass


class SyncV1SoftVoidedTestCase(unittest.SyncV1Params, BaseSoftVoidedTestCase):
pass


class SyncV2SoftVoidedTestCase(unittest.SyncV2Params, BaseSoftVoidedTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeSoftVoidedTestCase(unittest.SyncBridgeParams, SyncV2SoftVoidedTestCase):
pass
16 changes: 1 addition & 15 deletions tests/consensus/test_soft_voided2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
from hathor.transaction import Block, Transaction
from hathor.types import VertexId
from hathor.wallet import HDWallet
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import BURN_ADDRESS, add_custom_tx


class BaseConsensusSimulatorTestCase(SimulatorTestCase):
class ConsensusSimulatorTestCase(SimulatorTestCase):
seed_config = 5988775361793628169

def assertValidConflictResolution(self, tx1: Transaction, tx2: Transaction) -> None:
Expand Down Expand Up @@ -209,16 +208,3 @@ def test_soft_voided(self) -> None:
self.assertEqual(10, len(soft_voided_tx_ids))
for _ in self._run_test(self.simulator, soft_voided_tx_ids):
pass


class SyncV1ConsensusSimulatorTestCase(unittest.SyncV1Params, BaseConsensusSimulatorTestCase):
pass


class SyncV2ConsensusSimulatorTestCase(unittest.SyncV2Params, BaseConsensusSimulatorTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeConsensusSimulatorTestCase(unittest.SyncBridgeParams, SyncV2ConsensusSimulatorTestCase):
pass
16 changes: 1 addition & 15 deletions tests/consensus/test_soft_voided3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from hathor.simulator.utils import gen_new_tx
from hathor.transaction import BaseTransaction
from hathor.types import VertexId
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import add_custom_tx, gen_custom_tx


class BaseSoftVoidedTestCase(SimulatorTestCase):
class SoftVoidedTestCase(SimulatorTestCase):
seed_config = 5988775361793628169

def assertNoParentsAreSoftVoided(self, tx: BaseTransaction) -> None:
Expand Down Expand Up @@ -138,16 +137,3 @@ def test_soft_voided(self) -> None:
])
for _ in self._run_test(self.simulator, soft_voided_tx_ids):
pass


class SyncV1SoftVoidedTestCase(unittest.SyncV1Params, BaseSoftVoidedTestCase):
pass


class SyncV2SoftVoidedTestCase(unittest.SyncV2Params, BaseSoftVoidedTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeSoftVoidedTestCase(unittest.SyncBridgeParams, SyncV2SoftVoidedTestCase):
pass
16 changes: 1 addition & 15 deletions tests/consensus/test_soft_voided4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from hathor.simulator.utils import gen_new_double_spending
from hathor.transaction import Transaction
from hathor.types import VertexId
from tests import unittest
from tests.simulation.base import SimulatorTestCase
from tests.utils import add_custom_tx


class BaseSoftVoidedTestCase(SimulatorTestCase):
class SoftVoidedTestCase(SimulatorTestCase):
seed_config = 5988775361793628169

def _run_test(
Expand Down Expand Up @@ -173,16 +172,3 @@ def test_soft_voided(self) -> None:
]
for _ in self._run_test(self.simulator, soft_voided_tx_ids):
pass


class SyncV1SoftVoidedTestCase(unittest.SyncV1Params, BaseSoftVoidedTestCase):
pass


class SyncV2SoftVoidedTestCase(unittest.SyncV2Params, BaseSoftVoidedTestCase):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeSoftVoidedTestCase(unittest.SyncBridgeParams, SyncV2SoftVoidedTestCase):
pass
17 changes: 1 addition & 16 deletions tests/event/test_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from tests import unittest


class BaseEventManagerTest(unittest.TestCase):
__test__ = False

class EventManagerTest(unittest.TestCase):
def setUp(self) -> None:
super().setUp()
self.network = 'testnet'
Expand Down Expand Up @@ -86,16 +84,3 @@ def test_cannot_finish_group_twice(self) -> None:
with self.assertRaises(AssertionError):
self._fake_reorg_finished()
self.run_to_completion()


class SyncV1EventManager(unittest.SyncV1Params, BaseEventManagerTest):
pass


class SyncV2EventManager(unittest.SyncV1Params, BaseEventManagerTest):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeEventManagerTest(unittest.SyncBridgeParams, SyncV2EventManager):
pass
17 changes: 1 addition & 16 deletions tests/event/test_event_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from tests.utils import BURN_ADDRESS, get_genesis_key


class BaseEventReorgTest(unittest.TestCase):
__test__ = False

class EventReorgTest(unittest.TestCase):
def setUp(self) -> None:
super().setUp()
self.network = 'testnet'
Expand Down Expand Up @@ -87,16 +85,3 @@ def test_reorg_events(self) -> None:

for expected_data_key, expected_data_value in expected_partial_data.items():
self.assertEqual(actual_event.data.dict()[expected_data_key], expected_data_value)


class SyncV1EventReorgTest(unittest.SyncV1Params, BaseEventReorgTest):
pass


class SyncV2EventReorgTest(unittest.SyncV1Params, BaseEventReorgTest):
pass


# sync-bridge should behave like sync-v2
class SyncBridgeEventReorgTest(unittest.SyncBridgeParams, SyncV2EventReorgTest):
pass
Loading

0 comments on commit 745f933

Please sign in to comment.