From 6b943a042ca9b4ab9791016b12e04683f1657398 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 4 Aug 2022 06:14:06 +0800 Subject: [PATCH] itest: refactor `testUpdateChannelPolicyFeeRateAccuracy` --- lntest/itest/list_on_test.go | 4 +++ lntest/itest/lnd_channel_policy_test.go | 36 ++++++++----------------- lntest/itest/lnd_test_list_on_test.go | 4 --- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/lntest/itest/list_on_test.go b/lntest/itest/list_on_test.go index c25ff6061..364bf04a7 100644 --- a/lntest/itest/list_on_test.go +++ b/lntest/itest/list_on_test.go @@ -147,4 +147,8 @@ var allTestCasesTemp = []*lntemp.TestCase{ Name: "private channel update policy", TestFunc: testUpdateChannelPolicyForPrivateChannel, }, + { + Name: "update channel policy fee rate accuracy", + TestFunc: testUpdateChannelPolicyFeeRateAccuracy, + }, } diff --git a/lntest/itest/lnd_channel_policy_test.go b/lntest/itest/lnd_channel_policy_test.go index b2369de62..236f0e73b 100644 --- a/lntest/itest/lnd_channel_policy_test.go +++ b/lntest/itest/lnd_channel_policy_test.go @@ -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 diff --git a/lntest/itest/lnd_test_list_on_test.go b/lntest/itest/lnd_test_list_on_test.go index e76c16753..f695e6834 100644 --- a/lntest/itest/lnd_test_list_on_test.go +++ b/lntest/itest/lnd_test_list_on_test.go @@ -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,