File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import * as T from './types.js'
2121 * @typedef {T.HomestarEvents } HomestarEvents
2222 * @typedef {T.HomestarOptions } HomestarOptions
2323 * @typedef {T.Metrics } Metrics
24+ * @typedef {T.Node } Node
2425 * @typedef {T.Health } Health
2526 * @typedef {T.WorkflowNotification } WorkflowNotification
2627 * @typedef {T.EventNotification } EventNotification
@@ -91,6 +92,15 @@ export class Homestar extends Emittery {
9192 } )
9293 }
9394
95+ /**
96+ * Homestar Node info
97+ */
98+ async node ( ) {
99+ return this . #channel. request ( {
100+ method : 'node' ,
101+ } )
102+ }
103+
94104 /**
95105 * Homestar Health info
96106 */
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { CID as _CID } from 'multiformats/cid'
44/**
55 * @typedef {import('zod').z.infer<typeof Receipt> } Receipt
66 * @typedef {import('zod').z.infer<typeof Metrics> } Metrics
7+ * @typedef {import('zod').z.infer<typeof Node> } Node
78 * @typedef {import('zod').z.infer<typeof Health> } Health
89 * @typedef {import('zod').z.infer<typeof Invocation> } Invocation
910 * @typedef {import('zod').z.infer<typeof Task> } Task
@@ -30,10 +31,11 @@ export const Metrics = z.object({
3031
3132export const Health = z . object ( {
3233 healthy : z . boolean ( ) ,
33- // nodeInfo: z.object({
34- // static: z.object({ peer_id: z.string() }),
35- // dynamic: z.object({ listeners: z.array(z.string()) }),
36- // }),
34+ } )
35+
36+ export const Node = z . object ( {
37+ static : z . object ( { peer_id : z . string ( ) } ) ,
38+ dynamic : z . object ( { listeners : z . array ( z . string ( ) ) } ) ,
3739} )
3840
3941export const CID = /** @type {typeof z.custom<import('multiformats').CID> } */ (
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export interface Receipt<Out> extends Schemas.Receipt {
3131export type HomestarService = Service <
3232 [
3333 IO < { method : 'metrics' } , Schemas . Metrics > ,
34+ IO < { method : 'node' } , Schemas . Node > ,
3435 IO < { method : 'health' } , Schemas . Health > ,
3536 IO < { method : 'subscribe_run_workflow' ; params : Workflow [ ] } , string > ,
3637 IO < { method : 'subscribe_network_events' } , string > ,
Original file line number Diff line number Diff line change 5353 }
5454)
5555
56+ test (
57+ 'should fetch node info from homestar' ,
58+ async function ( ) {
59+ const hs = new Homestar ( {
60+ transport : new WebsocketTransport ( HS1_URL , {
61+ ws : WebSocket ,
62+ } ) ,
63+ } )
64+
65+ const { error, result } = await hs . node ( )
66+
67+ if ( error ) {
68+ return assert . fail ( error )
69+ }
70+
71+ assert . ok ( typeof result . static . peer_id === 'string' )
72+ assert . ok ( Array . isArray ( result . dynamic . listeners ) )
73+ hs . close ( )
74+ } ,
75+ {
76+ timeout : 30_000 ,
77+ }
78+ )
79+
5680test (
5781 'should fetch health from homestar' ,
5882 async function ( ) {
6993 }
7094
7195 assert . equal ( result . healthy , true )
72- // assert.ok(result.nodeInfo)
73- // assert.ok(typeof result.nodeInfo.static.peer_id === 'string')
74- // assert.ok(Array.isArray(result.nodeInfo.dynamic.listeners))
96+
7597 hs . close ( )
7698 } ,
7799 {
You can’t perform that action at this time.
0 commit comments