mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 22:46:40 +01:00
itest: break down single hop send to route
Also removed the duplicate test cases.
This commit is contained in:
parent
c029f0a84f
commit
efae8ea56f
2 changed files with 24 additions and 51 deletions
|
@ -300,10 +300,6 @@ var allTestCases = []*lntest.TestCase{
|
||||||
Name: "revoked uncooperative close retribution remote hodl",
|
Name: "revoked uncooperative close retribution remote hodl",
|
||||||
TestFunc: testRevokedCloseRetributionRemoteHodl,
|
TestFunc: testRevokedCloseRetributionRemoteHodl,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "single-hop send to route",
|
|
||||||
TestFunc: testSingleHopSendToRoute,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "multi-hop send to route",
|
Name: "multi-hop send to route",
|
||||||
TestFunc: testMultiHopSendToRoute,
|
TestFunc: testMultiHopSendToRoute,
|
||||||
|
@ -678,4 +674,5 @@ func init() {
|
||||||
allTestCases = append(allTestCases, channelFeePolicyTestCases...)
|
allTestCases = append(allTestCases, channelFeePolicyTestCases...)
|
||||||
allTestCases = append(allTestCases, walletImportAccountTestCases...)
|
allTestCases = append(allTestCases, walletImportAccountTestCases...)
|
||||||
allTestCases = append(allTestCases, basicFundingTestCases...)
|
allTestCases = append(allTestCases, basicFundingTestCases...)
|
||||||
|
allTestCases = append(allTestCases, sendToRouteTestCases...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,46 +20,33 @@ import (
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type singleHopSendToRouteCase struct {
|
var sendToRouteTestCases = []*lntest.TestCase{
|
||||||
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{
|
|
||||||
{
|
{
|
||||||
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",
|
Name: "single hop send to route stream",
|
||||||
streaming: true,
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
// useStream: true, routerrpc: false.
|
||||||
|
testSingleHopSendToRouteCase(ht, true, false)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "regular routerrpc sync",
|
Name: "single hop send to route v2",
|
||||||
routerrpc: true,
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
// useStream: false, routerrpc: true.
|
||||||
|
testSingleHopSendToRouteCase(ht, false, true)
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "mpp main sync",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "mpp main stream",
|
|
||||||
streaming: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "mpp routerrpc sync",
|
|
||||||
routerrpc: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// testSingleHopSendToRoute tests that payments are properly processed through a
|
// testSingleHopSendToRouteCase tests that payments are properly processed
|
||||||
// provided route with a single hop. We'll create the following network
|
// through a provided route with a single hop. We'll create the following
|
||||||
// topology:
|
// network topology:
|
||||||
//
|
//
|
||||||
// Carol --100k--> Dave
|
// Carol --100k--> Dave
|
||||||
//
|
//
|
||||||
|
@ -67,19 +54,8 @@ var singleHopSendToRouteCases = []singleHopSendToRouteCase{
|
||||||
// by feeding the route back into the various SendToRoute RPC methods. Here we
|
// 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
|
// test all three SendToRoute endpoints, forcing each to perform both a regular
|
||||||
// payment and an MPP payment.
|
// 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,
|
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
|
||||||
test singleHopSendToRouteCase) {
|
useStream, useRPC bool) {
|
||||||
|
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
const paymentAmtSat = 1000
|
const paymentAmtSat = 1000
|
||||||
|
@ -199,11 +175,11 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
|
||||||
// synchronously via the routerrpc's SendToRoute, or via the main RPC
|
// synchronously via the routerrpc's SendToRoute, or via the main RPC
|
||||||
// server's SendToRoute streaming or sync calls.
|
// server's SendToRoute streaming or sync calls.
|
||||||
switch {
|
switch {
|
||||||
case !test.routerrpc && test.streaming:
|
case !useRPC && useStream:
|
||||||
sendToRouteStream()
|
sendToRouteStream()
|
||||||
case !test.routerrpc && !test.streaming:
|
case !useRPC && !useStream:
|
||||||
sendToRouteSync()
|
sendToRouteSync()
|
||||||
case test.routerrpc && !test.streaming:
|
case useRPC && !useStream:
|
||||||
sendToRouteRouterRPC()
|
sendToRouteRouterRPC()
|
||||||
default:
|
default:
|
||||||
require.Fail(ht, "routerrpc does not support "+
|
require.Fail(ht, "routerrpc does not support "+
|
||||||
|
|
Loading…
Add table
Reference in a new issue