routing: modify the TestSendPaymentRouteFailureFallback to clear missionControl between attempts
In order to maintain the original essence of the test, we need to clear the state of missionControl with each attempt, essentially advancing time between each payment attempt.
This commit is contained in:
parent
8ef829ed80
commit
bbb34cebe0
@ -2860,7 +2860,8 @@ out:
|
|||||||
if err := carol.Shutdown(); err != nil {
|
if err := carol.Shutdown(); err != nil {
|
||||||
t.Fatalf("unable to shutdown carol: %v", err)
|
t.Fatalf("unable to shutdown carol: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second * 2)
|
// TODO(roasbeef): mission control
|
||||||
|
time.Sleep(time.Second * 5)
|
||||||
alicePayStream, err = net.Alice.SendPayment(ctxb)
|
alicePayStream, err = net.Alice.SendPayment(ctxb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create payment stream: %v", err)
|
t.Fatalf("unable to create payment stream: %v", err)
|
||||||
|
@ -175,6 +175,8 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
var preImage [32]byte
|
var preImage [32]byte
|
||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
|
|
||||||
|
sourceNode := ctx.router.selfNode
|
||||||
|
|
||||||
// We'll modify the SendToSwitch method that's been set within the
|
// We'll modify the SendToSwitch method that's been set within the
|
||||||
// router's configuration to ignore the path that has luo ji as the
|
// router's configuration to ignore the path that has luo ji as the
|
||||||
// first hop. This should force the router to instead take the
|
// first hop. This should force the router to instead take the
|
||||||
@ -184,7 +186,9 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
|
|
||||||
if ctx.aliases["luoji"].IsEqual(n) {
|
if ctx.aliases["luoji"].IsEqual(n) {
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureMessage: &lnwire.FailTemporaryNodeFailure{},
|
ErrorSource: sourceNode.PubKey,
|
||||||
|
// TODO(roasbeef): temp node failure should be?
|
||||||
|
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +281,8 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
return preImage, nil
|
return preImage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.router.missionControl.ResetHistory()
|
||||||
|
|
||||||
// When we try to dispatch that payment, we should receive an error as
|
// When we try to dispatch that payment, we should receive an error as
|
||||||
// both attempts should fail and cause both routes to be pruned.
|
// both attempts should fail and cause both routes to be pruned.
|
||||||
_, _, err = ctx.router.SendPayment(&payment)
|
_, _, err = ctx.router.SendPayment(&payment)
|
||||||
@ -290,6 +296,8 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
t.Fatalf("expected UnknownNextPeer instead got: %v", err)
|
t.Fatalf("expected UnknownNextPeer instead got: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.router.missionControl.ResetHistory()
|
||||||
|
|
||||||
// Next, we'll modify the SendToSwitch method to indicate that luo ji
|
// Next, we'll modify the SendToSwitch method to indicate that luo ji
|
||||||
// wasn't originally online. This should also halt the send all
|
// wasn't originally online. This should also halt the send all
|
||||||
// together as all paths contain luoji and he can't be reached.
|
// together as all paths contain luoji and he can't be reached.
|
||||||
@ -316,6 +324,8 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
t.Fatalf("expected UnknownNextPeer instead got: %v", err)
|
t.Fatalf("expected UnknownNextPeer instead got: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.router.missionControl.ResetHistory()
|
||||||
|
|
||||||
// Finally, we'll modify the SendToSwitch function to indicate that the
|
// Finally, we'll modify the SendToSwitch function to indicate that the
|
||||||
// roasbeef -> luoji channel has insufficient capacity.
|
// roasbeef -> luoji channel has insufficient capacity.
|
||||||
ctx.router.cfg.SendToSwitch = func(n *btcec.PublicKey,
|
ctx.router.cfg.SendToSwitch = func(n *btcec.PublicKey,
|
||||||
@ -337,9 +347,8 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
t.Fatalf("unable to send payment: %v", err)
|
t.Fatalf("unable to send payment: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should succeed finally.
|
// This should succeed finally. The route selected should have two
|
||||||
// The route selected should have two hops
|
// hops.
|
||||||
//
|
|
||||||
if len(route.Hops) != 2 {
|
if len(route.Hops) != 2 {
|
||||||
t.Fatalf("incorrect route length: expected %v got %v", 2,
|
t.Fatalf("incorrect route length: expected %v got %v", 2,
|
||||||
len(route.Hops))
|
len(route.Hops))
|
||||||
|
Loading…
Reference in New Issue
Block a user