From a540fac7f859414bfdf568efbfdbebd067516de9 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Sun, 29 Sep 2024 04:55:28 +0300 Subject: [PATCH] Update test object for new Object structure --- minode/tests/test_structure.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/minode/tests/test_structure.py b/minode/tests/test_structure.py index c6d7eb2..0d35275 100644 --- a/minode/tests/test_structure.py +++ b/minode/tests/test_structure.py @@ -18,11 +18,12 @@ sample_addr_data = unhexlify( '260753000201300000000000000057ae1f90') # data for an object with expires_time 1697063939 -# structure.Object( -# b'\x00' * 8, expires_time, 42, 1, 2, b'HELLO').to_bytes() +# structure.Object(expires_time, 42, 1, 2, object_payload=b'HELLO').data sample_object_data = unhexlify( '000000000000000000000000652724030000002a010248454c4c4f') +sample_object_expires = 1697063939 + logging.basicConfig( level=shared.log_level, format='[%(asctime)s] [%(levelname)s] %(message)s') @@ -131,9 +132,16 @@ class TestStructure(unittest.TestCase): message.Message(b'object', sample_object_data)) self.assertEqual(obj.object_type, 42) self.assertEqual(obj.stream_number, 2) - self.assertEqual(obj.expires_time, 1697063939) + self.assertEqual(obj.expires_time, sample_object_expires) self.assertEqual(obj.object_payload, b'HELLO') + obj = structure.Object( + sample_object_expires, 42, 1, 2, object_payload=b'HELLO') + self.assertEqual(obj.data, sample_object_data) + self.assertEqual(obj.offset, 22) + self.assertEqual(obj.nonce, b'\x00' * 8) + self.assertTrue(obj.is_expired()) + obj = structure.Object( int(time.time() + 3000000), 42, 1, 1, object_payload=b'HELLO') self.assertFalse(obj.is_valid())