Browse Source

tests: fix warnings in test_network.py

```
electrum/tests/test_network.py::TestNetwork::test_can_connect_during_backward
electrum/tests/test_network.py::TestNetwork::test_chain_false_during_binary
electrum/tests/test_network.py::TestNetwork::test_fork_conflict
electrum/tests/test_network.py::TestNetwork::test_fork_noconflict
  /tmp/cirrus-ci-build/electrum/interface.py:410: RuntimeWarning: coroutine 'Interface.run' was never awaited
    task = await self.network.taskgroup.spawn(self.run())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
```

closes https://github.com/spesmilo/electrum/pull/7817
master
SomberNight 2 years ago
parent
commit
c3562c00e6
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/tests/test_network.py

12
electrum/tests/test_network.py

@ -7,19 +7,18 @@ from electrum.simple_config import SimpleConfig
from electrum import blockchain
from electrum.interface import Interface, ServerAddr
from electrum.crypto import sha256
from electrum.util import OldTaskGroup
from electrum import util
from . import ElectrumTestCase
class MockTaskGroup:
async def spawn(self, x): return
class MockNetwork:
taskgroup = MockTaskGroup()
def __init__(self):
self.asyncio_loop = util.get_asyncio_loop()
self.taskgroup = OldTaskGroup()
class MockInterface(Interface):
def __init__(self, config):
@ -32,6 +31,7 @@ class MockInterface(Interface):
parent=None, forkpoint_hash=constants.net.GENESIS, prev_hash=None)
self.tip = 12
self.blockchain._size = self.tip + 1
async def get_block_header(self, height, assert_mode):
assert self.q.qsize() > 0, (height, assert_mode)
item = await self.q.get()
@ -40,6 +40,10 @@ class MockInterface(Interface):
assert assert_mode in item['mock'], (assert_mode, item)
return item
async def run(self):
return
class TestNetwork(ElectrumTestCase):
@classmethod

Loading…
Cancel
Save