Skip to content

Commit

Permalink
fix(app-ws)!: updated NetworkInfoRequest params (#186)
Browse files Browse the repository at this point in the history
* updated NetworkInfoRequest type

* test: add case for network info

* chore: revert version bump

---------

Co-authored-by: Jost Schulte <jost.schulte@protonmail.com>
  • Loading branch information
matthme and jost-s committed Apr 27, 2023
1 parent 71c8c62 commit bb1e17d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 3 deletions.
13 changes: 13 additions & 0 deletions docs/client.networkinforequest.agent_pub_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [NetworkInfoRequest](./client.networkinforequest.md) &gt; [agent\_pub\_key](./client.networkinforequest.agent_pub_key.md)

## NetworkInfoRequest.agent\_pub\_key property

The calling agent

<b>Signature:</b>

```typescript
agent_pub_key: AgentPubKey;
```
2 changes: 1 addition & 1 deletion docs/client.networkinforequest.dnas.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## NetworkInfoRequest.dnas property

The DNAs for which to get network info
Get network info for these DNAs

**Signature:**

Expand Down
13 changes: 13 additions & 0 deletions docs/client.networkinforequest.last_time_queried.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [NetworkInfoRequest](./client.networkinforequest.md) &gt; [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.

<b>Signature:</b>

```typescript
last_time_queried?: number;
```
4 changes: 3 additions & 1 deletion docs/client.networkinforequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <i>(Optional)</i> Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH. |

10 changes: 9 additions & 1 deletion src/api/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit bb1e17d

Please sign in to comment.