test_rlp_reciprocal.py (962B)
1 # standard imports 2 import os 3 import unittest 4 import logging 5 import ctypes 6 7 # local imports 8 from pylibrlp import RLPEncoder 9 10 logging.basicConfig(level=logging.DEBUG) 11 logg = logging.getLogger() 12 13 14 15 class TestRlpEncoder(unittest.TestCase): 16 17 def setUp(self): 18 self.encoder = RLPEncoder(1024) 19 20 21 def test_encode_multiple_adjacent(self): 22 v = [ 23 bytes.fromhex('01'), 24 bytes.fromhex('3b9aca00'), 25 bytes.fromhex('5208'), 26 bytes.fromhex('3102ac39709f178c0f5e87d05908609d8e09d820'), 27 bytes.fromhex('0400'), 28 bytes.fromhex('666f6f'), 29 bytes.fromhex('01'), 30 os.urandom(32), 31 os.urandom(32), 32 ] 33 b = self.encoder.encode(v) 34 print(b.hex()) 35 36 o = self.encoder.decode(b) 37 for e in o: 38 print(e.hex()) 39 40 41 if __name__ == '__main__': 42 unittest.main()