mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
lnwire: add alias to FundingLocked in TLV
This adds an optional short channel id field to the FundingLocked message that is sent/received as a TLV segment inside the ExtraOpaqueData field.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestShortChannelIDEncoding(t *testing.T) {
|
||||
@@ -39,3 +40,25 @@ func TestShortChannelIDEncoding(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestScidTypeEncodeDecode tests that we're able to properly encode and decode
|
||||
// ShortChannelID within TLV streams.
|
||||
func TestScidTypeEncodeDecode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
aliasScid := ShortChannelID{
|
||||
BlockHeight: (1 << 24) - 1,
|
||||
TxIndex: (1 << 24) - 1,
|
||||
TxPosition: (1 << 16) - 1,
|
||||
}
|
||||
|
||||
var extraData ExtraOpaqueData
|
||||
require.NoError(t, extraData.PackRecords(&aliasScid))
|
||||
|
||||
var aliasScid2 ShortChannelID
|
||||
tlvs, err := extraData.ExtractRecords(&aliasScid2)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Contains(t, tlvs, AliasScidRecordType)
|
||||
require.Equal(t, aliasScid, aliasScid2)
|
||||
}
|
||||
|
Reference in New Issue
Block a user