From 135a0a9f7ffb43635df2de9f05bbc57daa8acfa9 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Wed, 24 Mar 2021 19:47:33 -0700 Subject: [PATCH] htlcswitch/hop: make unknown required type const Currently we use the AMP record type, this allows us to change it easily as we add new known records. We also bump this to 0x0c instead of 0x0a. --- htlcswitch/hop/payload_test.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/htlcswitch/hop/payload_test.go b/htlcswitch/hop/payload_test.go index b0a92534f..bfe2c134e 100644 --- a/htlcswitch/hop/payload_test.go +++ b/htlcswitch/hop/payload_test.go @@ -10,6 +10,8 @@ import ( "github.com/lightningnetwork/lnd/record" ) +const testUnknownRequiredType = 0x10 + type decodePayloadTest struct { name string payload []byte @@ -81,21 +83,26 @@ var decodePayloadTests = []decodePayloadTest{ }, }, { - name: "required type after omitted hop id", - payload: []byte{0x02, 0x00, 0x04, 0x00, 0x0a, 0x00}, + name: "required type after omitted hop id", + payload: []byte{ + 0x02, 0x00, 0x04, 0x00, + testUnknownRequiredType, 0x00, + }, expErr: hop.ErrInvalidPayload{ - Type: 10, + Type: testUnknownRequiredType, Violation: hop.RequiredViolation, FinalHop: true, }, }, { name: "required type after included hop id", - payload: []byte{0x02, 0x00, 0x04, 0x00, 0x06, 0x08, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, + payload: []byte{ + 0x02, 0x00, 0x04, 0x00, 0x06, 0x08, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + testUnknownRequiredType, 0x00, }, expErr: hop.ErrInvalidPayload{ - Type: 10, + Type: testUnknownRequiredType, Violation: hop.RequiredViolation, FinalHop: false, },