multi: thread context through to AddrsForNode
This commit is contained in:
15 files changed
+88
-64
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package chanbackup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
@@ -61,8 +62,8 @@ func (m *mockChannelSource) addAddrsForNode(nodePub *btcec.PublicKey, addrs []ne
|
||||
m.addrs[nodeKey] = addrs
|
||||
}
|
||||
|
||||
func (m *mockChannelSource) AddrsForNode(nodePub *btcec.PublicKey) (bool,
|
||||
[]net.Addr, error) {
|
||||
func (m *mockChannelSource) AddrsForNode(_ context.Context,
|
||||
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
|
||||
|
||||
if m.failQuery {
|
||||
return false, nil, fmt.Errorf("fail")
|
||||
@@ -120,7 +121,8 @@ func TestFetchBackupForChan(t *testing.T) {
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
_, err := FetchBackupForChan(
|
||||
testCase.chanPoint, chanSource, chanSource,
|
||||
context.Background(), testCase.chanPoint, chanSource,
|
||||
chanSource,
|
||||
)
|
||||
switch {
|
||||
// If this is a valid test case, and we failed, then we'll
|
||||
@@ -141,6 +143,7 @@ func TestFetchBackupForChan(t *testing.T) {
|
||||
// channel source for all channels and construct a Single for each channel.
|
||||
func TestFetchStaticChanBackups(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
// First, we'll make the set of channels that we want to seed the
|
||||
// channel source with. Both channels will be fully populated in the
|
||||
@@ -162,7 +165,7 @@ func TestFetchStaticChanBackups(t *testing.T) {
|
||||
// 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
|
||||
// are populated within the channel source.
|
||||
backups, err := FetchStaticChanBackups(chanSource, chanSource)
|
||||
backups, err := FetchStaticChanBackups(ctx, chanSource, chanSource)
|
||||
require.NoError(t, err, "unable to create chan back ups")
|
||||
|
||||
if len(backups) != numChans {
|
||||
@@ -177,7 +180,7 @@ func TestFetchStaticChanBackups(t *testing.T) {
|
||||
copy(n[:], randomChan2.IdentityPub.SerializeCompressed())
|
||||
delete(chanSource.addrs, n)
|
||||
|
||||
_, err = FetchStaticChanBackups(chanSource, chanSource)
|
||||
_, err = FetchStaticChanBackups(ctx, chanSource, chanSource)
|
||||
if err == nil {
|
||||
t.Fatalf("query with incomplete information should fail")
|
||||
}
|
||||
@@ -186,7 +189,7 @@ func TestFetchStaticChanBackups(t *testing.T) {
|
||||
// source at all, then we'll fail as well.
|
||||
chanSource = newMockChannelSource()
|
||||
chanSource.failQuery = true
|
||||
_, err = FetchStaticChanBackups(chanSource, chanSource)
|
||||
_, err = FetchStaticChanBackups(ctx, chanSource, chanSource)
|
||||
if err == nil {
|
||||
t.Fatalf("query should fail")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user