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

lightningnetwork / lnd / 12012751795

25 Nov 2024 02:40PM UTC coverage: 49.835% (-9.2%) from 59.013%
12012751795

Pull #9303

github

yyforyongyu
lnwallet: add debug logs
Pull Request #9303: htlcswitch+routing: handle nil pointer dereference properly

20 of 23 new or added lines in 4 files covered. (86.96%)

25467 existing lines in 425 files now uncovered.

99835 of 200331 relevant lines covered (49.84%)

2.07 hits per line

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

68.75
/watchtower/wtserver/delete_session.go
1
package wtserver
2

3
import (
4
        "github.com/lightningnetwork/lnd/watchtower/wtdb"
5
        "github.com/lightningnetwork/lnd/watchtower/wtwire"
6
)
7

8
// handleDeleteSession processes a DeleteSession request for a client with given
9
// SessionID. The id is assumed to have been previously authenticated by the
10
// brontide connection.
11
func (s *Server) handleDeleteSession(peer Peer, id *wtdb.SessionID) error {
4✔
12
        var failCode wtwire.DeleteSessionCode
4✔
13

4✔
14
        // Delete all session data associated with id.
4✔
15
        err := s.cfg.DB.DeleteSession(*id)
4✔
16
        switch {
4✔
17
        case err == nil:
4✔
18
                failCode = wtwire.CodeOK
4✔
19

4✔
20
                log.Debugf("Session %s deleted", id)
4✔
21

UNCOV
22
        case err == wtdb.ErrSessionNotFound:
×
UNCOV
23
                failCode = wtwire.DeleteSessionCodeNotFound
×
24

25
        default:
×
26
                failCode = wtwire.CodeTemporaryFailure
×
27
        }
28

29
        return s.replyDeleteSession(peer, id, failCode)
4✔
30
}
31

32
// replyDeleteSession sends a DeleteSessionReply back to the peer containing the
33
// error code resulting from processes a DeleteSession request.
34
func (s *Server) replyDeleteSession(peer Peer, id *wtdb.SessionID,
35
        code wtwire.DeleteSessionCode) error {
4✔
36

4✔
37
        msg := &wtwire.DeleteSessionReply{
4✔
38
                Code: code,
4✔
39
        }
4✔
40

4✔
41
        err := s.sendMessage(peer, msg)
4✔
42
        if err != nil {
4✔
43
                log.Errorf("Unable to send DeleteSessionReply to %s", id)
×
44
        }
×
45

46
        // Return the write error if the request succeeded.
47
        if code == wtwire.CodeOK {
8✔
48
                return err
4✔
49
        }
4✔
50

51
        // Otherwise the request failed, return a connection failure to
52
        // disconnect the client.
UNCOV
53
        return &connFailure{
×
UNCOV
54
                ID:   *id,
×
UNCOV
55
                Code: code,
×
UNCOV
56
        }
×
57
}
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