routing/test: do not test local channel mission control
This commit updates existing tests to not rely on mission control for pruning of local channels. Information about local channels should already be up to date before path finding starts. If not, the problem should be fixed where bandwidth hints are set up.
This commit is contained in:
parent
45dacd0df1
commit
c39d7a29cd
@ -274,7 +274,7 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
var payHash [32]byte
|
var payHash [32]byte
|
||||||
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
||||||
payment := LightningPayment{
|
payment := LightningPayment{
|
||||||
Target: ctx.aliases["luoji"],
|
Target: ctx.aliases["sophon"],
|
||||||
Amount: paymentAmt,
|
Amount: paymentAmt,
|
||||||
FeeLimit: noFeeLimit,
|
FeeLimit: noFeeLimit,
|
||||||
PaymentHash: payHash,
|
PaymentHash: payHash,
|
||||||
@ -284,16 +284,16 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
|
|
||||||
// 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 son goku as the
|
||||||
// first hop. This should force the router to instead take the
|
// first hop. This should force the router to instead take the
|
||||||
// available two hop path (through satoshi).
|
// the more costly path (through pham nuwen).
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
roasbeefLuoji := lnwire.NewShortChanIDFromInt(689530843)
|
roasbeefSongoku := lnwire.NewShortChanIDFromInt(12345)
|
||||||
if firstHop == roasbeefLuoji {
|
if firstHop == roasbeefSongoku {
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureSourceIdx: 0,
|
FailureSourceIdx: 1,
|
||||||
// TODO(roasbeef): temp node failure should be?
|
// TODO(roasbeef): temp node failure should be?
|
||||||
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
return preImage, nil
|
return preImage, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
// Send off the payment request to the router, route through satoshi
|
// Send off the payment request to the router, route through pham nuwen
|
||||||
// should've been selected as a fall back and succeeded correctly.
|
// should've been selected as a fall back and succeeded correctly.
|
||||||
paymentPreImage, route, err := ctx.router.SendPayment(&payment)
|
paymentPreImage, route, err := ctx.router.SendPayment(&payment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -321,10 +321,10 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
preImage[:], paymentPreImage[:])
|
preImage[:], paymentPreImage[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// The route should have satoshi as the first hop.
|
// The route should have pham nuwen as the first hop.
|
||||||
if route.Hops[0].PubKeyBytes != ctx.aliases["satoshi"] {
|
if route.Hops[0].PubKeyBytes != ctx.aliases["phamnuwen"] {
|
||||||
|
|
||||||
t.Fatalf("route should go through satoshi as first hop, "+
|
t.Fatalf("route should go through phamnuwen as first hop, "+
|
||||||
"instead passes through: %v",
|
"instead passes through: %v",
|
||||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes,
|
getAliasFromPubKey(route.Hops[0].PubKeyBytes,
|
||||||
ctx.aliases))
|
ctx.aliases))
|
||||||
@ -743,7 +743,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
var payHash [32]byte
|
var payHash [32]byte
|
||||||
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
||||||
payment := LightningPayment{
|
payment := LightningPayment{
|
||||||
Target: ctx.aliases["luoji"],
|
Target: ctx.aliases["sophon"],
|
||||||
Amount: paymentAmt,
|
Amount: paymentAmt,
|
||||||
FeeLimit: noFeeLimit,
|
FeeLimit: noFeeLimit,
|
||||||
PaymentHash: payHash,
|
PaymentHash: payHash,
|
||||||
@ -752,32 +752,29 @@ func TestSendPaymentErrorPathPruning(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))
|
||||||
|
|
||||||
roasbeefLuoji := lnwire.NewShortChanIDFromInt(689530843)
|
roasbeefSongoku := lnwire.NewShortChanIDFromInt(12345)
|
||||||
|
roasbeefPhanNuwen := lnwire.NewShortChanIDFromInt(999991)
|
||||||
|
|
||||||
// First, we'll modify the SendToSwitch method to return an error
|
// First, we'll modify the SendToSwitch method to return an error
|
||||||
// indicating that the channel from roasbeef to luoji is not operable
|
// indicating that the channel from roasbeef to son goku is not operable
|
||||||
// with an UnknownNextPeer.
|
// with an UnknownNextPeer.
|
||||||
//
|
|
||||||
// TODO(roasbeef): filtering should be intelligent enough so just not
|
|
||||||
// go through satoshi at all at this point.
|
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefLuoji {
|
if firstHop == roasbeefSongoku {
|
||||||
// We'll first simulate an error from the first
|
// We'll first simulate an error from the first
|
||||||
// outgoing link to simulate the channel from luo ji to
|
// hop to simulate the channel from songoku to
|
||||||
// roasbeef not having enough capacity.
|
// sophon not having enough capacity.
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureSourceIdx: 0,
|
FailureSourceIdx: 1,
|
||||||
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, we'll create an error from satoshi to indicate
|
// Next, we'll create an error from phan nuwen to
|
||||||
// that the luoji node is not longer online, which should
|
// indicate that the sophon node is not longer online,
|
||||||
// prune out the rest of the routes.
|
// which should prune out the rest of the routes.
|
||||||
roasbeefSatoshi := lnwire.NewShortChanIDFromInt(2340213491)
|
if firstHop == roasbeefPhanNuwen {
|
||||||
if firstHop == roasbeefSatoshi {
|
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureSourceIdx: 1,
|
FailureSourceIdx: 1,
|
||||||
FailureMessage: &lnwire.FailUnknownNextPeer{},
|
FailureMessage: &lnwire.FailUnknownNextPeer{},
|
||||||
@ -804,15 +801,14 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
|
|
||||||
ctx.router.cfg.MissionControl.(*MissionControl).ResetHistory()
|
ctx.router.cfg.MissionControl.(*MissionControl).ResetHistory()
|
||||||
|
|
||||||
// Next, we'll modify the SendToSwitch method to indicate that luo ji
|
// Next, we'll modify the SendToSwitch method to indicate that the
|
||||||
// wasn't originally online. This should also halt the send all
|
// connection between songoku and isn't up.
|
||||||
// together as all paths contain luoji and he can't be reached.
|
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefLuoji {
|
if firstHop == roasbeefSongoku {
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureSourceIdx: 0,
|
FailureSourceIdx: 1,
|
||||||
FailureMessage: &lnwire.FailUnknownNextPeer{},
|
FailureMessage: &lnwire.FailUnknownNextPeer{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -821,14 +817,14 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// This shouldn't return an error, as we'll make a payment attempt via
|
// This shouldn't return an error, as we'll make a payment attempt via
|
||||||
// the satoshi channel based on the assumption that there might be an
|
// the pham nuwen channel based on the assumption that there might be an
|
||||||
// intermittent issue with the roasbeef <-> lioji channel.
|
// intermittent issue with the songoku <-> sophon channel.
|
||||||
paymentPreImage, rt, err := ctx.router.SendPayment(&payment)
|
paymentPreImage, rt, err := ctx.router.SendPayment(&payment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable send payment: %v", err)
|
t.Fatalf("unable send payment: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This path should go: roasbeef -> satoshi -> luoji
|
// This path should go: roasbeef -> pham nuwen -> sophon
|
||||||
if len(rt.Hops) != 2 {
|
if len(rt.Hops) != 2 {
|
||||||
t.Fatalf("incorrect route length: expected %v got %v", 2,
|
t.Fatalf("incorrect route length: expected %v got %v", 2,
|
||||||
len(rt.Hops))
|
len(rt.Hops))
|
||||||
@ -837,9 +833,9 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
t.Fatalf("incorrect preimage used: expected %x got %x",
|
t.Fatalf("incorrect preimage used: expected %x got %x",
|
||||||
preImage[:], paymentPreImage[:])
|
preImage[:], paymentPreImage[:])
|
||||||
}
|
}
|
||||||
if rt.Hops[0].PubKeyBytes != ctx.aliases["satoshi"] {
|
if rt.Hops[0].PubKeyBytes != ctx.aliases["phamnuwen"] {
|
||||||
|
|
||||||
t.Fatalf("route should go through satoshi as first hop, "+
|
t.Fatalf("route should go through phamnuwen as first hop, "+
|
||||||
"instead passes through: %v",
|
"instead passes through: %v",
|
||||||
getAliasFromPubKey(rt.Hops[0].PubKeyBytes,
|
getAliasFromPubKey(rt.Hops[0].PubKeyBytes,
|
||||||
ctx.aliases))
|
ctx.aliases))
|
||||||
@ -853,12 +849,12 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefLuoji {
|
if firstHop == roasbeefSongoku {
|
||||||
// We'll first simulate an error from the first
|
// We'll first simulate an error from the first
|
||||||
// outgoing link to simulate the channel from luo ji to
|
// outgoing link to simulate the channel from luo ji to
|
||||||
// roasbeef not having enough capacity.
|
// roasbeef not having enough capacity.
|
||||||
return [32]byte{}, &htlcswitch.ForwardingError{
|
return [32]byte{}, &htlcswitch.ForwardingError{
|
||||||
FailureSourceIdx: 0,
|
FailureSourceIdx: 1,
|
||||||
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -886,9 +882,9 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The route should have satoshi as the first hop.
|
// The route should have satoshi as the first hop.
|
||||||
if rt.Hops[0].PubKeyBytes != ctx.aliases["satoshi"] {
|
if rt.Hops[0].PubKeyBytes != ctx.aliases["phamnuwen"] {
|
||||||
|
|
||||||
t.Fatalf("route should go through satoshi as first hop, "+
|
t.Fatalf("route should go through phamnuwen as first hop, "+
|
||||||
"instead passes through: %v",
|
"instead passes through: %v",
|
||||||
getAliasFromPubKey(rt.Hops[0].PubKeyBytes,
|
getAliasFromPubKey(rt.Hops[0].PubKeyBytes,
|
||||||
ctx.aliases))
|
ctx.aliases))
|
||||||
|
Loading…
Reference in New Issue
Block a user