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

lightningnetwork / lnd / 13211764208

08 Feb 2025 03:08AM UTC coverage: 49.288% (-9.5%) from 58.815%
13211764208

Pull #9489

github

calvinrzachman
itest: verify switchrpc server enforces send then track

We prevent the rpc server from allowing onion dispatches for
attempt IDs which have already been tracked by rpc clients.

This helps protect the client from leaking a duplicate onion
attempt. NOTE: This is not the only method for solving this
issue! The issue could be addressed via careful client side
programming which accounts for the uncertainty and async
nature of dispatching onions to a remote process via RPC.
This would require some lnd ChannelRouter changes for how
we intend to use these RPCs though.
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

474 of 990 new or added lines in 11 files covered. (47.88%)

27321 existing lines in 435 files now uncovered.

101192 of 205306 relevant lines covered (49.29%)

1.54 hits per line

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

0.0
/watchtower/lookout/mock.go
1
package lookout
2

3
import (
4
        "fmt"
5
        "sync"
6

7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "github.com/btcsuite/btcd/wire"
9
        "github.com/lightningnetwork/lnd/chainntnfs"
10
)
11

12
type MockBackend struct {
13
        mu sync.RWMutex
14

15
        blocks chan *chainntnfs.BlockEpoch
16
        epochs map[chainhash.Hash]*wire.MsgBlock
17
        quit   chan struct{}
18
}
19

UNCOV
20
func NewMockBackend() *MockBackend {
×
UNCOV
21
        return &MockBackend{
×
UNCOV
22
                blocks: make(chan *chainntnfs.BlockEpoch),
×
UNCOV
23
                epochs: make(map[chainhash.Hash]*wire.MsgBlock),
×
UNCOV
24
                quit:   make(chan struct{}),
×
UNCOV
25
        }
×
UNCOV
26
}
×
27

28
func (m *MockBackend) RegisterBlockEpochNtfn(*chainntnfs.BlockEpoch) (
UNCOV
29
        *chainntnfs.BlockEpochEvent, error) {
×
UNCOV
30

×
UNCOV
31
        return &chainntnfs.BlockEpochEvent{
×
UNCOV
32
                Epochs: m.blocks,
×
UNCOV
33
        }, nil
×
UNCOV
34
}
×
35

UNCOV
36
func (m *MockBackend) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error) {
×
UNCOV
37
        m.mu.RLock()
×
UNCOV
38
        defer m.mu.RUnlock()
×
UNCOV
39

×
UNCOV
40
        block, ok := m.epochs[*hash]
×
UNCOV
41
        if !ok {
×
42
                return nil, fmt.Errorf("unknown block for hash %x", hash)
×
43
        }
×
44

UNCOV
45
        return block, nil
×
46
}
47

48
func (m *MockBackend) ConnectEpoch(epoch *chainntnfs.BlockEpoch,
UNCOV
49
        block *wire.MsgBlock) {
×
UNCOV
50

×
UNCOV
51
        m.mu.Lock()
×
UNCOV
52
        m.epochs[*epoch.Hash] = block
×
UNCOV
53
        m.mu.Unlock()
×
UNCOV
54

×
UNCOV
55
        select {
×
UNCOV
56
        case m.blocks <- epoch:
×
57
        case <-m.quit:
×
58
        }
59
}
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