From b1b9f34e5c1f49abdbc1074d7eaa4a54f58f82c5 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Wed, 31 Jul 2024 12:40:24 -0700 Subject: [PATCH 1/2] test: failing test demonstrating that hashes returned in client calls are now mis-typed --- test/e2e/app-websocket.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/e2e/app-websocket.ts b/test/e2e/app-websocket.ts index 2998fd3b..65000811 100644 --- a/test/e2e/app-websocket.ts +++ b/test/e2e/app-websocket.ts @@ -12,6 +12,7 @@ import { fakeAgentPubKey, NonProvenanceCallZomeRequest, RoleName, + AgentPubKey, } from "../../src"; import { createAppWsAndInstallApp, @@ -311,3 +312,22 @@ test( ]); }) ); + +test( + "can read myPubKey", + withConductor(ADMIN_PORT, async (t) => { + const { + installed_app_id, + cell_id, + client: appWs, + admin, + } = await createAppWsAndInstallApp(ADMIN_PORT); + + const myPubKey = appWs.myPubKey; + const appInfo = await appWs.appInfo(); + + t.deepEqual(myPubKey, appInfo.agent_pub_key); + t.deepEqual(myPubKey.getHashB64(), appInfo.agent_pub_key.getHashB64()); + t.deepEqual(myPubKey.toBytes(), appInfo.agent_pub_key.toBytes()); + }) +); \ No newline at end of file From 5a2ebd57b4e34ac734bdb9ba43eaa7e26639da1f Mon Sep 17 00:00:00 2001 From: Matthew Brisebois Date: Wed, 31 Jul 2024 17:36:37 -0600 Subject: [PATCH 2/2] Transform app info agent to instance of AgentPubKey (fixes #265) --- src/api/app/websocket.ts | 2 ++ test/e2e/app-websocket.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/app/websocket.ts b/src/api/app/websocket.ts index 8a356603..497de8f7 100644 --- a/src/api/app/websocket.ts +++ b/src/api/app/websocket.ts @@ -231,6 +231,7 @@ export class AppWebsocket implements AppClient { `The app your connection token was issued for was not found. The app needs to be installed and enabled.` ); } + appInfo.agent_pub_key = new AgentPubKey(appInfo.agent_pub_key); return new AppWebsocket( client, @@ -254,6 +255,7 @@ export class AppWebsocket implements AppClient { `App info not found. App needs to be installed and enabled.` ); } + appInfo.agent_pub_key = new AgentPubKey(appInfo.agent_pub_key); this.cachedAppInfo = appInfo; return appInfo; diff --git a/test/e2e/app-websocket.ts b/test/e2e/app-websocket.ts index 65000811..bfeea103 100644 --- a/test/e2e/app-websocket.ts +++ b/test/e2e/app-websocket.ts @@ -325,9 +325,9 @@ test( const myPubKey = appWs.myPubKey; const appInfo = await appWs.appInfo(); - + t.deepEqual(myPubKey, appInfo.agent_pub_key); - t.deepEqual(myPubKey.getHashB64(), appInfo.agent_pub_key.getHashB64()); + t.deepEqual(myPubKey.toString(), appInfo.agent_pub_key.toString()); t.deepEqual(myPubKey.toBytes(), appInfo.agent_pub_key.toBytes()); }) -); \ No newline at end of file +);