• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 18908318090

29 Oct 2025 12:45PM UTC coverage: 66.185%. First build
18908318090

Pull #9489

github

web-flow
Merge bb65b4fde into 1ccb52620
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

484 of 629 new or added lines in 14 files covered. (76.95%)

138000 of 208508 relevant lines covered (66.18%)

21020.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lntest/rpc/harness_rpc.go
1
package rpc
2

3
import (
4
        "context"
5
        "testing"
6

7
        "github.com/btcsuite/btcd/wire"
8
        "github.com/lightningnetwork/lnd/lnrpc"
9
        "github.com/lightningnetwork/lnd/lnrpc/chainrpc"
10
        "github.com/lightningnetwork/lnd/lnrpc/devrpc"
11
        "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
12
        "github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"
13
        "github.com/lightningnetwork/lnd/lnrpc/peersrpc"
14
        "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
15
        "github.com/lightningnetwork/lnd/lnrpc/signrpc"
16
        "github.com/lightningnetwork/lnd/lnrpc/switchrpc"
17
        "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
18
        "github.com/lightningnetwork/lnd/lnrpc/watchtowerrpc"
19
        "github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
20
        "github.com/lightningnetwork/lnd/lntest/wait"
21
        "github.com/stretchr/testify/require"
22
        "google.golang.org/grpc"
23
)
24

25
const (
26
        DefaultTimeout = wait.DefaultTimeout
27
)
28

29
// HarnessRPC wraps all lnd's RPC clients into a single struct for easier
30
// access.
31
type HarnessRPC struct {
32
        *testing.T
33

34
        LN               lnrpc.LightningClient
35
        WalletUnlocker   lnrpc.WalletUnlockerClient
36
        Invoice          invoicesrpc.InvoicesClient
37
        Signer           signrpc.SignerClient
38
        Switch           switchrpc.SwitchClient
39
        Router           routerrpc.RouterClient
40
        WalletKit        walletrpc.WalletKitClient
41
        Watchtower       watchtowerrpc.WatchtowerClient
42
        WatchtowerClient wtclientrpc.WatchtowerClientClient
43
        State            lnrpc.StateClient
44
        ChainClient      chainrpc.ChainNotifierClient
45
        ChainKit         chainrpc.ChainKitClient
46
        NeutrinoKit      neutrinorpc.NeutrinoKitClient
47
        Peer             peersrpc.PeersClient
48
        Dev              devrpc.DevClient
49

50
        // Name is the HarnessNode's name.
51
        Name string
52

53
        // runCtx is a context with cancel method. It's used to signal when the
54
        // node needs to quit, and used as the parent context when spawning
55
        // children contexts for RPC requests.
56
        runCtx context.Context //nolint:containedctx
57
        cancel context.CancelFunc
58
}
59

60
// NewHarnessRPC creates a new HarnessRPC with its own context inherted from
61
// the pass context.
62
func NewHarnessRPC(ctxt context.Context, t *testing.T, c *grpc.ClientConn,
63
        name string) *HarnessRPC {
×
64

×
65
        h := &HarnessRPC{
×
66
                T:                t,
×
67
                LN:               lnrpc.NewLightningClient(c),
×
68
                Invoice:          invoicesrpc.NewInvoicesClient(c),
×
69
                Router:           routerrpc.NewRouterClient(c),
×
70
                WalletKit:        walletrpc.NewWalletKitClient(c),
×
71
                WalletUnlocker:   lnrpc.NewWalletUnlockerClient(c),
×
72
                Watchtower:       watchtowerrpc.NewWatchtowerClient(c),
×
73
                WatchtowerClient: wtclientrpc.NewWatchtowerClientClient(c),
×
74
                Signer:           signrpc.NewSignerClient(c),
×
75
                State:            lnrpc.NewStateClient(c),
×
NEW
76
                Switch:           switchrpc.NewSwitchClient(c),
×
77
                ChainClient:      chainrpc.NewChainNotifierClient(c),
×
78
                ChainKit:         chainrpc.NewChainKitClient(c),
×
79
                NeutrinoKit:      neutrinorpc.NewNeutrinoKitClient(c),
×
80
                Peer:             peersrpc.NewPeersClient(c),
×
81
                Dev:              devrpc.NewDevClient(c),
×
82
                Name:             name,
×
83
        }
×
84

×
85
        // Inherit parent context.
×
86
        h.runCtx, h.cancel = context.WithCancel(ctxt)
×
87
        return h
×
88
}
×
89

90
// MakeOutpoint returns the outpoint of the channel's funding transaction.
91
func (h *HarnessRPC) MakeOutpoint(cp *lnrpc.ChannelPoint) wire.OutPoint {
×
92
        fundingTxID, err := lnrpc.GetChanPointFundingTxid(cp)
×
93
        require.NoErrorf(h, err, "failed to make chanPoint", h.Name)
×
94

×
95
        return wire.OutPoint{
×
96
                Hash:  *fundingTxID,
×
97
                Index: cp.OutputIndex,
×
98
        }
×
99
}
×
100

101
// NoError is a helper method to format the error message used in calling RPCs.
102
func (h *HarnessRPC) NoError(err error, operation string) {
×
103
        require.NoErrorf(h, err, "%s: failed to call %s", h.Name, operation)
×
104
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc