Skip to content

Commit ef069b6

Browse files
committed
itest: preparatory fee estimation changes
1 parent 7d9589e commit ef069b6

File tree

5 files changed

+46
-41
lines changed

5 files changed

+46
-41
lines changed

itest/lnd_amp_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
8989
// Increase Dave's fee to make the test deterministic. Otherwise it
9090
// would be unpredictable whether pathfinding would go through Charlie
9191
// or Dave for the first shard.
92-
expectedPolicy := mts.updateDaveGlobalPolicy()
92+
expectedPolicy := &lnrpc.RoutingPolicy{
93+
FeeBaseMsat: 500_000,
94+
FeeRateMilliMsat: int64(0.001 * 1_000_000),
95+
TimeLockDelta: 40,
96+
MinHtlc: 1000, // default value
97+
MaxHtlcMsat: 133_650_000,
98+
}
99+
mts.dave.UpdateGlobalPolicy(expectedPolicy)
93100

94101
// Make sure Alice has heard it for both Dave's channels.
95102
ht.AssertChannelPolicyUpdate(
@@ -382,10 +389,17 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {
382389
mts.openChannels(mppReq)
383390
chanPointAliceDave := mts.channelPoints[1]
384391

385-
// Increase Dave's fee to make the test deterministic. Otherwise it
392+
// Increase Dave's fee to make the test deterministic. Otherwise, it
386393
// would be unpredictable whether pathfinding would go through Charlie
387394
// or Dave for the first shard.
388-
expectedPolicy := mts.updateDaveGlobalPolicy()
395+
expectedPolicy := &lnrpc.RoutingPolicy{
396+
FeeBaseMsat: 500_000,
397+
FeeRateMilliMsat: int64(0.001 * 1_000_000),
398+
TimeLockDelta: 40,
399+
MinHtlc: 1000, // default value
400+
MaxHtlcMsat: 133_650_000,
401+
}
402+
mts.dave.UpdateGlobalPolicy(expectedPolicy)
389403

390404
// Make sure Alice has heard it.
391405
ht.AssertChannelPolicyUpdate(
@@ -493,7 +507,7 @@ func testSendToRouteAMP(ht *lntest.HarnessTest) {
493507
// Alice -- Carol ---- Bob
494508
// \ /
495509
// \__ Dave ____/
496-
///
510+
//
497511
mppReq := &mppOpenChannelRequest{
498512
// Since the channel Alice-> Carol will have to carry two
499513
// shards, we make it larger.

itest/lnd_mpp_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -347,33 +347,3 @@ func (m *mppTestScenario) buildRoute(amt btcutil.Amount,
347347

348348
return routeResp.Route
349349
}
350-
351-
// updatePolicy updates a Dave's global channel policy and returns the expected
352-
// policy for further check. It changes Dave's `FeeBaseMsat` from 1000 msat to
353-
// 500,000 msat, and `FeeProportionalMillonths` from 1 msat to 1000 msat.
354-
func (m *mppTestScenario) updateDaveGlobalPolicy() *lnrpc.RoutingPolicy {
355-
const (
356-
baseFeeMsat = 500_000
357-
feeRate = 0.001
358-
maxHtlcMsat = 133_650_000
359-
)
360-
361-
expectedPolicy := &lnrpc.RoutingPolicy{
362-
FeeBaseMsat: baseFeeMsat,
363-
FeeRateMilliMsat: feeRate * testFeeBase,
364-
TimeLockDelta: 40,
365-
MinHtlc: 1000, // default value
366-
MaxHtlcMsat: maxHtlcMsat,
367-
}
368-
369-
updateFeeReq := &lnrpc.PolicyUpdateRequest{
370-
BaseFeeMsat: baseFeeMsat,
371-
FeeRate: feeRate,
372-
TimeLockDelta: 40,
373-
Scope: &lnrpc.PolicyUpdateRequest_Global{Global: true},
374-
MaxHtlcMsat: maxHtlcMsat,
375-
}
376-
m.dave.RPC.UpdateChannelPolicy(updateFeeReq)
377-
378-
return expectedPolicy
379-
}

itest/lnd_send_multi_path_payment_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,17 @@ func testSendMultiPathPayment(ht *lntest.HarnessTest) {
3838
mts.openChannels(req)
3939
chanPointAliceDave := mts.channelPoints[1]
4040

41-
// Increase Dave's fee to make the test deterministic. Otherwise it
41+
// Increase Dave's fee to make the test deterministic. Otherwise, it
4242
// would be unpredictable whether pathfinding would go through Charlie
4343
// or Dave for the first shard.
44-
expectedPolicy := mts.updateDaveGlobalPolicy()
44+
expectedPolicy := &lnrpc.RoutingPolicy{
45+
FeeBaseMsat: 500_000,
46+
FeeRateMilliMsat: int64(0.001 * 1_000_000),
47+
TimeLockDelta: 40,
48+
MinHtlc: 1000, // default value
49+
MaxHtlcMsat: 133_650_000,
50+
}
51+
mts.dave.UpdateGlobalPolicy(expectedPolicy)
4552

4653
// Make sure Alice has heard it.
4754
ht.AssertChannelPolicyUpdate(

lntest/harness.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,8 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
16141614
// CreatePayReqs is a helper method that will create a slice of payment
16151615
// requests for the given node.
16161616
func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode,
1617-
paymentAmt btcutil.Amount, numInvoices int) ([]string,
1618-
[][]byte, []*lnrpc.Invoice) {
1617+
paymentAmt btcutil.Amount, numInvoices int,
1618+
routeHints ...*lnrpc.RouteHint) ([]string, [][]byte, []*lnrpc.Invoice) {
16191619

16201620
payReqs := make([]string, numInvoices)
16211621
rHashes := make([][]byte, numInvoices)
@@ -1624,9 +1624,10 @@ func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode,
16241624
preimage := h.Random32Bytes()
16251625

16261626
invoice := &lnrpc.Invoice{
1627-
Memo: "testing",
1628-
RPreimage: preimage,
1629-
Value: int64(paymentAmt),
1627+
Memo: "testing",
1628+
RPreimage: preimage,
1629+
Value: int64(paymentAmt),
1630+
RouteHints: routeHints,
16301631
}
16311632
resp := hn.RPC.AddInvoice(invoice)
16321633

lntest/node/harness_node.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,19 @@ func (hn *HarnessNode) RestoreDB() error {
876876
return nil
877877
}
878878

879+
// UpdateGlobalPolicy updates a node's global channel policy.
880+
func (hn *HarnessNode) UpdateGlobalPolicy(policy *lnrpc.RoutingPolicy) {
881+
updateFeeReq := &lnrpc.PolicyUpdateRequest{
882+
BaseFeeMsat: policy.FeeBaseMsat,
883+
FeeRate: float64(policy.FeeRateMilliMsat) /
884+
float64(1_000_000),
885+
TimeLockDelta: policy.TimeLockDelta,
886+
Scope: &lnrpc.PolicyUpdateRequest_Global{Global: true},
887+
MaxHtlcMsat: policy.MaxHtlcMsat,
888+
}
889+
hn.RPC.UpdateChannelPolicy(updateFeeReq)
890+
}
891+
879892
func postgresDatabaseDsn(dbName string) string {
880893
return fmt.Sprintf(postgresDsn, dbName)
881894
}

0 commit comments

Comments
 (0)