mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-27 18:26:18 +02:00
tlv+hop: contain odd/even logic in payload parsing
Tlv is used more widely in lnd than just for the onion payload. This commit isolated the protocol-specific odd/even logic, so that tlv can be used freely elsewhere. An example of this use is db serialization.
This commit is contained in:
@@ -203,26 +203,6 @@ var tlvDecodingFailureTests = []struct {
|
||||
},
|
||||
expErr: io.ErrUnexpectedEOF,
|
||||
},
|
||||
{
|
||||
name: "unknown even type",
|
||||
bytes: []byte{0x12, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x12),
|
||||
},
|
||||
{
|
||||
name: "unknown even type",
|
||||
bytes: []byte{0xfd, 0x01, 0x02, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x102),
|
||||
},
|
||||
{
|
||||
name: "unknown even type",
|
||||
bytes: []byte{0xfe, 0x01, 0x00, 0x00, 0x02, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x01000002),
|
||||
},
|
||||
{
|
||||
name: "unknown even type",
|
||||
bytes: []byte{0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x0100000000000002),
|
||||
},
|
||||
{
|
||||
name: "greater than encoding length for n1's amt",
|
||||
bytes: []byte{0x01, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||
@@ -340,12 +320,6 @@ var tlvDecodingFailureTests = []struct {
|
||||
expErr: tlv.NewTypeForDecodingErr(new(nodeAmts), "nodeAmts", 50, 49),
|
||||
skipN2: true,
|
||||
},
|
||||
{
|
||||
name: "unknown required type or n1",
|
||||
bytes: []byte{0x00, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x00),
|
||||
skipN2: true,
|
||||
},
|
||||
{
|
||||
name: "less than encoding length for n1's cltvDelta",
|
||||
bytes: []byte{0xfd, 0x00, 0x0fe, 0x00},
|
||||
@@ -364,12 +338,6 @@ var tlvDecodingFailureTests = []struct {
|
||||
expErr: tlv.NewTypeForDecodingErr(new(uint16), "uint16", 3, 2),
|
||||
skipN2: true,
|
||||
},
|
||||
{
|
||||
name: "unknown even field for n1's namespace",
|
||||
bytes: []byte{0x0a, 0x00},
|
||||
expErr: tlv.ErrUnknownRequiredType(0x0a),
|
||||
skipN2: true,
|
||||
},
|
||||
{
|
||||
name: "valid records but invalid ordering",
|
||||
bytes: []byte{0x02, 0x08,
|
||||
|
Reference in New Issue
Block a user