From 902d8f7dab3a787153d3e7f00515c9d4346e5df1 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 19 Jun 2020 09:56:00 +0930 Subject: [PATCH] pyln.proto.message: remove incorrect fundamental types now spec update. See https://github.com/lightningnetwork/lightning-rfc/commit/9e8e29af9b9a922eb114b2c716205d0772946e56 Signed-off-by: Rusty Russell --- .../pyln/proto/message/fundamental_types.py | 35 ++++++++++++++++--- .../tests/test_fundamental_types.py | 2 +- contrib/pyln-proto/tests/test_message.py | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/contrib/pyln-proto/pyln/proto/message/fundamental_types.py b/contrib/pyln-proto/pyln/proto/message/fundamental_types.py index 11f26704a..2d3baea34 100644 --- a/contrib/pyln-proto/pyln/proto/message/fundamental_types.py +++ b/contrib/pyln-proto/pyln/proto/message/fundamental_types.py @@ -250,7 +250,36 @@ class BigSizeType(FieldType): def fundamental_types() -> List[FieldType]: - # From 01-messaging.md#fundamental-types: + # BOLT #1: + # Various fundamental types are referred to in the message specifications: + # + # * `byte`: an 8-bit byte + # * `u16`: a 2 byte unsigned integer + # * `u32`: a 4 byte unsigned integer + # * `u64`: an 8 byte unsigned integer + # + # Inside TLV records which contain a single value, leading zeros in + # integers can be omitted: + # + # * `tu16`: a 0 to 2 byte unsigned integer + # * `tu32`: a 0 to 4 byte unsigned integer + # * `tu64`: a 0 to 8 byte unsigned integer + # + # The following convenience types are also defined: + # + # * `chain_hash`: a 32-byte chain identifier (see [BOLT + # #0](00-introduction.md#glossary-and-terminology-guide)) + # * `channel_id`: a 32-byte channel_id (see [BOLT + # #2](02-peer-protocol.md#definition-of-channel-id)) + # * `sha256`: a 32-byte SHA2-256 hash + # * `signature`: a 64-byte bitcoin Elliptic Curve signature + # * `point`: a 33-byte Elliptic Curve point (compressed encoding as per + # [SEC 1 standard](http://www.secg.org/sec1-v2.pdf#subsubsection.2.3.3)) + # * `short_channel_id`: an 8 byte value identifying a channel (see [BOLT + # #7](07-routing-gossip.md#definition-of-short-channel-id)) + # * `bigsize`: a variable-length, unsigned integer similar to Bitcoin's + # CompactSize encoding, but big-endian. Described in + # [BigSize](#appendix-a-bigsize-test-vectors). return [IntegerType('byte', 1, 'B'), IntegerType('u16', 2, '>H'), IntegerType('u32', 4, '>I'), @@ -265,10 +294,6 @@ def fundamental_types() -> List[FieldType]: ShortChannelIDType('short_channel_id'), FundamentalHexType('signature', 64), BigSizeType('bigsize'), - # FIXME: See https://github.com/lightningnetwork/lightning-rfc/pull/778 - BigSizeType('varint'), - # FIXME - IntegerType('u8', 1, 'B'), ] diff --git a/contrib/pyln-proto/tests/test_fundamental_types.py b/contrib/pyln-proto/tests/test_fundamental_types.py index 5513a13e5..dbd03c988 100644 --- a/contrib/pyln-proto/tests/test_fundamental_types.py +++ b/contrib/pyln-proto/tests/test_fundamental_types.py @@ -74,4 +74,4 @@ def test_fundamental_types(): t.write(buf, v, None) assert buf.getvalue() == test[1] - assert untested == set(['varint', 'u8']) + assert untested == set() diff --git a/contrib/pyln-proto/tests/test_message.py b/contrib/pyln-proto/tests/test_message.py index c9b516921..3e79faf9d 100644 --- a/contrib/pyln-proto/tests/test_message.py +++ b/contrib/pyln-proto/tests/test_message.py @@ -140,7 +140,7 @@ def test_tlv_complex(): "msgdata,reply_channel_range,encoded_short_ids,byte,len", "msgdata,reply_channel_range,tlvs,reply_channel_range_tlvs,", "tlvtype,reply_channel_range_tlvs,timestamps_tlv,1", - "tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoding_type,u8,", + "tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoding_type,byte,", "tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoded_timestamps,byte,...", "tlvtype,reply_channel_range_tlvs,checksums_tlv,3", "tlvdata,reply_channel_range_tlvs,checksums_tlv,checksums,channel_update_checksums,...",