pylibrlp

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

commit 151c736804f58f94af5ee49557b65ce49893d14a
parent e5ea3187921d3f195430ade079cd8e606df94ceb
Author: nolash <dev@holbrook.no>
Date:   Sat, 10 Apr 2021 22:12:47 +0200

Set correct sizes in struct adapter

Diffstat:
Mrlpstream/encode.py | 7++++---
Mtests/test_rlp_encoder.py | 5+++++
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/rlpstream/encode.py b/rlpstream/encode.py @@ -11,15 +11,16 @@ librlp = ctypes.CDLL(path_librlp) #print(librlp) #print(dir(librlp)) +LIBRLP_RLP_MAX_LIST_DEPTH = 1024 + class RLPEncoderBackend(ctypes.Structure): _fields_ = [ ('buf', ctypes.POINTER(ctypes.c_char * 1024)), ('depth', ctypes.c_int), - #('list_ptr', ctypes.POINTER(ctypes.POINTER(ctypes.c_char))), - #('list_ptr', ctypes.POINTER(ctypes.c_char)), - #('ptr', ctypes.POINTER(ctypes.c_char)), + ('list_ptr', ctypes.POINTER(ctypes.POINTER(ctypes.c_char) * LIBRLP_RLP_MAX_LIST_DEPTH)), + ('ptr', ctypes.POINTER(ctypes.c_char)), ] diff --git a/tests/test_rlp_encoder.py b/tests/test_rlp_encoder.py @@ -28,5 +28,10 @@ class TestRlpEncoder(unittest.TestCase): print(b.hex()) + def test_encode_nested(self): + v = [b'foo', [b'bar', b'baz']] + b = self.encoder.encode(v) + print(b.hex()) + if __name__ == '__main__': unittest.main()