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:
1 file changed
+13
-6
@@ -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,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user