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.
This commit is contained in:
Conner Fromknecht 2021-03-24 19:47:33 -07:00
parent 82b4f11292
commit 135a0a9f7f
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -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,
},