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

lightningnetwork / lnd / 13233514377

10 Feb 2025 04:24AM UTC coverage: 49.335% (-9.5%) from 58.815%
13233514377

Pull #9492

github

yyforyongyu
itest: fix flake in `testForwardInterceptorRestart`

We need to make sure the links are recreated before calling the
interceptor, otherwise we'd get the following error, causing the test to
fail.
```
2025-02-07 15:01:38.991 [ERR] RPCS interceptor.go:624: [/routerrpc.Router/HtlcInterceptor]: fwd (Chan ID=487:3:0, HTLC ID=0) not found
```
Pull Request #9492: itest: fix flake in `testForwardInterceptorRestart`

100803 of 204322 relevant lines covered (49.34%)

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

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

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

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

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

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

45
        return block, nil
×
46
}
47

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

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

×
55
        select {
×
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