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

lightningnetwork / lnd / 13536249039

26 Feb 2025 03:42AM UTC coverage: 57.462% (-1.4%) from 58.835%
13536249039

Pull #8453

github

Roasbeef
peer: update chooseDeliveryScript to gen script if needed

In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
Pull Request #8453: [4/4] - multi: integrate new rbf coop close FSM into the existing peer flow

275 of 1318 new or added lines in 22 files covered. (20.86%)

19521 existing lines in 257 files now uncovered.

103858 of 180741 relevant lines covered (57.46%)

24750.23 hits per line

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

13.21
/build/config_dev.go
1
//go:build dev
2
// +build dev
3

4
package build
5

6
import (
7
        "fmt"
8
        "strings"
9

10
        btclogv1 "github.com/btcsuite/btclog"
11
        "github.com/btcsuite/btclog/v2"
12
)
13

14
const (
15
        resetSeq = "0"
16
        boldSeq  = "1"
17
        faintSeq = "2"
18
        esc      = '\x1b'
19
        csi      = string(esc) + "["
20
)
21

22
// consoleLoggerCfg extends the LoggerConfig struct by adding a Color option
23
// which is only available for a console logger.
24
//
25
//nolint:ll
26
type consoleLoggerCfg struct {
27
        LoggerConfig
28
        Style bool `long:"style" description:"If set, the output will be styled with color and fonts"`
29
}
30

31
// defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the dev
32
// console logger.
33
func defaultConsoleLoggerCfg() *consoleLoggerCfg {
1✔
34
        return &consoleLoggerCfg{
1✔
35
                LoggerConfig: LoggerConfig{
1✔
36
                        CallSite: callSiteShort,
1✔
37
                },
1✔
38
        }
1✔
39
}
1✔
40

41
// HandlerOptions returns the set of btclog.HandlerOptions that the state of the
42
// config struct translates to.
UNCOV
43
func (cfg *consoleLoggerCfg) HandlerOptions() []btclog.HandlerOption {
×
UNCOV
44
        opts := cfg.LoggerConfig.HandlerOptions()
×
UNCOV
45

×
UNCOV
46
        if !cfg.Style {
×
UNCOV
47
                return opts
×
UNCOV
48
        }
×
49

50
        return append(
×
51
                opts, btclog.WithStyledLevel(
×
52
                        func(l btclogv1.Level) string {
×
53
                                return styleString(
×
54
                                        fmt.Sprintf("[%s]", l),
×
55
                                        boldSeq,
×
56
                                        string(ansiColoSeq(l)),
×
57
                                )
×
58
                        },
×
59
                ),
60
                btclog.WithStyledCallSite(
61
                        func(file string, line int) string {
×
62
                                str := fmt.Sprintf("%s:%d", file, line)
×
63

×
64
                                return styleString(str, faintSeq)
×
65
                        },
×
66
                ),
67
                btclog.WithStyledKeys(func(key string) string {
×
68
                        return styleString(key, faintSeq)
×
69
                }),
×
70
        )
71
}
72

73
func styleString(s string, styles ...string) string {
×
74
        if len(styles) == 0 {
×
75
                return s
×
76
        }
×
77

78
        seq := strings.Join(styles, ";")
×
79
        if seq == "" {
×
80
                return s
×
81
        }
×
82

83
        return fmt.Sprintf("%s%sm%s%sm", csi, seq, s, csi+resetSeq)
×
84
}
85

86
type ansiColorSeq string
87

88
const (
89
        ansiColorSeqDarkTeal  ansiColorSeq = "38;5;30"
90
        ansiColorSeqDarkBlue  ansiColorSeq = "38;5;63"
91
        ansiColorSeqLightBlue ansiColorSeq = "38;5;86"
92
        ansiColorSeqYellow    ansiColorSeq = "38;5;192"
93
        ansiColorSeqRed       ansiColorSeq = "38;5;204"
94
        ansiColorSeqPink      ansiColorSeq = "38;5;134"
95
)
96

97
func ansiColoSeq(l btclogv1.Level) ansiColorSeq {
×
98
        switch l {
×
99
        case btclog.LevelTrace:
×
100
                return ansiColorSeqDarkTeal
×
101
        case btclog.LevelDebug:
×
102
                return ansiColorSeqDarkBlue
×
103
        case btclog.LevelWarn:
×
104
                return ansiColorSeqYellow
×
105
        case btclog.LevelError:
×
106
                return ansiColorSeqRed
×
107
        case btclog.LevelCritical:
×
108
                return ansiColorSeqPink
×
109
        default:
×
110
                return ansiColorSeqLightBlue
×
111
        }
112
}
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