@@ -1117,6 +1117,8 @@ describe("OT RCP Driver", () => {
1117
1117
} ) ;
1118
1118
1119
1119
it ( "disassociates" , async ( ) => {
1120
+ // no-op, not relevant for this test
1121
+ vi . spyOn ( driver , "sendPeriodicManyToOneRouteRequest" ) . mockImplementation ( async ( ) => { } ) ;
1120
1122
driver . allowJoins ( 0xfe , true ) ;
1121
1123
1122
1124
// neighbor FFD
@@ -1687,6 +1689,8 @@ describe("OT RCP Driver", () => {
1687
1689
} ) ;
1688
1690
1689
1691
it ( "performs a join & authorize - ROUTER" , async ( ) => {
1692
+ // no-op, not relevant for this test
1693
+ vi . spyOn ( driver , "sendPeriodicManyToOneRouteRequest" ) . mockImplementation ( async ( ) => { } ) ;
1690
1694
// Expected flow (APS acks requested from device are skipped for brevity):
1691
1695
// - NET2_BEACON_REQ_FROM_DEVICE
1692
1696
// - NET2_BEACON_RESP_FROM_COORD
@@ -2855,9 +2859,9 @@ describe("OT RCP Driver", () => {
2855
2859
2856
2860
expect ( driver . sourceRouteTable . get ( 0x4b8e ) ) . toBeUndefined ( ) ;
2857
2861
await vi . advanceTimersByTimeAsync ( 11000 ) ; // past concentrator min time
2858
- expect ( ( ) => driver . findBestSourceRoute ( 0x4b8e , undefined ) ) . toThrow ( "No known route to destination" ) ;
2862
+ expect ( driver . findBestSourceRoute ( 0x4b8e , undefined ) ) . toStrictEqual ( [ undefined , undefined , undefined ] ) ;
2859
2863
await vi . advanceTimersByTimeAsync ( 10 ) ; // flush
2860
- expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2864
+ expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 1 + 1 /* disassociate */ ) ;
2861
2865
expect ( sendZigbeeNWKRouteReqSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2862
2866
2863
2867
//-- too many NO_ACK
@@ -2871,18 +2875,31 @@ describe("OT RCP Driver", () => {
2871
2875
await vi . advanceTimersByTimeAsync ( 5000 ) ; // not past concentrator min time
2872
2876
expect ( driver . findBestSourceRoute ( 0x6887 , undefined ) ) . toStrictEqual ( [ 2 , [ 0x6 , 0x7 , 0x8 ] , 4 ] ) ;
2873
2877
await vi . advanceTimersByTimeAsync ( 10 ) ; // flush
2874
- expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 2 ) ;
2878
+ expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 2 + 1 /* disassociate */ ) ;
2875
2879
expect ( sendZigbeeNWKRouteReqSpy ) . toHaveBeenCalledTimes ( 1 ) ; // too soon
2876
2880
expect ( driver . sourceRouteTable . get ( 0x6887 ) ) . toStrictEqual ( [ { relayAddresses : [ 0x6 , 0x7 , 0x8 ] , pathCost : 4 } ] ) ;
2877
2881
2878
2882
//-- too many NO_ACK, no more route
2879
2883
driver . macNoACKs . set ( 0x8 , 4 ) ;
2880
2884
await vi . advanceTimersByTimeAsync ( 6000 ) ; // past concentrator min time
2881
- expect ( ( ) => driver . findBestSourceRoute ( 0x6887 , undefined ) ) . toThrow ( "No known route to destination" ) ;
2885
+ expect ( driver . findBestSourceRoute ( 0x6887 , undefined ) ) . toStrictEqual ( [ undefined , undefined , undefined ] ) ;
2882
2886
await vi . advanceTimersByTimeAsync ( 10 ) ; // flush
2883
- expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 3 ) ;
2887
+ expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 3 + 1 /* disassociate */ ) ;
2884
2888
expect ( sendZigbeeNWKRouteReqSpy ) . toHaveBeenCalledTimes ( 2 ) ;
2885
2889
expect ( driver . sourceRouteTable . get ( 0x6887 ) ) . toBeUndefined ( ) ;
2890
+
2891
+ //--- received LINK_STATUS indicating direct link to coordinator available
2892
+ expect ( driver . deviceTable . get ( driver . address16ToAddress64 . get ( 0x6887 ) ! ) ! . neighbor ) . toStrictEqual ( false ) ;
2893
+ driver . processZigbeeNWKLinkStatus (
2894
+ Buffer . from ( [ 97 , 0x00 , 0x00 , 17 ] ) ,
2895
+ 0 ,
2896
+ // @ts -expect-error minimal mock
2897
+ { source16 : 0x6887 , source64 : 5149013643361676n } ,
2898
+ { source16 : 0x6887 , source64 : 5149013643361676n } ,
2899
+ ) ;
2900
+ await vi . advanceTimersByTimeAsync ( 10 ) ; // flush
2901
+ expect ( driver . sourceRouteTable . get ( 0x6887 ) ) . toStrictEqual ( [ { relayAddresses : [ ] , pathCost : 1 } ] ) ;
2902
+ expect ( driver . deviceTable . get ( driver . address16ToAddress64 . get ( 0x6887 ) ! ) ! . neighbor ) . toStrictEqual ( true ) ;
2886
2903
} ) ;
2887
2904
2888
2905
it ( "checks if source route exists in entries for a given device" , ( ) => {
@@ -3013,8 +3030,8 @@ describe("OT RCP Driver", () => {
3013
3030
Buffer . from ( [ 2 , dest16 & 0xff , ( dest16 >> 8 ) & 0xff ] ) ,
3014
3031
0 ,
3015
3032
// @ts -expect-error minimal mock
3016
- { source16 : 1 , source64 : 1n } ,
3017
- { source16 : 1 , source64 : 1n } ,
3033
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3034
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3018
3035
) ;
3019
3036
3020
3037
expect ( driver . routeFailures . get ( 0x91d2 ) ) . toStrictEqual ( 1 ) ;
@@ -3023,8 +3040,8 @@ describe("OT RCP Driver", () => {
3023
3040
Buffer . from ( [ 2 , dest16 & 0xff , ( dest16 >> 8 ) & 0xff ] ) ,
3024
3041
0 ,
3025
3042
// @ts -expect-error minimal mock
3026
- { source16 : 1 , source64 : 1n } ,
3027
- { source16 : 1 , source64 : 1n } ,
3043
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3044
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3028
3045
) ;
3029
3046
3030
3047
expect ( driver . routeFailures . get ( 0x91d2 ) ) . toStrictEqual ( 2 ) ;
@@ -3033,13 +3050,13 @@ describe("OT RCP Driver", () => {
3033
3050
Buffer . from ( [ 2 , dest16 & 0xff , ( dest16 >> 8 ) & 0xff ] ) ,
3034
3051
0 ,
3035
3052
// @ts -expect-error minimal mock
3036
- { source16 : 1 , source64 : 1n } ,
3037
- { source16 : 1 , source64 : 1n } ,
3053
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3054
+ { source16 : 0x9ed5 , source64 : 5149013578478658n } ,
3038
3055
) ;
3039
3056
3040
3057
expect ( driver . routeFailures . get ( 0x91d2 ) ) . toStrictEqual ( 0 ) ;
3041
3058
expect ( driver . sourceRouteTable . get ( 0x9ed5 ) ) . toBeUndefined ( ) ;
3042
- expect ( ( ) => driver . findBestSourceRoute ( 0x9ed5 , undefined ) ) . toThrow ( "No known route to destination" ) ;
3059
+ expect ( driver . findBestSourceRoute ( 0x9ed5 , undefined ) ) . toStrictEqual ( [ undefined , undefined , undefined ] ) ;
3043
3060
await vi . advanceTimersByTimeAsync ( 10 ) ; // flush
3044
3061
expect ( sendPeriodicManyToOneRouteRequestSpy ) . toHaveBeenCalledTimes ( 1 ) ;
3045
3062
expect ( sendZigbeeNWKRouteReqSpy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -3162,6 +3179,7 @@ describe("OT RCP Driver", () => {
3162
3179
) ;
3163
3180
3164
3181
//-- mock LEAVE
3182
+ vi . spyOn ( driver , "sendPeriodicManyToOneRouteRequest" ) . mockImplementationOnce ( async ( ) => { } ) ; // no-op for disassociate
3165
3183
await driver . disassociate ( 0x91d2 , 8118874123826907736n ) ;
3166
3184
3167
3185
expect ( driver . sourceRouteTable . size ) . toStrictEqual ( 5 ) ;
@@ -3427,6 +3445,7 @@ describe("OT RCP Driver", () => {
3427
3445
3428
3446
expect ( lqiTable ) . toStrictEqual ( expectedLQITable . subarray ( 0 , 5 + 3 * 22 ) ) ;
3429
3447
3448
+ vi . spyOn ( driver , "sendPeriodicManyToOneRouteRequest" ) . mockImplementationOnce ( async ( ) => { } ) ; // no-op for disassociate
3430
3449
await driver . disassociate ( 0xcb47 , 5149013569626593n ) ;
3431
3450
expect ( driver . deviceTable . size ) . toStrictEqual ( 5 ) ;
3432
3451
0 commit comments