mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
itest: preparatory fee estimation changes
This commit is contained in:
@@ -89,7 +89,14 @@ func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
|
|||||||
// Increase Dave's fee to make the test deterministic. Otherwise it
|
// Increase Dave's fee to make the test deterministic. Otherwise it
|
||||||
// would be unpredictable whether pathfinding would go through Charlie
|
// would be unpredictable whether pathfinding would go through Charlie
|
||||||
// or Dave for the first shard.
|
// or Dave for the first shard.
|
||||||
expectedPolicy := mts.updateDaveGlobalPolicy()
|
expectedPolicy := &lnrpc.RoutingPolicy{
|
||||||
|
FeeBaseMsat: 500_000,
|
||||||
|
FeeRateMilliMsat: int64(0.001 * 1_000_000),
|
||||||
|
TimeLockDelta: 40,
|
||||||
|
MinHtlc: 1000, // default value
|
||||||
|
MaxHtlcMsat: 133_650_000,
|
||||||
|
}
|
||||||
|
mts.dave.UpdateGlobalPolicy(expectedPolicy)
|
||||||
|
|
||||||
// Make sure Alice has heard it for both Dave's channels.
|
// Make sure Alice has heard it for both Dave's channels.
|
||||||
ht.AssertChannelPolicyUpdate(
|
ht.AssertChannelPolicyUpdate(
|
||||||
@@ -382,10 +389,17 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {
|
|||||||
mts.openChannels(mppReq)
|
mts.openChannels(mppReq)
|
||||||
chanPointAliceDave := mts.channelPoints[1]
|
chanPointAliceDave := mts.channelPoints[1]
|
||||||
|
|
||||||
// Increase Dave's fee to make the test deterministic. Otherwise it
|
// Increase Dave's fee to make the test deterministic. Otherwise, it
|
||||||
// would be unpredictable whether pathfinding would go through Charlie
|
// would be unpredictable whether pathfinding would go through Charlie
|
||||||
// or Dave for the first shard.
|
// or Dave for the first shard.
|
||||||
expectedPolicy := mts.updateDaveGlobalPolicy()
|
expectedPolicy := &lnrpc.RoutingPolicy{
|
||||||
|
FeeBaseMsat: 500_000,
|
||||||
|
FeeRateMilliMsat: int64(0.001 * 1_000_000),
|
||||||
|
TimeLockDelta: 40,
|
||||||
|
MinHtlc: 1000, // default value
|
||||||
|
MaxHtlcMsat: 133_650_000,
|
||||||
|
}
|
||||||
|
mts.dave.UpdateGlobalPolicy(expectedPolicy)
|
||||||
|
|
||||||
// Make sure Alice has heard it.
|
// Make sure Alice has heard it.
|
||||||
ht.AssertChannelPolicyUpdate(
|
ht.AssertChannelPolicyUpdate(
|
||||||
@@ -493,7 +507,7 @@ func testSendToRouteAMP(ht *lntest.HarnessTest) {
|
|||||||
// Alice -- Carol ---- Bob
|
// Alice -- Carol ---- Bob
|
||||||
// \ /
|
// \ /
|
||||||
// \__ Dave ____/
|
// \__ Dave ____/
|
||||||
///
|
//
|
||||||
mppReq := &mppOpenChannelRequest{
|
mppReq := &mppOpenChannelRequest{
|
||||||
// Since the channel Alice-> Carol will have to carry two
|
// Since the channel Alice-> Carol will have to carry two
|
||||||
// shards, we make it larger.
|
// shards, we make it larger.
|
||||||
|
@@ -347,33 +347,3 @@ func (m *mppTestScenario) buildRoute(amt btcutil.Amount,
|
|||||||
|
|
||||||
return routeResp.Route
|
return routeResp.Route
|
||||||
}
|
}
|
||||||
|
|
||||||
// updatePolicy updates a Dave's global channel policy and returns the expected
|
|
||||||
// policy for further check. It changes Dave's `FeeBaseMsat` from 1000 msat to
|
|
||||||
// 500,000 msat, and `FeeProportionalMillonths` from 1 msat to 1000 msat.
|
|
||||||
func (m *mppTestScenario) updateDaveGlobalPolicy() *lnrpc.RoutingPolicy {
|
|
||||||
const (
|
|
||||||
baseFeeMsat = 500_000
|
|
||||||
feeRate = 0.001
|
|
||||||
maxHtlcMsat = 133_650_000
|
|
||||||
)
|
|
||||||
|
|
||||||
expectedPolicy := &lnrpc.RoutingPolicy{
|
|
||||||
FeeBaseMsat: baseFeeMsat,
|
|
||||||
FeeRateMilliMsat: feeRate * testFeeBase,
|
|
||||||
TimeLockDelta: 40,
|
|
||||||
MinHtlc: 1000, // default value
|
|
||||||
MaxHtlcMsat: maxHtlcMsat,
|
|
||||||
}
|
|
||||||
|
|
||||||
updateFeeReq := &lnrpc.PolicyUpdateRequest{
|
|
||||||
BaseFeeMsat: baseFeeMsat,
|
|
||||||
FeeRate: feeRate,
|
|
||||||
TimeLockDelta: 40,
|
|
||||||
Scope: &lnrpc.PolicyUpdateRequest_Global{Global: true},
|
|
||||||
MaxHtlcMsat: maxHtlcMsat,
|
|
||||||
}
|
|
||||||
m.dave.RPC.UpdateChannelPolicy(updateFeeReq)
|
|
||||||
|
|
||||||
return expectedPolicy
|
|
||||||
}
|
|
||||||
|
@@ -38,10 +38,17 @@ func testSendMultiPathPayment(ht *lntest.HarnessTest) {
|
|||||||
mts.openChannels(req)
|
mts.openChannels(req)
|
||||||
chanPointAliceDave := mts.channelPoints[1]
|
chanPointAliceDave := mts.channelPoints[1]
|
||||||
|
|
||||||
// Increase Dave's fee to make the test deterministic. Otherwise it
|
// Increase Dave's fee to make the test deterministic. Otherwise, it
|
||||||
// would be unpredictable whether pathfinding would go through Charlie
|
// would be unpredictable whether pathfinding would go through Charlie
|
||||||
// or Dave for the first shard.
|
// or Dave for the first shard.
|
||||||
expectedPolicy := mts.updateDaveGlobalPolicy()
|
expectedPolicy := &lnrpc.RoutingPolicy{
|
||||||
|
FeeBaseMsat: 500_000,
|
||||||
|
FeeRateMilliMsat: int64(0.001 * 1_000_000),
|
||||||
|
TimeLockDelta: 40,
|
||||||
|
MinHtlc: 1000, // default value
|
||||||
|
MaxHtlcMsat: 133_650_000,
|
||||||
|
}
|
||||||
|
mts.dave.UpdateGlobalPolicy(expectedPolicy)
|
||||||
|
|
||||||
// Make sure Alice has heard it.
|
// Make sure Alice has heard it.
|
||||||
ht.AssertChannelPolicyUpdate(
|
ht.AssertChannelPolicyUpdate(
|
||||||
|
@@ -1614,8 +1614,8 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
|
|||||||
// CreatePayReqs is a helper method that will create a slice of payment
|
// CreatePayReqs is a helper method that will create a slice of payment
|
||||||
// requests for the given node.
|
// requests for the given node.
|
||||||
func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode,
|
func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode,
|
||||||
paymentAmt btcutil.Amount, numInvoices int) ([]string,
|
paymentAmt btcutil.Amount, numInvoices int,
|
||||||
[][]byte, []*lnrpc.Invoice) {
|
routeHints ...*lnrpc.RouteHint) ([]string, [][]byte, []*lnrpc.Invoice) {
|
||||||
|
|
||||||
payReqs := make([]string, numInvoices)
|
payReqs := make([]string, numInvoices)
|
||||||
rHashes := make([][]byte, numInvoices)
|
rHashes := make([][]byte, numInvoices)
|
||||||
@@ -1624,9 +1624,10 @@ func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode,
|
|||||||
preimage := h.Random32Bytes()
|
preimage := h.Random32Bytes()
|
||||||
|
|
||||||
invoice := &lnrpc.Invoice{
|
invoice := &lnrpc.Invoice{
|
||||||
Memo: "testing",
|
Memo: "testing",
|
||||||
RPreimage: preimage,
|
RPreimage: preimage,
|
||||||
Value: int64(paymentAmt),
|
Value: int64(paymentAmt),
|
||||||
|
RouteHints: routeHints,
|
||||||
}
|
}
|
||||||
resp := hn.RPC.AddInvoice(invoice)
|
resp := hn.RPC.AddInvoice(invoice)
|
||||||
|
|
||||||
|
@@ -876,6 +876,19 @@ func (hn *HarnessNode) RestoreDB() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateGlobalPolicy updates a node's global channel policy.
|
||||||
|
func (hn *HarnessNode) UpdateGlobalPolicy(policy *lnrpc.RoutingPolicy) {
|
||||||
|
updateFeeReq := &lnrpc.PolicyUpdateRequest{
|
||||||
|
BaseFeeMsat: policy.FeeBaseMsat,
|
||||||
|
FeeRate: float64(policy.FeeRateMilliMsat) /
|
||||||
|
float64(1_000_000),
|
||||||
|
TimeLockDelta: policy.TimeLockDelta,
|
||||||
|
Scope: &lnrpc.PolicyUpdateRequest_Global{Global: true},
|
||||||
|
MaxHtlcMsat: policy.MaxHtlcMsat,
|
||||||
|
}
|
||||||
|
hn.RPC.UpdateChannelPolicy(updateFeeReq)
|
||||||
|
}
|
||||||
|
|
||||||
func postgresDatabaseDsn(dbName string) string {
|
func postgresDatabaseDsn(dbName string) string {
|
||||||
return fmt.Sprintf(postgresDsn, dbName)
|
return fmt.Sprintf(postgresDsn, dbName)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user