mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 10:09:08 +02:00
lnrpc+routing: fix issues with missing data in unmarshallRoute
In this commit the dependency of unmarshallRoute on edge policies being available is removed. Edge policies may be unknown and reported as nil. SendToRoute does not need the policies, but it does need pubkeys of the route hops. In this commit, unmarshallRoute is modified so that it takes the pubkeys from edgeInfo instead of channelEdgePolicy. In addition to this, the route structure is simplified. No more connection to the database at that point. Fees are determined based on incoming and outgoing amounts.
This commit is contained in:
@ -262,9 +262,12 @@ func TestFindRoutesWithFeeLimit(t *testing.T) {
|
||||
t.Fatalf("expected 2 hops, got %d", len(hops))
|
||||
}
|
||||
|
||||
if hops[0].Channel.Node.Alias != "songoku" {
|
||||
if !bytes.Equal(hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["songoku"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("expected first hop through songoku, got %s",
|
||||
hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,10 +344,13 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
||||
}
|
||||
|
||||
// The route should have satoshi as the first hop.
|
||||
if route.Hops[0].Channel.Node.Alias != "satoshi" {
|
||||
if !bytes.Equal(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["satoshi"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("route should go through satoshi as first hop, "+
|
||||
"instead passes through: %v",
|
||||
route.Hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,24 +412,12 @@ func TestChannelUpdateValidation(t *testing.T) {
|
||||
|
||||
hops := []*Hop{
|
||||
{
|
||||
Channel: &ChannelHop{
|
||||
ChannelEdgePolicy: &channeldb.ChannelEdgePolicy{
|
||||
ChannelID: 1,
|
||||
Node: &channeldb.LightningNode{
|
||||
PubKeyBytes: hop1,
|
||||
},
|
||||
},
|
||||
},
|
||||
ChannelID: 1,
|
||||
PubKeyBytes: hop1,
|
||||
},
|
||||
{
|
||||
Channel: &ChannelHop{
|
||||
ChannelEdgePolicy: &channeldb.ChannelEdgePolicy{
|
||||
ChannelID: 2,
|
||||
Node: &channeldb.LightningNode{
|
||||
PubKeyBytes: hop2,
|
||||
},
|
||||
},
|
||||
},
|
||||
ChannelID: 2,
|
||||
PubKeyBytes: hop2,
|
||||
},
|
||||
}
|
||||
|
||||
@ -605,10 +599,13 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
|
||||
}
|
||||
|
||||
// The route should have pham nuwen as the first hop.
|
||||
if route.Hops[0].Channel.Node.Alias != "phamnuwen" {
|
||||
if !bytes.Equal(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["phamnuwen"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("route should go through satoshi as first hop, "+
|
||||
"instead passes through: %v",
|
||||
route.Hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,10 +698,13 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
// The route should have satoshi as the first hop.
|
||||
if route.Hops[0].Channel.Node.Alias != "phamnuwen" {
|
||||
if !bytes.Equal(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["phamnuwen"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("route should go through phamnuwen as first hop, "+
|
||||
"instead passes through: %v",
|
||||
route.Hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
}
|
||||
|
||||
@ -868,10 +868,13 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
||||
t.Fatalf("incorrect preimage used: expected %x got %x",
|
||||
preImage[:], paymentPreImage[:])
|
||||
}
|
||||
if route.Hops[0].Channel.Node.Alias != "satoshi" {
|
||||
if !bytes.Equal(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["satoshi"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("route should go through satoshi as first hop, "+
|
||||
"instead passes through: %v",
|
||||
route.Hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
|
||||
ctx.router.missionControl.ResetHistory()
|
||||
@ -913,10 +916,13 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
||||
}
|
||||
|
||||
// The route should have satoshi as the first hop.
|
||||
if route.Hops[0].Channel.Node.Alias != "satoshi" {
|
||||
if !bytes.Equal(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases["satoshi"].SerializeCompressed()) {
|
||||
|
||||
t.Fatalf("route should go through satoshi as first hop, "+
|
||||
"instead passes through: %v",
|
||||
route.Hops[0].Channel.Node.Alias)
|
||||
getAliasFromPubKey(route.Hops[0].PubKeyBytes[:],
|
||||
ctx.aliases))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user