@@ -689,19 +689,12 @@ test('persists authenticated Owner routes imported through a connection code', a
689689 routeHints : [ '/ip4/192.0.2.8/udp/44001/quic-v1' ] ,
690690 coordinationRelays : [ '/memory/stale-relay' ] ,
691691 } ;
692- const freshEndpoint = {
693- lease : {
694- version : 1 as const ,
695- peerId : staleTransport . peerId ,
696- revision : 2 ,
697- issuedAt : 1 ,
698- expiresAt : 2 ,
699- directRoutes : [ '/ip4/198.51.100.9/udp/44002/quic-v1' ] ,
700- coordinationRoutes : [ '/memory/fresh-relay' ] ,
701- } ,
702- publicKey : 'AA' ,
703- signature : 'AA' ,
704- } ;
692+ const freshEndpoint = peerReachability (
693+ staleTransport . peerId ,
694+ 2 ,
695+ [ '/ip4/198.51.100.9/udp/44002/quic-v1' ] ,
696+ [ '/memory/fresh-relay' ] ,
697+ ) ;
705698 let observedIncarnation : string | undefined ;
706699 const service = createDesktopRuntimeHostProfileService ( {
707700 clientDataRoot : root ,
@@ -738,7 +731,12 @@ test('persists authenticated Owner routes imported through a connection code', a
738731 assert . equal ( persisted . profileIncarnationId , observedIncarnation ) ;
739732 assert . deepEqual (
740733 persisted . profile . kind === 'remote' ? persisted . profile . transport : undefined ,
741- { kind : 'libp2p-direct' , ...freshEndpoint } ,
734+ {
735+ kind : 'libp2p-direct' ,
736+ peerId : freshEndpoint . lease . peerId ,
737+ routeHints : freshEndpoint . lease . directRoutes ,
738+ coordinationRelays : freshEndpoint . lease . coordinationRoutes ,
739+ } ,
742740 ) ;
743741 const restarted = await resolveDesktopRuntimeHostStartup ( root , { catalog } ) ;
744742 assert . deepEqual ( restarted . remotes , [ persisted ] ) ;
@@ -781,11 +779,12 @@ test("keeps a managed Direct route on the SSH profile credential authority", asy
781779 await managedServices . save ( MANAGED_PROFILE , MANAGED_SERVICE ) ;
782780 const startup = await resolveDesktopRuntimeHostStartup ( root , { catalog } ) ;
783781 const activated : ResolvedRuntimeHostProfile [ ] = [ ] ;
784- const livePeer = {
785- peerId : "12D3KooWpeer" ,
786- routeHints : [ "/ip4/192.0.2.9/udp/44002/quic-v1" ] ,
787- coordinationRelays : [ "/dns4/relay.example/udp/443/quic-v1/p2p/12D3KooWrelay" ] ,
788- } ;
782+ const livePeer = peerReachability (
783+ '12D3KooWpeer' ,
784+ 2 ,
785+ [ '/ip4/192.0.2.9/udp/44002/quic-v1' ] ,
786+ [ '/dns4/relay.example/udp/443/quic-v1/p2p/12D3KooWrelay' ] ,
787+ ) ;
789788 let exposeReadyState = false ;
790789 const service = createDesktopRuntimeHostProfileService ( {
791790 clientDataRoot : root ,
@@ -840,7 +839,12 @@ test("keeps a managed Direct route on the SSH profile credential authority", asy
840839 await service . resolveCollaborationConnectionTarget ( MANAGED_PROFILE ) ,
841840 {
842841 name : MANAGED_PROFILE . name ,
843- transport : { kind : "libp2p-direct" , ...livePeer } ,
842+ transport : {
843+ kind : 'libp2p-direct' ,
844+ peerId : livePeer . lease . peerId ,
845+ routeHints : livePeer . lease . directRoutes ,
846+ coordinationRelays : livePeer . lease . coordinationRoutes ,
847+ } ,
844848 } ,
845849 ) ;
846850 exposeReadyState = false ;
@@ -1689,11 +1693,7 @@ function ready(target: ResolvedRuntimeHostProfile): RuntimeHostDesktopTargetStat
16891693
16901694function readyWithPeerEndpoint (
16911695 target : ResolvedRuntimeHostProfile ,
1692- peerEndpoint : {
1693- readonly peerId : string ;
1694- readonly routeHints : readonly string [ ] ;
1695- readonly coordinationRelays : readonly string [ ] ;
1696- } ,
1696+ peerEndpoint : ReturnType < typeof peerReachability > ,
16971697) : RuntimeHostDesktopTargetState {
16981698 return {
16991699 epoch : `epoch-${ target . profile . id } ` ,
@@ -1708,6 +1708,27 @@ function readyWithPeerEndpoint(
17081708 } ;
17091709}
17101710
1711+ function peerReachability (
1712+ peerId : string ,
1713+ revision = 1 ,
1714+ directRoutes : readonly string [ ] = [ '/ip4/192.0.2.8/udp/44001/quic-v1' ] ,
1715+ coordinationRoutes : readonly string [ ] = [ ] ,
1716+ ) {
1717+ return {
1718+ lease : {
1719+ version : 1 as const ,
1720+ peerId,
1721+ revision,
1722+ issuedAt : 1 ,
1723+ expiresAt : 2 ,
1724+ directRoutes,
1725+ coordinationRoutes,
1726+ } ,
1727+ publicKey : Buffer . from ( 'public' ) . toString ( 'base64url' ) ,
1728+ signature : Buffer . from ( `signature-${ revision } ` ) . toString ( 'base64url' ) ,
1729+ } ;
1730+ }
1731+
17111732function unavailable (
17121733 target : ResolvedRuntimeHostProfile ,
17131734 error : Error ,
0 commit comments