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

lightningnetwork / lnd / 15040473937

15 May 2025 08:37AM UTC coverage: 68.995% (-0.002%) from 68.997%
15040473937

Pull #9810

github

web-flow
Merge 1f4cbf54b into b0cba7dd0
Pull Request #9810: rpc: proper error code for GetChanInfo

4 of 7 new or added lines in 2 files covered. (57.14%)

56 existing lines in 15 files now uncovered.

133899 of 194071 relevant lines covered (68.99%)

22011.61 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/walletrpc"
17
        "github.com/lightningnetwork/lnd/lnrpc/watchtowerrpc"
18
        "github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
19
        "github.com/lightningnetwork/lnd/lntest/wait"
20
        "github.com/stretchr/testify/require"
21
        "google.golang.org/grpc"
22
)
23

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

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

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

48
        // Name is the HarnessNode's name.
49
        Name string
50

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

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

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

×
82
        // Inherit parent context.
×
83
        h.runCtx, h.cancel = context.WithCancel(ctxt)
×
84
        return h
×
85
}
×
86

87
// Context returns the context of the RPC harness
NEW
88
func (h *HarnessRPC) Context() context.Context {
×
NEW
89
        return h.runCtx
×
NEW
90
}
×
91

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

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

103
// NoError is a helper method to format the error message used in calling RPCs.
104
func (h *HarnessRPC) NoError(err error, operation string) {
×
105
        require.NoErrorf(h, err, "%s: failed to call %s", h.Name, operation)
×
106
}
×
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