diff --git a/ts/src/local/conductor.ts b/ts/src/local/conductor.ts index 65867972..1e3a11e5 100644 --- a/ts/src/local/conductor.ts +++ b/ts/src/local/conductor.ts @@ -396,13 +396,11 @@ export class Conductor implements IConductor { installed_app_id, network_seed, }; - if (agent_key) { - logger.debug( - `installing app with id ${installed_app_id} for agent ${encodeHashToBase64( - agent_key - )}` - ); - } + logger.debug( + `installing app with id ${installed_app_id} for agent ${encodeHashToBase64( + agent_key + )}` + ); return this.adminWs().installApp(installAppRequest); } diff --git a/ts/src/trycp/trycp-client.ts b/ts/src/trycp/trycp-client.ts index 39a41f7e..d6cb4217 100644 --- a/ts/src/trycp/trycp-client.ts +++ b/ts/src/trycp/trycp-client.ts @@ -1,4 +1,4 @@ -import { SignalCb, AppSignal, CallZomeRequestSigned } from "@holochain/client"; +import { SignalCb, CallZomeRequestSigned } from "@holochain/client"; import msgpack from "@msgpack/msgpack"; import cloneDeep from "lodash/cloneDeep.js"; import assert from "node:assert"; diff --git a/ts/src/trycp/util.ts b/ts/src/trycp/util.ts index a3d04434..fe63dbd1 100644 --- a/ts/src/trycp/util.ts +++ b/ts/src/trycp/util.ts @@ -1,4 +1,4 @@ -import { Signal, SignalType } from "@holochain/client"; +import { AppSignal, RawSignal, Signal, SignalType } from "@holochain/client"; import msgpack from "@msgpack/msgpack"; import assert from "node:assert"; import { TryCpApiResponse, _TryCpResponseWrapper } from "./types.js"; @@ -25,13 +25,18 @@ export const deserializeTryCpResponse = (response: Uint8Array) => { */ export const deserializeTryCpSignal = (signal: Uint8Array) => { const deserializedSignal = msgpack.decode(signal); - assertIsSignal(deserializedSignal); + assertIsRawSignal(deserializedSignal); if (SignalType.App in deserializedSignal) { const { - [SignalType.App]: { cell_id, payload: decodedPayload, zome_name }, + [SignalType.App]: { cell_id, signal, zome_name }, } = deserializedSignal; - const app_payload = { cell_id, payload: decodedPayload, zome_name }; - return { App: app_payload } as Signal; + const decodedPayload = msgpack.decode(signal) as T; + const app_signal: AppSignal = { + cell_id, + zome_name, + payload: decodedPayload, + }; + return { App: app_signal } as Signal; } else { throw new Error("Receiving system signals is not implemented yet"); } @@ -85,7 +90,7 @@ function assertIsApiResponse( assert(response && typeof response === "object" && "type" in response); } -function assertIsSignal(signal: unknown): asserts signal is Signal { +function assertIsRawSignal(signal: unknown): asserts signal is RawSignal { assert( signal && typeof signal === "object" && diff --git a/ts/test/fixture/zomes/coordinator/src/lib.rs b/ts/test/fixture/zomes/coordinator/src/lib.rs index f1970bb2..a674d76c 100644 --- a/ts/test/fixture/zomes/coordinator/src/lib.rs +++ b/ts/test/fixture/zomes/coordinator/src/lib.rs @@ -44,7 +44,9 @@ fn signal_loopback(value: LoopBack) -> ExternResult<()> { } #[hdk_extern] -fn create_two_party_countersigning_session(with_other: AgentPubKey) -> ExternResult { +fn create_two_party_countersigning_session( + with_other: AgentPubKey, +) -> ExternResult { let my_agent_info = agent_info()?; let entry = Content("hello".to_string()); @@ -55,27 +57,22 @@ fn create_two_party_countersigning_session(with_other: AgentPubKey) -> ExternRes let request = PreflightRequest::try_new( entry_hash, vec![ - ( - my_agent_info.agent_initial_pubkey, - vec![], - ), + (my_agent_info.agent_initial_pubkey, vec![]), (with_other.clone(), vec![]), ], Vec::with_capacity(0), 0, true, session_times, - ActionBase::Create(CreateBase::new( - EntryTypesUnit::Content.try_into()?, - )), + ActionBase::Create(CreateBase::new(EntryTypesUnit::Content.try_into()?)), PreflightBytes(vec![]), ) - .map_err(|e| { - wasm_error!(WasmErrorInner::Guest(format!( + .map_err(|e| { + wasm_error!(WasmErrorInner::Guest(format!( "Failed to create countersigning request: {:?}", e ))) - })?; + })?; // Accept ours now and then Holochain should wait for the other party to join the session let my_acceptance = accept_countersigning_preflight_request(request.clone())?; @@ -97,9 +94,7 @@ fn create_two_party_countersigning_session(with_other: AgentPubKey) -> ExternRes fn accept_two_party(request: PreflightRequest) -> ExternResult { let my_accept = accept_countersigning_preflight_request(request)?; match my_accept { - PreflightRequestAcceptance::Accepted(response) => { - Ok(response) - } + PreflightRequestAcceptance::Accepted(response) => Ok(response), e => Err(wasm_error!(WasmErrorInner::Guest(format!( "Unexpected response: {:?}", e diff --git a/ts/test/local/conductor.ts b/ts/test/local/conductor.ts index 4780a4c2..81cf59c7 100644 --- a/ts/test/local/conductor.ts +++ b/ts/test/local/conductor.ts @@ -6,7 +6,6 @@ import { CellProvisioningStrategy, CloneId, EntryHash, - AppSignal, SignalType, } from "@holochain/client"; import assert from "node:assert"; diff --git a/ts/test/local/scenario.ts b/ts/test/local/scenario.ts index 9d397501..a2be083c 100644 --- a/ts/test/local/scenario.ts +++ b/ts/test/local/scenario.ts @@ -5,7 +5,6 @@ import { SignalCb, AppWebsocket, EntryHash, - AppSignal, SignalType, } from "@holochain/client"; import assert from "node:assert/strict"; diff --git a/ts/test/trycp/conductor.ts b/ts/test/trycp/conductor.ts index cf400600..8f711758 100644 --- a/ts/test/trycp/conductor.ts +++ b/ts/test/trycp/conductor.ts @@ -8,6 +8,7 @@ import { CloneId, encodeHashToBase64, EntryHash, + SignalType, GrantedFunctionsType, } from "@holochain/client"; import assert from "node:assert"; @@ -433,7 +434,7 @@ test("TryCP Conductor - receive a signal", async (t) => { }); const actualSignal = await signalReceived; t.deepEqual( - actualSignal.payload, + actualSignal[SignalType.App].payload, testSignal, "received signal matches expected signal" ); diff --git a/ts/test/trycp/scenario.ts b/ts/test/trycp/scenario.ts index c34b45ae..f19c119f 100644 --- a/ts/test/trycp/scenario.ts +++ b/ts/test/trycp/scenario.ts @@ -1,4 +1,4 @@ -import { Signal, SignalCb, EntryHash } from "@holochain/client"; +import { Signal, SignalCb, EntryHash, SignalType } from "@holochain/client"; import { URL } from "node:url"; import test from "tape-promise/tape.js"; import { runLocalServices } from "../../src/common.js"; @@ -192,12 +192,18 @@ test("TryCP Scenario - receive signals with 2 conductors", async (t) => { signalReceivedAlice, signalReceivedBob, ]); + t.deepEqual( - actualSignalAlice.payload, + actualSignalAlice[SignalType.App].payload, signalAlice, "received alice's signal" ); - t.deepEqual(actualSignalBob.payload, signalBob, "received bob's signal"); + + t.deepEqual( + actualSignalBob[SignalType.App].payload, + signalBob, + "received bob's signal" + ); await scenario.cleanUp(); await tryCpServer.stop();