routing/test: use half shard for single success case
Update our single shard success case to use a route which splits the payment amount in half. This change still tests the case where reveal of the preimage counts as a success, even if we don't have the full amount. This change is made to cut down on potential races in this test case. While we are waiting for collectResultAsync to report a success, the payment lifecycle will continue trying to dispatch shards. In the case where we send 1/4 of the payment amount, we send 1 or 2 more shards, depending on how long collectAsync takes. Reducing this test to send 1/2 of the payment amount means that we will always only try one more shard before waiting for our shard.
This commit is contained in:
parent
198d567cb2
commit
a68155545c
@ -190,6 +190,9 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
t.Fatalf("unable to create route: %v", err)
|
t.Fatalf("unable to create route: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
halfShard, err := createTestRoute(paymentAmt/2, testGraph.aliasMap)
|
||||||
|
require.NoError(t, err, "unable to create half route")
|
||||||
|
|
||||||
shard, err := createTestRoute(paymentAmt/4, testGraph.aliasMap)
|
shard, err := createTestRoute(paymentAmt/4, testGraph.aliasMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create route: %v", err)
|
t.Fatalf("unable to create route: %v", err)
|
||||||
@ -501,10 +504,8 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// An MP payment scenario where 3 of the shards fail.
|
// An MP payment scenario where one of the shards fails,
|
||||||
// However the last shard settle, which means we get
|
// but we still receive a single success shard.
|
||||||
// the preimage and should consider the overall payment
|
|
||||||
// a success.
|
|
||||||
name: "MP one shard success",
|
name: "MP one shard success",
|
||||||
|
|
||||||
steps: []string{
|
steps: []string{
|
||||||
@ -518,30 +519,18 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
routerRegisterAttempt,
|
routerRegisterAttempt,
|
||||||
sendToSwitchSuccess,
|
sendToSwitchSuccess,
|
||||||
|
|
||||||
// shard 2
|
// shard 0 fails, and should be failed by the
|
||||||
routerRegisterAttempt,
|
|
||||||
sendToSwitchSuccess,
|
|
||||||
|
|
||||||
// shard 3
|
|
||||||
routerRegisterAttempt,
|
|
||||||
sendToSwitchSuccess,
|
|
||||||
|
|
||||||
// 3 shards fail, and should be failed by the
|
|
||||||
// router.
|
// router.
|
||||||
getPaymentResultTempFailure,
|
getPaymentResultTempFailure,
|
||||||
getPaymentResultTempFailure,
|
|
||||||
getPaymentResultTempFailure,
|
|
||||||
routerFailAttempt,
|
|
||||||
routerFailAttempt,
|
|
||||||
routerFailAttempt,
|
routerFailAttempt,
|
||||||
|
|
||||||
// The fourth shard succeed against all odds,
|
// The second shard succeed against all odds,
|
||||||
// making the overall payment succeed.
|
// making the overall payment succeed.
|
||||||
getPaymentResultSuccess,
|
getPaymentResultSuccess,
|
||||||
routerSettleAttempt,
|
routerSettleAttempt,
|
||||||
paymentSuccess,
|
paymentSuccess,
|
||||||
},
|
},
|
||||||
routes: []*route.Route{shard, shard, shard, shard},
|
routes: []*route.Route{halfShard, halfShard},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// An MP payment scenario a shard fail with a terminal
|
// An MP payment scenario a shard fail with a terminal
|
||||||
|
Loading…
Reference in New Issue
Block a user