chanbackup: make sure onion addresses are covered in tests

This commit is contained in:
Elle Mouton
2025-05-23 16:11:27 +02:00
committed by Oliver Gugger
parent 4b3fb1150b
commit 659549a5fc
3 changed files with 9 additions and 3 deletions

View File

@@ -156,6 +156,7 @@ func TestFetchStaticChanBackups(t *testing.T) {
chanSource.chans[randomChan2.FundingOutpoint] = randomChan2
chanSource.addAddrsForNode(randomChan1.IdentityPub, []net.Addr{addr1})
chanSource.addAddrsForNode(randomChan2.IdentityPub, []net.Addr{addr2})
chanSource.addAddrsForNode(randomChan2.IdentityPub, []net.Addr{addr3})
// 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,7 @@ func TestMultiPackUnpack(t *testing.T) {
t.Fatalf("unable to gen channel: %v", err)
}
single := NewSingle(channel, []net.Addr{addr1, addr2})
single := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
originalSingles = append(originalSingles, single)
multi.StaticBackups = append(multi.StaticBackups, single)

View File

@@ -18,6 +18,7 @@ import (
"github.com/lightningnetwork/lnd/lnencrypt"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain"
"github.com/lightningnetwork/lnd/tor"
"github.com/stretchr/testify/require"
)
@@ -36,6 +37,10 @@ var (
addr1, _ = net.ResolveTCPAddr("tcp", "10.0.0.2:9000")
addr2, _ = net.ResolveTCPAddr("tcp", "10.0.0.3:9000")
addr3 = &tor.OnionAddr{
OnionService: "3g2upl4pq6kufc4m.onion",
Port: 9735,
}
)
func assertSingleEqual(t *testing.T, a, b Single) {
@@ -309,7 +314,7 @@ func TestSinglePackUnpack(t *testing.T) {
channel, err := genRandomOpenChannelShell()
require.NoError(t, err, "unable to gen open channel")
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2})
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
keyRing := &lnencrypt.MockKeyRing{}
@@ -634,7 +639,7 @@ func TestSingleUnconfirmedChannel(t *testing.T) {
channel.ShortChannelID.BlockHeight = 0
channel.FundingBroadcastHeight = fundingBroadcastHeight
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2})
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2, addr3})
keyRing := &lnencrypt.MockKeyRing{}
// Pack it and then unpack it again to make sure everything is written