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.
This commit is contained in:
parent
b49637fbe9
commit
7ab8900eb6
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
@ -54,9 +55,10 @@ var (
|
|||||||
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
|
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
|
||||||
nodeKeyPub2 = nodeKeyPriv2.PubKey()
|
nodeKeyPub2 = nodeKeyPriv2.PubKey()
|
||||||
|
|
||||||
trickleDelay = time.Millisecond * 100
|
trickleDelay = time.Millisecond * 100
|
||||||
retransmitDelay = time.Hour * 1
|
retransmitDelay = time.Hour * 1
|
||||||
proofMatureDelta uint32
|
proofMatureDelta uint32
|
||||||
|
maxBtcFundingAmount = btcutil.Amount(1<<62) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
// 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 {
|
if _, ok := r.infos[info.ChannelID]; ok {
|
||||||
return errors.New("info already exist")
|
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
|
r.infos[info.ChannelID] = info
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user