@@ -3950,39 +3950,66 @@ func TestFindBlindedPaths(t *testing.T) {
3950
3950
"eve,bob,dave" ,
3951
3951
})
3952
3952
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.
3955
3970
paths , err = ctx .findBlindedPaths (& blindedPathRestrictions {
3956
- minNumHops : 2 ,
3957
- maxNumHops : 3 ,
3971
+ minNumHops : 1 ,
3972
+ maxNumHops : 2 ,
3973
+ nodeOmissionSet : fn .NewSet (ctx .keyFromAlias ("frank" )),
3958
3974
incomingChainedChannels : []uint64 {
3959
- ctx .nodePairChannel ("charlie " , "dave" ),
3975
+ ctx .nodePairChannel ("bob " , "dave" ),
3960
3976
},
3961
3977
})
3962
3978
require .NoError (t , err )
3963
3979
3964
3980
// We expect the following paths:
3965
- // - E, C , D
3966
- // - B, E, C , D
3981
+ // - B , D
3982
+ // - E, B , D
3967
3983
assertPaths (paths , []string {
3968
- "eve,charlie ,dave" ,
3969
- "bob, eve,charlie ,dave" ,
3984
+ "bob ,dave" ,
3985
+ "eve,bob ,dave" ,
3970
3986
})
3971
3987
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 ,
3978
3994
incomingChainedChannels : []uint64 {
3979
- ctx .nodePairChannel ("charlie " , "dave " ),
3995
+ ctx .nodePairChannel ("dave " , "alice " ),
3980
3996
},
3981
3997
})
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 )
3984
3999
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
3986
4013
// to force a circular path.
3987
4014
_ , err = ctx .findBlindedPaths (& blindedPathRestrictions {
3988
4015
minNumHops : 2 ,
@@ -3995,4 +4022,26 @@ func TestFindBlindedPaths(t *testing.T) {
3995
4022
},
3996
4023
})
3997
4024
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
+ })
3998
4047
}
0 commit comments