mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-11 09:21:38 +02:00
itest: refactor testUpdateChannelPolicyFeeRateAccuracy
This commit is contained in:
parent
cd7f02c866
commit
6b943a042c
@ -147,4 +147,8 @@ var allTestCasesTemp = []*lntemp.TestCase{
|
|||||||
Name: "private channel update policy",
|
Name: "private channel update policy",
|
||||||
TestFunc: testUpdateChannelPolicyForPrivateChannel,
|
TestFunc: testUpdateChannelPolicyForPrivateChannel,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "update channel policy fee rate accuracy",
|
||||||
|
TestFunc: testUpdateChannelPolicyFeeRateAccuracy,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package itest
|
package itest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
@ -771,24 +770,21 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntemp.HarnessTest) {
|
|||||||
// testUpdateChannelPolicyFeeRateAccuracy tests that updating the channel policy
|
// testUpdateChannelPolicyFeeRateAccuracy tests that updating the channel policy
|
||||||
// rounds fee rate values correctly as well as setting fee rate with ppm works
|
// rounds fee rate values correctly as well as setting fee rate with ppm works
|
||||||
// as expected.
|
// as expected.
|
||||||
func testUpdateChannelPolicyFeeRateAccuracy(net *lntest.NetworkHarness,
|
func testUpdateChannelPolicyFeeRateAccuracy(ht *lntemp.HarnessTest) {
|
||||||
t *harnessTest) {
|
|
||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := chanAmt / 2
|
pushAmt := chanAmt / 2
|
||||||
|
|
||||||
// Create a channel Alice -> Bob.
|
// Create a channel Alice -> Bob.
|
||||||
chanPoint := openChannelAndAssert(
|
alice, bob := ht.Alice, ht.Bob
|
||||||
t, net, net.Alice, net.Bob,
|
chanPoint := ht.OpenChannel(
|
||||||
lntest.OpenChannelParams{
|
alice, bob, lntemp.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
defer closeChannelAndAssert(t, net, net.Alice, chanPoint, false)
|
|
||||||
|
|
||||||
// Nodes that we need to make sure receive the channel updates.
|
// Nodes that we need to make sure receive the channel updates.
|
||||||
nodes := []*lntest.HarnessNode{net.Alice, net.Bob}
|
nodes := []*node.HarnessNode{alice, bob}
|
||||||
|
|
||||||
baseFee := int64(1500)
|
baseFee := int64(1500)
|
||||||
timeLockDelta := uint32(66)
|
timeLockDelta := uint32(66)
|
||||||
@ -823,17 +819,10 @@ func testUpdateChannelPolicyFeeRateAccuracy(net *lntest.NetworkHarness,
|
|||||||
ChanPoint: chanPoint,
|
ChanPoint: chanPoint,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
alice.RPC.UpdateChannelPolicy(req)
|
||||||
ctxb := context.Background()
|
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
|
||||||
if _, err := net.Alice.UpdateChannelPolicy(ctxt, req); err != nil {
|
|
||||||
t.Fatalf("unable to get alice's balance: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that both Alice and Bob sees the same policy after update.
|
// Make sure that both Alice and Bob sees the same policy after update.
|
||||||
assertPolicyUpdate(
|
assertNodesPolicyUpdate(ht, nodes, alice, expectedPolicy, chanPoint)
|
||||||
t, nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint,
|
|
||||||
)
|
|
||||||
|
|
||||||
// Now use the new PPM feerate field and make sure that the feerate is
|
// Now use the new PPM feerate field and make sure that the feerate is
|
||||||
// correctly set.
|
// correctly set.
|
||||||
@ -842,15 +831,12 @@ func testUpdateChannelPolicyFeeRateAccuracy(net *lntest.NetworkHarness,
|
|||||||
req.FeeRatePpm = feeRatePPM
|
req.FeeRatePpm = feeRatePPM
|
||||||
expectedPolicy.FeeRateMilliMsat = int64(feeRatePPM)
|
expectedPolicy.FeeRateMilliMsat = int64(feeRatePPM)
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
alice.RPC.UpdateChannelPolicy(req)
|
||||||
if _, err := net.Alice.UpdateChannelPolicy(ctxt, req); err != nil {
|
|
||||||
t.Fatalf("unable to get alice's balance: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that both Alice and Bob sees the same policy after update.
|
// Make sure that both Alice and Bob sees the same policy after update.
|
||||||
assertPolicyUpdate(
|
assertNodesPolicyUpdate(ht, nodes, alice, expectedPolicy, chanPoint)
|
||||||
t, nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint,
|
|
||||||
)
|
ht.CloseChannel(alice, chanPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// assertNodesPolicyUpdate checks that a given policy update has been received
|
// assertNodesPolicyUpdate checks that a given policy update has been received
|
||||||
|
@ -4,10 +4,6 @@
|
|||||||
package itest
|
package itest
|
||||||
|
|
||||||
var allTestCases = []*testCase{
|
var allTestCases = []*testCase{
|
||||||
{
|
|
||||||
name: "update channel policy fee rate accuracy",
|
|
||||||
test: testUpdateChannelPolicyFeeRateAccuracy,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "open channel reorg test",
|
name: "open channel reorg test",
|
||||||
test: testOpenChannelAfterReorg,
|
test: testOpenChannelAfterReorg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user