pylibrlp

Python3 wrapper for librlp
git clone git://git.defalsify.org/pylibrlp.git
Info | Log | Files | Refs | LICENSE

test_rlp_encoder.py (1268B)


      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 class TestRlpEncoder(unittest.TestCase):
     15 
     16     def setUp(self):
     17         self.encoder = RLPEncoder(1024)
     18 
     19 
     20     @unittest.skip('test')
     21     def test_encode_single_string(self):
     22         v = b'foo'
     23         b = self.encoder.encode(v)
     24         print(b.hex())
     25 
     26 
     27     @unittest.skip('test')
     28     def test_encode_single_list(self):
     29         v = [b'foo']
     30         b = self.encoder.encode(v)
     31         print(b.hex())
     32 
     33 
     34     @unittest.skip('test')
     35     def test_encode_nested(self):
     36         v = [b'foo', [b'bar', b'baz']]
     37         b = self.encoder.encode(v)
     38         print(b.hex())
     39 
     40 
     41     def test_encode_multiple_adjacent(self):
     42         v = [
     43             bytes.fromhex('01'),
     44             bytes.fromhex('3b9aca00'),
     45             bytes.fromhex('5208'),
     46             bytes.fromhex('3102ac39709f178c0f5e87d05908609d8e09d820'),
     47             bytes.fromhex('0400'),
     48             bytes.fromhex('666f6f'),
     49             bytes.fromhex('01'),
     50             os.urandom(32),
     51             os.urandom(32),
     52         ]
     53         b = self.encoder.encode(v)
     54         print(b.hex())
     55 
     56 
     57 if __name__ == '__main__':
     58     unittest.main()