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

lightningnetwork / lnd / 13523316608

25 Feb 2025 02:12PM UTC coverage: 49.351% (-9.5%) from 58.835%
13523316608

Pull #9549

github

yyforyongyu
routing/chainview: refactor `TestFilteredChainView`

So each test has its own miner and chainView.
Pull Request #9549: Fix unit test flake `TestHistoricalConfDetailsTxIndex`

0 of 120 new or added lines in 1 file covered. (0.0%)

27196 existing lines in 434 files now uncovered.

100945 of 204543 relevant lines covered (49.35%)

1.54 hits per line

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

0.0
/lnwallet/chancloser/rbf_coop_msg_mapper.go
1
package chancloser
2

3
import (
4
        "github.com/lightningnetwork/lnd/fn/v2"
5
        "github.com/lightningnetwork/lnd/lnwire"
6
)
7

8
// RbfMsgMapper is a struct that implements the MsgMapper interface for the
9
// rbf-coop close state machine. This enables the state machine to be used with
10
// protofsm.
11
type RbfMsgMapper struct {
12
        // blockHeight is the height of the block when the co-op close request
13
        // was initiated. This is used to validate conditions related to the
14
        // thaw height.
15
        blockHeight uint32
16

17
        // chanID is the channel ID of the channel being closed.
18
        chanID lnwire.ChannelID
19
}
20

21
// NewRbfMsgMapper creates a new RbfMsgMapper instance given the current block
22
// height when the co-op close request was initiated.
23
func NewRbfMsgMapper(blockHeight uint32,
UNCOV
24
        chanID lnwire.ChannelID) *RbfMsgMapper {
×
UNCOV
25

×
UNCOV
26
        return &RbfMsgMapper{
×
UNCOV
27
                blockHeight: blockHeight,
×
UNCOV
28
                chanID:      chanID,
×
UNCOV
29
        }
×
UNCOV
30
}
×
31

32
// someEvent returns the target type as a protocol event option.
33
func someEvent[T ProtocolEvent](m T) fn.Option[ProtocolEvent] {
×
34
        return fn.Some(ProtocolEvent(m))
×
35
}
×
36

37
// isExpectedChanID returns true if the channel ID of the message matches the
38
// bound instance.
39
func (r *RbfMsgMapper) isExpectedChanID(chanID lnwire.ChannelID) bool {
×
40
        return r.chanID == chanID
×
41
}
×
42

43
// MapMsg maps a wire message into a FSM event. If the message is not mappable,
44
// then an error is returned.
45
func (r *RbfMsgMapper) MapMsg(wireMsg lnwire.Message) fn.Option[ProtocolEvent] {
×
46
        switch msg := wireMsg.(type) {
×
47
        case *lnwire.Shutdown:
×
48
                if !r.isExpectedChanID(msg.ChannelID) {
×
49
                        return fn.None[ProtocolEvent]()
×
50
                }
×
51

52
                return someEvent(&ShutdownReceived{
×
53
                        BlockHeight:    r.blockHeight,
×
54
                        ShutdownScript: msg.Address,
×
55
                })
×
56

57
        case *lnwire.ClosingComplete:
×
58
                if !r.isExpectedChanID(msg.ChannelID) {
×
59
                        return fn.None[ProtocolEvent]()
×
60
                }
×
61

62
                return someEvent(&OfferReceivedEvent{
×
63
                        SigMsg: *msg,
×
64
                })
×
65

66
        case *lnwire.ClosingSig:
×
67
                if !r.isExpectedChanID(msg.ChannelID) {
×
68
                        return fn.None[ProtocolEvent]()
×
69
                }
×
70

71
                return someEvent(&LocalSigReceived{
×
72
                        SigMsg: *msg,
×
73
                })
×
74
        }
75

76
        return fn.None[ProtocolEvent]()
×
77
}
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