mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
patch message-export-types.patch
This commit is contained in:
committed by
Christian Decker
parent
eb73a0dd8f
commit
ed4eadc8f3
@@ -1,11 +1,11 @@
|
|||||||
#! /usr/bin/python3
|
|
||||||
from .fundamental_types import FieldType, IntegerType, split_field
|
from .fundamental_types import FieldType, IntegerType, split_field
|
||||||
|
|
||||||
|
|
||||||
class ArrayType(FieldType):
|
class ArrayType(FieldType):
|
||||||
"""Abstract class for the different kinds of arrays: these are not in
|
"""Abstract class for the different kinds of arrays.
|
||||||
the namespace, but generated when a message says it wants an array of
|
|
||||||
some type.
|
These are not in the namespace, but generated when a message says it
|
||||||
|
wants an array of some type.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, outer, name, elemtype):
|
def __init__(self, outer, name, elemtype):
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#! /usr/bin/python3
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ These are further specialized.
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.name
|
return 'FieldType({})'.format(self.name)
|
||||||
|
|
||||||
|
|
||||||
class IntegerType(FieldType):
|
class IntegerType(FieldType):
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#! /usr/bin/python3
|
|
||||||
import struct
|
import struct
|
||||||
from .fundamental_types import fundamental_types, BigSizeType, split_field
|
from .fundamental_types import fundamental_types, BigSizeType, split_field
|
||||||
from .array_types import (
|
from .array_types import (
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_sized_array():
|
|||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
for test in [[SizedArrayType(dummy("test1"), "test_arr", byte, 4),
|
for arrtype, s, b in [[SizedArrayType(dummy("test1"), "test_arr", byte, 4),
|
||||||
"00010203",
|
"00010203",
|
||||||
bytes([0, 1, 2, 3])],
|
bytes([0, 1, 2, 3])],
|
||||||
[SizedArrayType(dummy("test2"), "test_arr", u16, 4),
|
[SizedArrayType(dummy("test2"), "test_arr", u16, 4),
|
||||||
@@ -30,11 +30,11 @@ def test_sized_array():
|
|||||||
+ [0, 0, 4, 0, 0, 5, 0, 6]
|
+ [0, 0, 4, 0, 0, 5, 0, 6]
|
||||||
+ [0, 0, 7, 0, 0, 8, 0, 9]
|
+ [0, 0, 7, 0, 0, 8, 0, 9]
|
||||||
+ [0, 0, 10, 0, 0, 11, 0, 12])]]:
|
+ [0, 0, 10, 0, 0, 11, 0, 12])]]:
|
||||||
v, _ = test[0].val_from_str(test[1])
|
v, _ = arrtype.val_from_str(s)
|
||||||
assert test[0].val_to_str(v, None) == test[1]
|
assert arrtype.val_to_str(v, None) == s
|
||||||
v2, _ = test[0].val_from_bin(test[2], None)
|
v2, _ = arrtype.val_from_bin(b, None)
|
||||||
assert v2 == v
|
assert v2 == v
|
||||||
assert test[0].val_to_bin(v, None) == test[2]
|
assert arrtype.val_to_bin(v, None) == b
|
||||||
|
|
||||||
|
|
||||||
def test_ellipsis_array():
|
def test_ellipsis_array():
|
||||||
|
|||||||
Reference in New Issue
Block a user