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

lightningnetwork / lnd / 14721313522

29 Apr 2025 01:25AM UTC coverage: 58.598% (+0.006%) from 58.592%
14721313522

Pull #9489

github

web-flow
Merge 290053529 into b34afa33f
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

360 of 553 new or added lines in 10 files covered. (65.1%)

83 existing lines in 10 files now uncovered.

97747 of 166809 relevant lines covered (58.6%)

1.82 hits per line

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

61.29
/lnrpc/switchrpc/driver.go
1
//go:build switchrpc
2
// +build switchrpc
3

4
package switchrpc
5

6
import (
7
        "fmt"
8

9
        "github.com/lightningnetwork/lnd/lnrpc"
10
)
11

12
// createNewSubServer is a helper method that will create the new router sub
13
// server given the main config dispatcher method. If we're unable to find the
14
// config that is meant for us in the config dispatcher, then we'll exit with
15
// an error.
16
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
17
        *Server, lnrpc.MacaroonPerms, error) {
3✔
18

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

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

38
        // Before we try to make the new switch service instance, we'll perform
39
        // some sanity checks on the arguments to ensure that they're usable.
40
        switch {
3✔
NEW
41
        case config.Switch == nil:
×
NEW
42
                return nil, nil, fmt.Errorf("Switch must be set to create " +
×
NEW
43
                        "SwitchRPC")
×
44
        }
45

46
        return New(config)
3✔
47
}
48

49
func init() {
3✔
50
        subServer := &lnrpc.SubServerDriver{
3✔
51
                SubServerName: subServerName,
3✔
52
                NewGrpcHandler: func() lnrpc.GrpcHandler {
6✔
53
                        return &ServerShell{}
3✔
54
                },
3✔
55
        }
56

57
        // If the build tag is active, then we'll register ourselves as a
58
        // sub-RPC server within the global lnrpc package namespace.
59
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
3✔
NEW
60
                panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
×
NEW
61
                        subServerName, err))
×
62
        }
63
}
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