Skip to content

Commit 325b83b

Browse files
committed
tests: interface: add timeout to avoid hangs
instead of an infinite hang, the unit test should just fail
1 parent 0a414ad commit 325b83b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_interface.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import collections
3-
from typing import Optional, Sequence, Iterable
3+
from typing import Optional, Sequence, Iterable, Mapping
44

55
import aiorpcx
66
from aiorpcx import RPCError
@@ -99,7 +99,7 @@ def get_local_height(self) -> int:
9999

100100

101101
# regtest chain:
102-
BLOCK_HEADERS = {
102+
BLOCK_HEADERS: Mapping[int, bytes] = {
103103
0: bfh("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000"),
104104
1: bfh("0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f186c8dfd970a4545f79916bc1d75c9d00432f57c89209bf3bb115b7612848f509c25f45bffff7f2000000000"),
105105
2: bfh("00000020686bdfc6a3db73d5d93e8c9663a720a26ecb1ef20eb05af11b36cdbc57c19f7ebf2cbf153013a1c54abaf70e95198fcef2f3059cc6b4d0f7e876808e7d24d11cc825f45bffff7f2000000000"),
@@ -333,8 +333,9 @@ async def asyncTearDown(self):
333333
async def _start_iface_and_wait_for_sync(self):
334334
interface = Interface(network=self.network, server=ServerAddr(host="127.0.0.1", port=self._server_port, protocol="t"))
335335
self.network.interface = interface
336-
await util.wait_for2(interface.ready, 5)
337-
await interface._blockchain_updated.wait()
336+
async with util.async_timeout(5):
337+
await interface.ready
338+
await interface._blockchain_updated.wait()
338339
return interface
339340

340341
async def test_client_syncs_headers_to_tip(self):

0 commit comments

Comments
 (0)