From efae8ea56f5c36ff8dd90fd574b959416e2141c9 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sat, 9 Nov 2024 15:14:53 +0800 Subject: [PATCH] itest: break down single hop send to route Also removed the duplicate test cases. --- itest/list_on_test.go | 5 +-- itest/lnd_routing_test.go | 70 +++++++++++++-------------------------- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/itest/list_on_test.go b/itest/list_on_test.go index 73016dd92..b0146f16b 100644 --- a/itest/list_on_test.go +++ b/itest/list_on_test.go @@ -300,10 +300,6 @@ var allTestCases = []*lntest.TestCase{ Name: "revoked uncooperative close retribution remote hodl", TestFunc: testRevokedCloseRetributionRemoteHodl, }, - { - Name: "single-hop send to route", - TestFunc: testSingleHopSendToRoute, - }, { Name: "multi-hop send to route", TestFunc: testMultiHopSendToRoute, @@ -678,4 +674,5 @@ func init() { allTestCases = append(allTestCases, channelFeePolicyTestCases...) allTestCases = append(allTestCases, walletImportAccountTestCases...) allTestCases = append(allTestCases, basicFundingTestCases...) + allTestCases = append(allTestCases, sendToRouteTestCases...) } diff --git a/itest/lnd_routing_test.go b/itest/lnd_routing_test.go index 950b24d24..c32e021d4 100644 --- a/itest/lnd_routing_test.go +++ b/itest/lnd_routing_test.go @@ -20,46 +20,33 @@ import ( "google.golang.org/protobuf/proto" ) -type singleHopSendToRouteCase struct { - name string - - // streaming tests streaming SendToRoute if true, otherwise tests - // synchronous SenToRoute. - streaming bool - - // routerrpc submits the request to the routerrpc subserver if true, - // otherwise submits to the main rpc server. - routerrpc bool -} - -var singleHopSendToRouteCases = []singleHopSendToRouteCase{ +var sendToRouteTestCases = []*lntest.TestCase{ { - name: "regular main sync", + Name: "single hop send to route sync", + TestFunc: func(ht *lntest.HarnessTest) { + // useStream: false, routerrpc: false. + testSingleHopSendToRouteCase(ht, false, false) + }, }, { - name: "regular main stream", - streaming: true, + Name: "single hop send to route stream", + TestFunc: func(ht *lntest.HarnessTest) { + // useStream: true, routerrpc: false. + testSingleHopSendToRouteCase(ht, true, false) + }, }, { - name: "regular routerrpc sync", - routerrpc: true, - }, - { - name: "mpp main sync", - }, - { - name: "mpp main stream", - streaming: true, - }, - { - name: "mpp routerrpc sync", - routerrpc: true, + Name: "single hop send to route v2", + TestFunc: func(ht *lntest.HarnessTest) { + // useStream: false, routerrpc: true. + testSingleHopSendToRouteCase(ht, false, true) + }, }, } -// testSingleHopSendToRoute tests that payments are properly processed through a -// provided route with a single hop. We'll create the following network -// topology: +// testSingleHopSendToRouteCase tests that payments are properly processed +// through a provided route with a single hop. We'll create the following +// network topology: // // Carol --100k--> Dave // @@ -67,19 +54,8 @@ var singleHopSendToRouteCases = []singleHopSendToRouteCase{ // by feeding the route back into the various SendToRoute RPC methods. Here we // test all three SendToRoute endpoints, forcing each to perform both a regular // payment and an MPP payment. -func testSingleHopSendToRoute(ht *lntest.HarnessTest) { - for _, test := range singleHopSendToRouteCases { - test := test - - ht.Run(test.name, func(t1 *testing.T) { - st := ht.Subtest(t1) - testSingleHopSendToRouteCase(st, test) - }) - } -} - func testSingleHopSendToRouteCase(ht *lntest.HarnessTest, - test singleHopSendToRouteCase) { + useStream, useRPC bool) { const chanAmt = btcutil.Amount(100000) const paymentAmtSat = 1000 @@ -199,11 +175,11 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest, // synchronously via the routerrpc's SendToRoute, or via the main RPC // server's SendToRoute streaming or sync calls. switch { - case !test.routerrpc && test.streaming: + case !useRPC && useStream: sendToRouteStream() - case !test.routerrpc && !test.streaming: + case !useRPC && !useStream: sendToRouteSync() - case test.routerrpc && !test.streaming: + case useRPC && !useStream: sendToRouteRouterRPC() default: require.Fail(ht, "routerrpc does not support "+