Fix bug in test_send_broadcast() - using temporary msgid for lookups.

Wait for final msgid. Maximum PoW wait time is 30 sec.
This commit is contained in:
Dmitri Bogomolov 2021-05-28 21:15:03 +03:00
parent b83c3f42d2
commit f6cb3ad016
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -276,6 +276,7 @@ class TestAPI(TestAPIProto):
msg = base64.encodestring('test broadcast') msg = base64.encodestring('test broadcast')
ackdata = self.api.sendBroadcast( ackdata = self.api.sendBroadcast(
addr, base64.encodestring('test_subject'), msg) addr, base64.encodestring('test_subject'), msg)
try: try:
int(ackdata, 16) int(ackdata, 16)
status = self.api.getStatus(ackdata) status = self.api.getStatus(ackdata)
@ -283,6 +284,15 @@ class TestAPI(TestAPIProto):
raise KeyError raise KeyError
self.assertIn(status, ( self.assertIn(status, (
'doingbroadcastpow', 'broadcastqueued', 'broadcastsent')) '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 # Find the message and its ID in sent
for m in json.loads(self.api.getAllSentMessages())['sentMessages']: for m in json.loads(self.api.getAllSentMessages())['sentMessages']:
if m['ackData'] == ackdata: if m['ackData'] == ackdata: