Skip to content

Commit

Permalink
fix: type in network info request, test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Mar 24, 2024
1 parent 98ff446 commit 33e27b1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Emittery from "emittery"
import semverSatisfies from 'semver/functions/satisfies'
import { AppInfoResponse, AppAgentClient, AppAgentCallZomeRequest, AppCreateCloneCellRequest, CreateCloneCellResponse, AgentPubKey, AppEnableCloneCellRequest, AppDisableCloneCellRequest, EnableCloneCellResponse, DisableCloneCellResponse, AppSignal, decodeHashFromBase64, NetworkInfoRequest, NetworkInfoResponse } from '@holochain/client'
import { AppInfoResponse, AppAgentClient, AppAgentCallZomeRequest, AppCreateCloneCellRequest, CreateCloneCellResponse, AgentPubKey, AppEnableCloneCellRequest, AppDisableCloneCellRequest, EnableCloneCellResponse, DisableCloneCellResponse, AppSignal, decodeHashFromBase64, NetworkInfoResponse, AppAgentNetworkInfoRequest } from '@holochain/client'

const COMPATIBLE_CHAPERONE_VERSION = '>=0.1.1 <0.2.0'

Expand Down Expand Up @@ -192,6 +192,8 @@ class WebSdkApi implements AppAgentClient {

appInfo = (): Promise<AppInfoResponse> => this.#child.call('appInfo')

networkInfo = (args: AppAgentNetworkInfoRequest): Promise<NetworkInfoResponse> => this.#child.call('networkInfo', args)

callZome = async (args: AppAgentCallZomeRequest): Promise<any> => this.#child.call('callZome', args).then(unwrap)

createCloneCell = (args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse> => this.#child.call('createCloneCell', args).then(unwrap)
Expand All @@ -200,8 +202,6 @@ class WebSdkApi implements AppAgentClient {

enableCloneCell = (args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse> => this.#child.call('enableCloneCell', args).then(unwrap)

networkInfo = (args: NetworkInfoRequest): Promise<NetworkInfoResponse> => this.#child.call('networkInfo', args).then(unwrap)

signPayload = (args: any): Promise<any> => this.#child.call('signPayload', args).then(unwrap)

stateDump = () => this.#child.call('stateDump')
Expand Down
26 changes: 26 additions & 0 deletions tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@ describe('test API endpoints', () => {
expect(response).toMatchObject(expectedResponse)
})

it("should call network_info", async () => {
const expectedResponse = [
{
fetch_pool_info: {
op_bytes_to_fetch: 1,
num_ops_to_fetch: 1,
},
current_number_of_peers: 1,
arc_size: 1,
total_network_peers: 1,
bytes_since_last_time_queried: 1,
completed_rounds_since_last_time_queried: 1,
}
]

mock_comb.nextResponse(expectedResponse)

const response = await holo.networkInfo({
dnas: ['dna_hash'],
});

log.debug("Response: %s", response)

expect(response).toBeDefined()
})

it("should sign payloads", async () => {
const payload = { mockPayload: 'value' }
const expectedResponse = {
Expand Down

0 comments on commit 33e27b1

Please sign in to comment.