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

lightningnetwork / lnd / 13586005509

28 Feb 2025 10:14AM UTC coverage: 68.629% (+9.9%) from 58.77%
13586005509

Pull #9521

github

web-flow
Merge 37d3a70a5 into 8532955b3
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

129950 of 189351 relevant lines covered (68.63%)

23726.46 hits per line

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

92.59
/lnwire/channel_type.go
1
package lnwire
2

3
import (
4
        "io"
5

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

9
const (
10
        // ChannelTypeRecordType is the type of the experimental record used
11
        // to denote which channel type is being negotiated.
12
        ChannelTypeRecordType tlv.Type = 1
13
)
14

15
// ChannelType represents a specific channel type as a set of feature bits that
16
// comprise it.
17
type ChannelType RawFeatureVector
18

19
// featureBitLen returns the length in bytes of the encoded feature bits.
20
func (c ChannelType) featureBitLen() uint64 {
241✔
21
        fv := RawFeatureVector(c)
241✔
22
        return fv.sizeFunc()
241✔
23
}
241✔
24

25
// Record returns a TLV record that can be used to encode/decode the channel
26
// type from a given TLV stream.
27
func (c *ChannelType) Record() tlv.Record {
618✔
28
        return tlv.MakeDynamicRecord(
618✔
29
                ChannelTypeRecordType, c, c.featureBitLen, channelTypeEncoder,
618✔
30
                channelTypeDecoder,
618✔
31
        )
618✔
32
}
618✔
33

34
// channelTypeEncoder is a custom TLV encoder for the ChannelType record.
35
func channelTypeEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
241✔
36
        if v, ok := val.(*ChannelType); ok {
482✔
37
                fv := RawFeatureVector(*v)
241✔
38
                return rawFeatureEncoder(w, &fv, buf)
241✔
39
        }
241✔
40

41
        return tlv.NewTypeForEncodingErr(val, "*lnwire.ChannelType")
×
42
}
43

44
// channelTypeDecoder is a custom TLV decoder for the ChannelType record.
45
func channelTypeDecoder(r io.Reader, val interface{}, buf *[8]byte,
46
        l uint64) error {
347✔
47

347✔
48
        if v, ok := val.(*ChannelType); ok {
694✔
49
                fv := NewRawFeatureVector()
347✔
50

347✔
51
                if err := rawFeatureDecoder(r, fv, buf, l); err != nil {
350✔
52
                        return err
3✔
53
                }
3✔
54

55
                *v = ChannelType(*fv)
344✔
56
                return nil
344✔
57
        }
58

59
        return tlv.NewTypeForEncodingErr(val, "*lnwire.ChannelType")
×
60
}
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