WIP: Implementing sqlite objects storage #13

Draft
lee.miller wants to merge 11 commits from lee.miller/MiNode:sqlite into v0.3
Showing only changes of commit 79aedd1bb5 - Show all commits

View File

@ -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"""