From bb1e17d4a665f87ca8432304326b445b96a2d098 Mon Sep 17 00:00:00 2001 From: matthme <36768177+matthme@users.noreply.github.com> Date: Thu, 27 Apr 2023 11:56:04 +0000 Subject: [PATCH] fix(app-ws)!: updated NetworkInfoRequest params (#186) * updated NetworkInfoRequest type * test: add case for network info * chore: revert version bump --------- Co-authored-by: Jost Schulte --- ...client.networkinforequest.agent_pub_key.md | 13 +++++++++++ docs/client.networkinforequest.dnas.md | 2 +- ...nt.networkinforequest.last_time_queried.md | 13 +++++++++++ docs/client.networkinforequest.md | 4 +++- src/api/app/types.ts | 10 +++++++- test/e2e/index.ts | 23 +++++++++++++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 docs/client.networkinforequest.agent_pub_key.md create mode 100644 docs/client.networkinforequest.last_time_queried.md diff --git a/docs/client.networkinforequest.agent_pub_key.md b/docs/client.networkinforequest.agent_pub_key.md new file mode 100644 index 00000000..365404e2 --- /dev/null +++ b/docs/client.networkinforequest.agent_pub_key.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [NetworkInfoRequest](./client.networkinforequest.md) > [agent\_pub\_key](./client.networkinforequest.agent_pub_key.md) + +## NetworkInfoRequest.agent\_pub\_key property + +The calling agent + +Signature: + +```typescript +agent_pub_key: AgentPubKey; +``` diff --git a/docs/client.networkinforequest.dnas.md b/docs/client.networkinforequest.dnas.md index b33cd555..aa4659bd 100644 --- a/docs/client.networkinforequest.dnas.md +++ b/docs/client.networkinforequest.dnas.md @@ -4,7 +4,7 @@ ## NetworkInfoRequest.dnas property -The DNAs for which to get network info +Get network info for these DNAs **Signature:** diff --git a/docs/client.networkinforequest.last_time_queried.md b/docs/client.networkinforequest.last_time_queried.md new file mode 100644 index 00000000..7ae3abf4 --- /dev/null +++ b/docs/client.networkinforequest.last_time_queried.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [NetworkInfoRequest](./client.networkinforequest.md) > [last\_time\_queried](./client.networkinforequest.last_time_queried.md) + +## NetworkInfoRequest.last\_time\_queried property + +Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH. + +Signature: + +```typescript +last_time_queried?: number; +``` diff --git a/docs/client.networkinforequest.md b/docs/client.networkinforequest.md index 3d37cb8a..072e34af 100644 --- a/docs/client.networkinforequest.md +++ b/docs/client.networkinforequest.md @@ -15,5 +15,7 @@ export interface NetworkInfoRequest | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [dnas](./client.networkinforequest.dnas.md) | | [DnaHash](./client.dnahash.md)\[\] | The DNAs for which to get network info | +| [agent\_pub\_key](./client.networkinforequest.agent_pub_key.md) | | [AgentPubKey](./client.agentpubkey.md) | The calling agent | +| [dnas](./client.networkinforequest.dnas.md) | | [DnaHash](./client.dnahash.md)\[\] | Get network info for these DNAs | +| [last\_time\_queried?](./client.networkinforequest.last_time_queried.md) | | number | (Optional) Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH. | diff --git a/src/api/app/types.ts b/src/api/app/types.ts index c858583e..e0ec7c10 100644 --- a/src/api/app/types.ts +++ b/src/api/app/types.ts @@ -135,9 +135,17 @@ export type EnableCloneCellResponse = CreateCloneCellResponse; */ export interface NetworkInfoRequest { /** - * The DNAs for which to get network info + * The calling agent + */ + agent_pub_key: AgentPubKey; + /** + * Get network info for these DNAs */ dnas: DnaHash[]; + /** + * Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX_EPOCH. + */ + last_time_queried?: number; } /** diff --git a/test/e2e/index.ts b/test/e2e/index.ts index 497a4666..0bf44618 100644 --- a/test/e2e/index.ts +++ b/test/e2e/index.ts @@ -1004,6 +1004,29 @@ test( }) ); +test( + "can fetch network info", + withConductor(ADMIN_PORT, async (t: Test) => { + const { client, cell_id } = await installAppAndDna(ADMIN_PORT); + + const response = await client.networkInfo({ + agent_pub_key: cell_id[1], + dnas: [cell_id[0]], + }); + + t.deepEqual(response, [ + { + fetch_pool_info: { op_bytes_to_fetch: 0, num_ops_to_fetch: 0 }, + current_number_of_peers: 1, + arc_size: 1, + total_network_peers: 1, + bytes_since_last_time_queried: 1844, + completed_rounds_since_last_time_queried: 0, + }, + ]); + }) +); + test( "can update coordinators of an app", withConductor(ADMIN_PORT, async (t: Test) => {