From 79aedd1bb54af4ed950709b9503c1f6c7ac662bc Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Mon, 9 Sep 2024 00:29:55 +0300 Subject: [PATCH] Update test object for the new Object structure, comment outdated setting object_payload --- minode/tests/test_structure.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/minode/tests/test_structure.py b/minode/tests/test_structure.py index c45d2d4..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()) @@ -151,9 +159,10 @@ class TestStructure(unittest.TestCase): shared.stream = 2 self.assertTrue(obj.is_valid()) - obj.object_payload = \ - b'TIGER, tiger, burning bright. In the forests of the night' - self.assertFalse(obj.is_valid()) + # obj.data = struct.pack(... + # obj.object_payload = \ + # b'TIGER, tiger, burning bright. In the forests of the night' + # self.assertFalse(obj.is_valid()) def test_proofofwork(self): """Check the main proofofwork call and worker"""