|
|
@ -1,18 +1,10 @@ |
|
|
|
#! /usr/bin/python3 |
|
|
|
from pyln.proto.message.fundamental_types import fundamental_types |
|
|
|
from pyln.proto.message.fundamental_types import byte, u16, short_channel_id |
|
|
|
from pyln.proto.message.array_types import SizedArrayType, DynamicArrayType, EllipsisArrayType, LengthFieldType |
|
|
|
import io |
|
|
|
|
|
|
|
|
|
|
|
def test_sized_array(): |
|
|
|
# Steal two fundamental types for testing |
|
|
|
for t in fundamental_types(): |
|
|
|
if t.name == 'byte': |
|
|
|
byte = t |
|
|
|
if t.name == 'u16': |
|
|
|
u16 = t |
|
|
|
if t.name == 'short_channel_id': |
|
|
|
scid = t |
|
|
|
|
|
|
|
# Simple class to make outer work. |
|
|
|
class dummy: |
|
|
@ -25,7 +17,7 @@ def test_sized_array(): |
|
|
|
[SizedArrayType(dummy("test2"), "test_arr", u16, 4), |
|
|
|
"[0,1,2,256]", |
|
|
|
bytes([0, 0, 0, 1, 0, 2, 1, 0])], |
|
|
|
[SizedArrayType(dummy("test3"), "test_arr", scid, 4), |
|
|
|
[SizedArrayType(dummy("test3"), "test_arr", short_channel_id, 4), |
|
|
|
"[1x2x3,4x5x6,7x8x9,10x11x12]", |
|
|
|
bytes([0, 0, 1, 0, 0, 2, 0, 3] |
|
|
|
+ [0, 0, 4, 0, 0, 5, 0, 6] |
|
|
@ -41,15 +33,6 @@ def test_sized_array(): |
|
|
|
|
|
|
|
|
|
|
|
def test_ellipsis_array(): |
|
|
|
# Steal two fundamental types for testing |
|
|
|
for t in fundamental_types(): |
|
|
|
if t.name == 'byte': |
|
|
|
byte = t |
|
|
|
if t.name == 'u16': |
|
|
|
u16 = t |
|
|
|
if t.name == 'short_channel_id': |
|
|
|
scid = t |
|
|
|
|
|
|
|
# Simple class to make outer work. |
|
|
|
class dummy: |
|
|
|
def __init__(self, name): |
|
|
@ -61,7 +44,7 @@ def test_ellipsis_array(): |
|
|
|
[EllipsisArrayType(dummy("test2"), "test_arr", u16), |
|
|
|
"[0,1,2,256]", |
|
|
|
bytes([0, 0, 0, 1, 0, 2, 1, 0])], |
|
|
|
[EllipsisArrayType(dummy("test3"), "test_arr", scid), |
|
|
|
[EllipsisArrayType(dummy("test3"), "test_arr", short_channel_id), |
|
|
|
"[1x2x3,4x5x6,7x8x9,10x11x12]", |
|
|
|
bytes([0, 0, 1, 0, 0, 2, 0, 3] |
|
|
|
+ [0, 0, 4, 0, 0, 5, 0, 6] |
|
|
@ -77,15 +60,6 @@ def test_ellipsis_array(): |
|
|
|
|
|
|
|
|
|
|
|
def test_dynamic_array(): |
|
|
|
# Steal two fundamental types for testing |
|
|
|
for t in fundamental_types(): |
|
|
|
if t.name == 'byte': |
|
|
|
byte = t |
|
|
|
if t.name == 'u16': |
|
|
|
u16 = t |
|
|
|
if t.name == 'short_channel_id': |
|
|
|
scid = t |
|
|
|
|
|
|
|
# Simple class to make outer. |
|
|
|
class dummy: |
|
|
|
def __init__(self, name): |
|
|
@ -106,7 +80,7 @@ def test_dynamic_array(): |
|
|
|
lenfield), |
|
|
|
"[0,1,2,256]", |
|
|
|
bytes([0, 0, 0, 1, 0, 2, 1, 0])], |
|
|
|
[DynamicArrayType(dummy("test3"), "test_arr", scid, |
|
|
|
[DynamicArrayType(dummy("test3"), "test_arr", short_channel_id, |
|
|
|
lenfield), |
|
|
|
"[1x2x3,4x5x6,7x8x9,10x11x12]", |
|
|
|
bytes([0, 0, 1, 0, 0, 2, 0, 3] |
|
|
|