From f6cb3ad0161d71ddd0a0d80ca56d06d170a8810c Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Fri, 28 May 2021 21:15:03 +0300 Subject: [PATCH] Fix bug in test_send_broadcast() - using temporary msgid for lookups. Wait for final msgid. Maximum PoW wait time is 30 sec. --- src/tests/test_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tests/test_api.py b/src/tests/test_api.py index 8069d160..413075a6 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -276,6 +276,7 @@ class TestAPI(TestAPIProto): msg = base64.encodestring('test broadcast') ackdata = self.api.sendBroadcast( addr, base64.encodestring('test_subject'), msg) + try: int(ackdata, 16) status = self.api.getStatus(ackdata) @@ -283,6 +284,15 @@ class TestAPI(TestAPIProto): raise KeyError self.assertIn(status, ( 'doingbroadcastpow', 'broadcastqueued', 'broadcastsent')) + + start = time.time() + while status == 'doingbroadcastpow': + spent = int(time.time() - start) + if spent > 30: + self.fail('PoW is taking too much time: %ss' % spent) + time.sleep(1) # wait for PoW to get final msgid on next step + status = self.api.getStatus(ackdata) + # Find the message and its ID in sent for m in json.loads(self.api.getAllSentMessages())['sentMessages']: if m['ackData'] == ackdata: