From 6c85bdd4981d9f468d38f52d15a20fad3e3f0bff Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 13 Feb 2019 12:25:28 +0200 Subject: [PATCH] Also check sent broadcast status and it's presence in sent messages --- src/tests/test_api.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/tests/test_api.py b/src/tests/test_api.py index 0c0cad95..d94878eb 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -157,14 +157,28 @@ class TestAPI(TestAPIProto): def test_send_broadcast(self): """API command 'sendBroadcast': ensure it returns ackData""" addr = self._add_random_address('random_2') - ack = self.api.sendBroadcast( - addr, base64.encodestring('test_subject'), - base64.encodestring('test message') - ) + msg = base64.encodestring('test message') + ackdata = self.api.sendBroadcast( + addr, base64.encodestring('test_subject'), msg) try: - int(ack, 16) + int(ackdata, 16) + status = self.api.getStatus(ackdata) + if status == 'notfound': + raise KeyError + self.assertIn( + status, ('broadcastqueued', 'broadcastsent', 'doingmsgpow')) + for m in json.loads(self.api.getAllSentMessages())['sentMessages']: + if m['ackData'] == ackdata: + sent_msg = m['message'] + break + else: + raise KeyError except ValueError: self.fail('sendBroadcast returned error or ackData is not hex') + except KeyError: + self.fail('Could not find sent broadcast in sent messages') + else: + self.assertEqual(sent_msg, msg.strip()) finally: self.assertEqual(self.api.deleteAddress(addr), 'success')