lnwire: add *OpaqueAddrs case in WriteElements

And then expand the chanbackup unit tests to cover such a case.
This commit is contained in:
Elle Mouton
2025-05-23 16:14:47 +02:00
committed by Oliver Gugger
parent 2530ab13c7
commit c79daf68fa
4 changed files with 20 additions and 3 deletions

View File

@@ -157,6 +157,7 @@ func TestFetchStaticChanBackups(t *testing.T) {
chanSource.addAddrsForNode(randomChan1.IdentityPub, []net.Addr{addr1})
chanSource.addAddrsForNode(randomChan2.IdentityPub, []net.Addr{addr2})
chanSource.addAddrsForNode(randomChan2.IdentityPub, []net.Addr{addr3})
chanSource.addAddrsForNode(randomChan2.IdentityPub, []net.Addr{addr4})
// With the channel source populated, we'll now attempt to create a set
// of backups for all the channels. This should succeed, as all items

View File

@@ -22,7 +22,9 @@ func TestMultiPackUnpack(t *testing.T) {
t.Fatalf("unable to gen channel: %v", err)
}
single := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
single := NewSingle(
channel, []net.Addr{addr1, addr2, addr3, addr4},
)
originalSingles = append(originalSingles, single)
multi.StaticBackups = append(multi.StaticBackups, single)

View File

@@ -41,6 +41,11 @@ var (
OnionService: "3g2upl4pq6kufc4m.onion",
Port: 9735,
}
addr4 = &lnwire.OpaqueAddrs{
// The first byte must be an address type we are not yet aware
// of for it to be a valid OpaqueAddrs.
Payload: []byte{math.MaxUint8, 1, 2, 3, 4},
}
)
func assertSingleEqual(t *testing.T, a, b Single) {
@@ -314,7 +319,9 @@ func TestSinglePackUnpack(t *testing.T) {
channel, err := genRandomOpenChannelShell()
require.NoError(t, err, "unable to gen open channel")
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
singleChanBackup := NewSingle(
channel, []net.Addr{addr1, addr2, addr3, addr4},
)
keyRing := &lnencrypt.MockKeyRing{}
@@ -639,7 +646,9 @@ func TestSingleUnconfirmedChannel(t *testing.T) {
channel.ShortChannelID.BlockHeight = 0
channel.FundingBroadcastHeight = fundingBroadcastHeight
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
singleChanBackup := NewSingle(
channel, []net.Addr{addr1, addr2, addr3, addr4},
)
keyRing := &lnencrypt.MockKeyRing{}
// Pack it and then unpack it again to make sure everything is written