multi: move bandwidth hints behind interface

This commit is contained in:
carla
2021-10-19 09:37:44 +02:00
parent e6c65f1cbd
commit 45de686d35
15 changed files with 369 additions and 134 deletions

View File

@@ -18,6 +18,21 @@ const (
targetNodeID = 2
)
type mockBandwidthHints struct {
hints map[uint64]lnwire.MilliSatoshi
}
func (m *mockBandwidthHints) availableChanBandwidth(channelID uint64) (
lnwire.MilliSatoshi, bool) {
if m.hints == nil {
return 0, false
}
balance, ok := m.hints[channelID]
return balance, ok
}
// integratedRoutingContext defines the context in which integrated routing
// tests run.
type integratedRoutingContext struct {
@@ -130,14 +145,16 @@ func (c *integratedRoutingContext) testPayment(maxParts uint32,
c.t.Fatal(err)
}
getBandwidthHints := func() (map[uint64]lnwire.MilliSatoshi, error) {
getBandwidthHints := func() (bandwidthHints, error) {
// Create bandwidth hints based on local channel balances.
bandwidthHints := map[uint64]lnwire.MilliSatoshi{}
for _, ch := range c.graph.nodes[c.source.pubkey].channels {
bandwidthHints[ch.id] = ch.balance
}
return bandwidthHints, nil
return &mockBandwidthHints{
hints: bandwidthHints,
}, nil
}
var paymentAddr [32]byte