diff tests/test_app.py @ 19:905b6fdc5e1b

handle invalid magic bytes
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Wed, 10 Nov 2021 11:37:44 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_app.py	Wed Nov 10 11:37:44 2021 +0100
@@ -0,0 +1,19 @@
+import os
+from bitcaviar_plus.block import deserialize_block
+from bitcaviar_plus.errors import InvalidMagicBytes
+
+
+def parse_genesis_block():
+    blk_path = '/bitcoin-node/.bitcoin/blocks/blk00355.dat'
+
+    with open(blk_path, 'rb') as f:
+        file_size = os.path.getsize(blk_path)
+        while f.tell() < file_size:
+            try:
+                block = deserialize_block(f)
+            except InvalidMagicBytes as e:
+                print(e)
+
+
+if __name__ == '__main__':
+    parse_genesis_block()