MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_static_array

Function test_static_array

contrib/pyln-proto/tests/test_message.py:39–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38
39def test_static_array():
40 ns = MessageNamespace()
41 ns.load_csv(['msgtype,test1,1',
42 'msgdata,test1,test_arr,byte,4'])
43 ns.load_csv(['msgtype,test2,2',
44 'msgdata,test2,test_arr,short_channel_id,4'])
45
46 for test in [["test1 test_arr=00010203", bytes([0, 1] + [0, 1, 2, 3])],
47 ["test2 test_arr=[0x1x2,4x5x6,7x8x9,10x11x12]",
48 bytes([0, 2]
49 + [0, 0, 0, 0, 0, 1, 0, 2]
50 + [0, 0, 4, 0, 0, 5, 0, 6]
51 + [0, 0, 7, 0, 0, 8, 0, 9]
52 + [0, 0, 10, 0, 0, 11, 0, 12])]]:
53 m = Message.from_str(ns, test[0])
54 assert m.to_str() == test[0]
55 buf = io.BytesIO()
56 m.write(buf)
57 assert buf.getvalue() == test[1]
58 assert Message.read(ns, io.BytesIO(test[1])).to_str() == test[0]
59
60
61def test_subtype():

Callers

nothing calls this directly

Calls 6

load_csvMethod · 0.95
MessageNamespaceClass · 0.90
to_strMethod · 0.80
from_strMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected