Skip to content

Commit 4945bd4

Browse files
committed
routing: expand routeblinding path finding tests
Cover more cases for the incoming chained channel feature.
1 parent 3415480 commit 4945bd4

File tree

1 file changed

+68
-19
lines changed

1 file changed

+68
-19
lines changed

routing/pathfind_test.go

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,39 +3950,66 @@ func TestFindBlindedPaths(t *testing.T) {
39503950
"eve,bob,dave",
39513951
})
39523952

3953-
// 6.3) Extend the search even further and also increase the minimum path
3954-
// length, but this time with charlie-dave as the incoming channel.
3953+
// 6.3) Repeat the above test but instruct the function to never use
3954+
// bob. This should fail since bob owns one of the channels in the
3955+
// partially specified path.
3956+
_, err = ctx.findBlindedPaths(&blindedPathRestrictions{
3957+
minNumHops: 1,
3958+
maxNumHops: 2,
3959+
nodeOmissionSet: fn.NewSet(ctx.keyFromAlias("bob")),
3960+
incomingChainedChannels: []uint64{
3961+
ctx.nodePairChannel("bob", "dave"),
3962+
},
3963+
})
3964+
require.ErrorContains(t, err, "cannot simultaneously be included in "+
3965+
"the omission set and in the partially specified path")
3966+
3967+
// 6.4) Repeat it again but this time omit frank and demonstrate that
3968+
// the resulting set contains all the results from 6.2 except for the
3969+
// frank path.
39553970
paths, err = ctx.findBlindedPaths(&blindedPathRestrictions{
3956-
minNumHops: 2,
3957-
maxNumHops: 3,
3971+
minNumHops: 1,
3972+
maxNumHops: 2,
3973+
nodeOmissionSet: fn.NewSet(ctx.keyFromAlias("frank")),
39583974
incomingChainedChannels: []uint64{
3959-
ctx.nodePairChannel("charlie", "dave"),
3975+
ctx.nodePairChannel("bob", "dave"),
39603976
},
39613977
})
39623978
require.NoError(t, err)
39633979

39643980
// We expect the following paths:
3965-
// - E, C, D
3966-
// - B, E, C, D
3981+
// - B, D
3982+
// - E, B, D
39673983
assertPaths(paths, []string{
3968-
"eve,charlie,dave",
3969-
"bob,eve,charlie,dave",
3984+
"bob,dave",
3985+
"eve,bob,dave",
39703986
})
39713987

3972-
// 6.4) Repeat the above test but instruct the function to never use
3973-
// charlie.
3974-
_, err = ctx.findBlindedPaths(&blindedPathRestrictions{
3975-
minNumHops: 2,
3976-
maxNumHops: 3,
3977-
nodeOmissionSet: fn.NewSet(ctx.keyFromAlias("charlie")),
3988+
// 6.5) Users may specify channels to nodes that do not signal route
3989+
// blinding (like A). So if we specify the A-D channel, we should get
3990+
// valid paths.
3991+
paths, err = ctx.findBlindedPaths(&blindedPathRestrictions{
3992+
minNumHops: 1,
3993+
maxNumHops: 4,
39783994
incomingChainedChannels: []uint64{
3979-
ctx.nodePairChannel("charlie", "dave"),
3995+
ctx.nodePairChannel("dave", "alice"),
39803996
},
39813997
})
3982-
require.ErrorContains(t, err, "cannot simultaneously be included in "+
3983-
"the omission set and in the partially specified path")
3998+
require.NoError(t, err)
39843999

3985-
// 6.5) Assert that an error is returned if a user accidentally tries
4000+
// We expect the following paths:
4001+
// - A, D
4002+
// - F, A, D
4003+
// - B, F, A, D
4004+
// - E, B, F, A, D
4005+
assertPaths(paths, []string{
4006+
"alice,dave",
4007+
"frank,alice,dave",
4008+
"bob,frank,alice,dave",
4009+
"eve,bob,frank,alice,dave",
4010+
})
4011+
4012+
// 6.6) Assert that an error is returned if a user accidentally tries
39864013
// to force a circular path.
39874014
_, err = ctx.findBlindedPaths(&blindedPathRestrictions{
39884015
minNumHops: 2,
@@ -3995,4 +4022,26 @@ func TestFindBlindedPaths(t *testing.T) {
39954022
},
39964023
})
39974024
require.ErrorContains(t, err, "circular route")
4025+
4026+
// 6.7) Test specifying a chain of incoming channels. We specify
4027+
// the following incoming list: [A->D, F->A].
4028+
paths, err = ctx.findBlindedPaths(&blindedPathRestrictions{
4029+
minNumHops: 1,
4030+
maxNumHops: 4,
4031+
incomingChainedChannels: []uint64{
4032+
ctx.nodePairChannel("dave", "alice"),
4033+
ctx.nodePairChannel("alice", "frank"),
4034+
},
4035+
})
4036+
require.NoError(t, err)
4037+
4038+
// We expect the following paths:
4039+
// - F, A, D
4040+
// - B, F, A, D
4041+
// - E, B, F, A, D
4042+
assertPaths(paths, []string{
4043+
"frank,alice,dave",
4044+
"bob,frank,alice,dave",
4045+
"eve,bob,frank,alice,dave",
4046+
})
39984047
}

0 commit comments

Comments
 (0)