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

lightningnetwork / lnd / 13412100018

19 Feb 2025 12:05PM UTC coverage: 44.914% (-13.9%) from 58.794%
13412100018

Pull #9521

github

web-flow
Merge 861d6970e into 0e8786348
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

101023 of 224923 relevant lines covered (44.91%)

19479.4 hits per line

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

13.51
/lnrpc/chainrpc/driver.go
1
//go:build chainrpc
2
// +build chainrpc
3

4
package chainrpc
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 chain notifier
13
// sub server given the main config dispatcher method. If we're unable to find
14
// the config that is meant for us in the config dispatcher, then we'll exit
15
// with an error.
16
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
17
        *Server, lnrpc.MacaroonPerms, error) {
×
18

×
19
        // We'll attempt to look up the config that we expect, according to our
×
20
        // subServerName name. If we can't find this, then we'll exit with an
×
21
        // error, as we're unable to properly initialize ourselves without this
×
22
        // config.
×
23
        chainNotifierServerConf, ok := configRegistry.FetchConfig(subServerName)
×
24
        if !ok {
×
25
                return nil, nil, fmt.Errorf("unable to find config for "+
×
26
                        "subserver type %s", subServerName)
×
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 := chainNotifierServerConf.(*Config)
×
32
        if !ok {
×
33
                return nil, nil, fmt.Errorf("wrong type of config for "+
×
34
                        "subserver %s, expected %T got %T", subServerName,
×
35
                        &Config{}, chainNotifierServerConf)
×
36
        }
×
37

38
        // Before we try to make the new chain notifier service instance, we'll
39
        // perform some sanity checks on the arguments to ensure that they're
40
        // usable.
41
        switch {
×
42
        // If the macaroon service is set (we should use macaroons), then
43
        // ensure that we know where to look for them, or create them if not
44
        // found.
45
        case config.MacService != nil && config.NetworkDir == "":
×
46
                return nil, nil, fmt.Errorf("NetworkDir must be set to create " +
×
47
                        "chainrpc")
×
48

49
        case config.ChainNotifier == nil:
×
50
                return nil, nil, fmt.Errorf("ChainNotifier must be set to " +
×
51
                        "create chainrpc")
×
52

53
        case config.Chain == nil:
×
54
                return nil, nil, fmt.Errorf("field Chain must be set to " +
×
55
                        "create chainrpc")
×
56
        }
57

58
        return New(config)
×
59
}
60

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

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