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:
eugene
2022-04-04 15:25:16 -04:00
parent a493caf3c0
commit 3ff8eb899c
3 changed files with 103 additions and 1 deletions

View File

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