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

lightningnetwork / lnd / 12430760174

20 Dec 2024 11:38AM UTC coverage: 58.684% (-0.03%) from 58.716%
12430760174

Pull #9368

github

yyforyongyu
itest: fix flake in `testCoopCloseWithExternalDeliveryImpl`

The response from `ClosedChannels` may not be up-to-date, so we wrap it
inside a wait closure.
Pull Request #9368: Fix itest re new behaviors introduced by `blockbeat`

2 of 240 new or added lines in 10 files covered. (0.83%)

228 existing lines in 43 files now uncovered.

135182 of 230357 relevant lines covered (58.68%)

19128.77 hits per line

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

0.0
/itest/lnd_custom_features.go
1
package itest
2

3
import (
4
        "fmt"
5

6
        "github.com/lightningnetwork/lnd/lnrpc"
7
        "github.com/lightningnetwork/lnd/lnrpc/peersrpc"
8
        "github.com/lightningnetwork/lnd/lntest"
9
        "github.com/stretchr/testify/require"
10
)
11

12
// testCustomFeatures tests advertisement of custom features in various bolt 9
13
// sets. For completeness, it also asserts that features aren't set in places
14
// where they aren't intended to be.
15
func testCustomFeatures(ht *lntest.HarnessTest) {
×
16
        var (
×
17
                // Odd custom features so that we don't need to worry about
×
18
                // issues connecting to peers.
×
19
                customInit    uint32 = 101
×
20
                customNodeAnn uint32 = 103
×
21
                customInvoice uint32 = 105
×
22
        )
×
23

×
24
        // Restart Alice with custom feature bits configured.
×
25
        extraArgs := []string{
×
26
                fmt.Sprintf("--protocol.custom-init=%v", customInit),
×
27
                fmt.Sprintf("--protocol.custom-nodeann=%v", customNodeAnn),
×
28
                fmt.Sprintf("--protocol.custom-invoice=%v", customInvoice),
×
29
        }
×
NEW
30
        cfgs := [][]string{extraArgs, nil}
×
31

×
NEW
32
        _, nodes := ht.CreateSimpleNetwork(
×
NEW
33
                cfgs, lntest.OpenChannelParams{Amt: 1000000},
×
34
        )
×
NEW
35
        alice, bob := nodes[0], nodes[1]
×
36

×
37
        // Check that Alice's custom feature bit was sent to Bob in her init
×
38
        // message.
×
NEW
39
        peers := bob.RPC.ListPeers()
×
40
        require.Len(ht, peers.Peers, 1)
×
NEW
41
        require.Equal(ht, peers.Peers[0].PubKey, alice.PubKeyStr)
×
42

×
43
        _, customInitSet := peers.Peers[0].Features[customInit]
×
44
        require.True(ht, customInitSet)
×
45
        assertFeatureNotInSet(
×
46
                ht, []uint32{customNodeAnn, customInvoice},
×
47
                peers.Peers[0].Features,
×
48
        )
×
49

×
50
        // Assert that Alice's custom feature bit is contained in the node
×
51
        // announcement sent to Bob.
×
NEW
52
        updates := ht.AssertNumNodeAnns(bob, alice.PubKeyStr, 1)
×
53
        features := updates[len(updates)-1].Features
×
54
        _, customFeature := features[customNodeAnn]
×
55
        require.True(ht, customFeature)
×
56
        assertFeatureNotInSet(
×
57
                ht, []uint32{customInit, customInvoice}, features,
×
58
        )
×
59

×
60
        // Assert that Alice's custom feature bit is included in invoices.
×
NEW
61
        invoice := alice.RPC.AddInvoice(&lnrpc.Invoice{})
×
NEW
62
        payReq := alice.RPC.DecodePayReq(invoice.PaymentRequest)
×
63
        _, customInvoiceSet := payReq.Features[customInvoice]
×
64
        require.True(ht, customInvoiceSet)
×
65
        assertFeatureNotInSet(
×
66
                ht, []uint32{customInit, customNodeAnn}, payReq.Features,
×
67
        )
×
68

×
69
        // Check that Alice can't unset configured features via the node
×
70
        // announcement update API. This is only checked for node announcement
×
71
        // because it is the only set that can be updated via the API.
×
72
        nodeAnnReq := &peersrpc.NodeAnnouncementUpdateRequest{
×
73
                FeatureUpdates: []*peersrpc.UpdateFeatureAction{
×
74
                        {
×
75
                                Action:     peersrpc.UpdateAction_ADD,
×
76
                                FeatureBit: lnrpc.FeatureBit(customNodeAnn),
×
77
                        },
×
78
                },
×
79
        }
×
NEW
80
        alice.RPC.UpdateNodeAnnouncementErr(nodeAnnReq)
×
81
}
×
82

83
// assertFeatureNotInSet checks that the features provided aren't contained in
84
// a feature map.
85
func assertFeatureNotInSet(ht *lntest.HarnessTest, features []uint32,
86
        advertised map[uint32]*lnrpc.Feature) {
×
87

×
88
        for _, feature := range features {
×
89
                _, featureSet := advertised[feature]
×
90
                require.False(ht, featureSet)
×
91
        }
×
92
}
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