From 7ab8900eb67cc4561198bc798a85ddacae9237b8 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Sat, 12 Jan 2019 18:59:43 +0100 Subject: [PATCH] discovery/gossiper_test: mock AddEdge: set capacity In this commit, we modify the mockGraphSource's `AddEdge` method to set the capacity of the edge it's adding to be a large capacity. This will enable us to test the validation of each ChannelUpdate's max HTLC, since future validation checks will ensure the specified max HTLC is less than total channel capacity. --- discovery/gossiper_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 230e0dd1..f8c510af 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -17,6 +17,7 @@ import ( "github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcutil" "github.com/davecgh/go-spew/spew" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/chainntnfs" @@ -54,9 +55,10 @@ var ( nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256()) nodeKeyPub2 = nodeKeyPriv2.PubKey() - trickleDelay = time.Millisecond * 100 - retransmitDelay = time.Hour * 1 - proofMatureDelta uint32 + trickleDelay = time.Millisecond * 100 + retransmitDelay = time.Hour * 1 + proofMatureDelta uint32 + maxBtcFundingAmount = btcutil.Amount(1<<62) - 1 ) // makeTestDB creates a new instance of the ChannelDB for testing purposes. A @@ -130,6 +132,10 @@ func (r *mockGraphSource) AddEdge(info *channeldb.ChannelEdgeInfo) error { if _, ok := r.infos[info.ChannelID]; ok { return errors.New("info already exist") } + + // Usually, the capacity is fetched in the router from the funding txout. + // Since the mockGraphSource can't access the txout, assign a default value. + info.Capacity = maxBtcFundingAmount r.infos[info.ChannelID] = info return nil }