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