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

lightningnetwork / lnd / 13974489001

20 Mar 2025 04:32PM UTC coverage: 56.292% (-2.9%) from 59.168%
13974489001

Pull #8754

github

web-flow
Merge aed149e6b into ea050d06f
Pull Request #8754: Add `Outbound` Remote Signer implementation

594 of 1713 new or added lines in 26 files covered. (34.68%)

23052 existing lines in 272 files now uncovered.

105921 of 188165 relevant lines covered (56.29%)

23796.34 hits per line

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

13.16
/lnrpc/routerrpc/driver.go
1
package routerrpc
2

3
import (
4
        "fmt"
5

6
        "github.com/lightningnetwork/lnd/lnrpc"
7
)
8

9
// getConfig is a helper method that will fetch the config for sub-server given
10
// the main config dispatcher method. If we're unable to find the config
11
// that is meant for us in the config dispatcher, then we'll exit with an
12
// error. If enforceDependencies is set to true, the function also verifies that
13
// the dependencies in the config are properly set.
14
func getConfig(configRegistry lnrpc.SubServerConfigDispatcher,
NEW
15
        enforceDependencies bool) (*Config, error) {
×
UNCOV
16

×
UNCOV
17
        // We'll attempt to look up the config that we expect, according to our
×
UNCOV
18
        // subServerName name. If we can't find this, then we'll exit with an
×
UNCOV
19
        // error, as we're unable to properly initialize ourselves without this
×
UNCOV
20
        // config.
×
NEW
21
        subServerConf, ok := configRegistry.FetchConfig(subServerName)
×
UNCOV
22
        if !ok {
×
NEW
23
                return nil, fmt.Errorf("unable to find config for subserver "+
×
NEW
24
                        "type %s", subServerName)
×
UNCOV
25
        }
×
26

27
        // Now that we've found an object mapping to our service name, we'll
28
        // ensure that it's the type we need.
NEW
29
        config, ok := subServerConf.(*Config)
×
UNCOV
30
        if !ok {
×
NEW
31
                return nil, fmt.Errorf("wrong type of config for subserver "+
×
NEW
32
                        "%s, expected %T got %T", subServerName, &Config{},
×
NEW
33
                        subServerConf)
×
UNCOV
34
        }
×
35

NEW
36
        if enforceDependencies {
×
NEW
37
                if err := verifyDependencies(config); err != nil {
×
NEW
38
                        return nil, err
×
NEW
39
                }
×
40
        }
41

NEW
42
        return config, nil
×
43
}
44

45
// verifyDependencies ensures that the dependencies in the config are properly
46
// set.
47
//
48
//nolint:stylecheck
NEW
49
func verifyDependencies(config *Config) error {
×
UNCOV
50
        // Before we try to make the new router service instance, we'll perform
×
UNCOV
51
        // some sanity checks on the arguments to ensure that they're usable.
×
UNCOV
52
        switch {
×
53
        case config.Router == nil:
×
NEW
54
                return fmt.Errorf("Router must be set to create Routerpc")
×
55
        }
56

NEW
57
        return nil
×
58
}
59

60
func init() {
4✔
61
        subServer := &lnrpc.SubServerDriver{
4✔
62
                SubServerName: subServerName,
4✔
63
                NewGrpcHandler: func() lnrpc.GrpcHandler {
4✔
UNCOV
64
                        return &ServerShell{}
×
UNCOV
65
                },
×
66
        }
67

68
        // If the build tag is active, then we'll register ourselves as a
69
        // sub-RPC server within the global lnrpc package namespace.
70
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
4✔
71
                panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
×
72
                        subServerName, err))
×
73
        }
74
}
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