From 9016c36df06ff9bed482bbd15a614f3a853e9c7e Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 9 Jun 2025 15:46:02 +0000 Subject: [PATCH] tests: test_network.py: rm test_fork_conflict, no longer applicable Just prior to this commit, test_fork_conflict and test_fork_noconflict were essentially identical copies. The only diff was that test_fork_conflict set the global blockchain.blockchains, but this was not even affecting its behaviour anymore. Originally when this test was added, we had the concept of chain fork conflicting with each other: we could not handle three-way chain-splits. As in, there could only be a single fork forking away from the main chain at any given height. see https://github.com/spesmilo/electrum/commit/7221fb3231a736dc5d3ebd5ed5e0723c9b8203f2 However, this restriction was removed and generalised later: https://github.com/spesmilo/electrum/commit/141ff99580192c920bc6bb7f6bbc9d35449daea8 After which the "test_fork_conflict" test did not make sense anymore. --- tests/test_network.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/tests/test_network.py b/tests/test_network.py index 4ff5132c9..0ea825b69 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -67,7 +67,7 @@ class TestNetwork(ElectrumTestCase): self.config = SimpleConfig({'electrum_path': self.electrum_path}) self.interface = MockInterface(self.config) - async def test_fork_noconflict(self): + async def test_fork(self): blockchain.blockchains = {} self.interface.q.put_nowait({'block_height': 8, 'mock': {CRM.CATCHUP:1, 'check': lambda x: False, 'connect': lambda x: False}}) def mock_connect(height): @@ -82,21 +82,6 @@ class TestNetwork(ElectrumTestCase): self.assertEqual((CRM.FORK, 8), res) self.assertEqual(self.interface.q.qsize(), 0) - async def test_fork_conflict(self): - blockchain.blockchains = {7: {'check': lambda bad_header: False}} - self.interface.q.put_nowait({'block_height': 8, 'mock': {CRM.CATCHUP:1, 'check': lambda x: False, 'connect': lambda x: False}}) - def mock_connect(height): - return height == 6 - self.interface.q.put_nowait({'block_height': 7, 'mock': {CRM.BACKWARD:1,'check': lambda x: False, 'connect': mock_connect, 'fork': self.mock_fork}}) - self.interface.q.put_nowait({'block_height': 2, 'mock': {CRM.BACKWARD:1,'check':lambda x: True, 'connect': lambda x: False}}) - self.interface.q.put_nowait({'block_height': 4, 'mock': {CRM.BINARY:1,'check':lambda x: True, 'connect': lambda x: True}}) - self.interface.q.put_nowait({'block_height': 5, 'mock': {CRM.BINARY:1,'check':lambda x: True, 'connect': lambda x: True}}) - self.interface.q.put_nowait({'block_height': 6, 'mock': {CRM.BINARY:1,'check':lambda x: True, 'connect': lambda x: True}}) - ifa = self.interface - res = await ifa.sync_until(8, next_height=7) - self.assertEqual((CRM.FORK, 8), res) - self.assertEqual(self.interface.q.qsize(), 0) - async def test_can_connect_during_backward(self): blockchain.blockchains = {} self.interface.q.put_nowait({'block_height': 8, 'mock': {CRM.CATCHUP:1, 'check': lambda x: False, 'connect': lambda x: False}})