diff --git a/crates/trycp_server/tests/integration.rs b/crates/trycp_server/tests/integration.rs index 5bca272a..2975c96e 100644 --- a/crates/trycp_server/tests/integration.rs +++ b/crates/trycp_server/tests/integration.rs @@ -32,9 +32,8 @@ async fn multiple_conductors_on_same_machine_are_assigned_different_admin_ports( id: id_player_1.to_string(), partial_config: "dpki: dna_path: ~ - network_seed: test - allow_throwaway_random_dpki_agent_key: true - no_dpki: false" + network_seed: ~ + no_dpki: true" .to_string(), }, ONE_MIN, @@ -87,9 +86,8 @@ async fn multiple_conductors_on_same_machine_are_assigned_different_admin_ports( id: id_player_2.to_string(), partial_config: "dpki: dna_path: ~ - network_seed: test - allow_throwaway_random_dpki_agent_key: true - no_dpki: false" + network_seed: ~ + no_dpki: true" .to_string(), }, ONE_MIN, diff --git a/ts/src/local/conductor.ts b/ts/src/local/conductor.ts index fcbc7de1..4daebeec 100644 --- a/ts/src/local/conductor.ts +++ b/ts/src/local/conductor.ts @@ -62,15 +62,19 @@ export interface ConductorOptions { /** * Disable DPKI in the conductor instance. + * + * unstable */ - noDpki?: boolean; + // noDpki?: boolean; /** * Set a DPKI network seed in the conductor instance. * * Defaults to "deepkey-test". + * + * unstable */ - dpkiNetworkSeed?: NetworkSeed; + // dpkiNetworkSeed?: NetworkSeed; /** * Timeout for requests to Admin and App API. @@ -85,11 +89,7 @@ export interface ConductorOptions { */ export type CreateConductorOptions = Pick< ConductorOptions, - | "bootstrapServerUrl" - | "networkType" - | "noDpki" - | "dpkiNetworkSeed" - | "timeout" + "bootstrapServerUrl" | "networkType" | "timeout" >; /** @@ -152,12 +152,6 @@ export class Conductor implements IConductor { signalingServerUrl: URL, options?: CreateConductorOptions ) { - if (options?.noDpki && options?.dpkiNetworkSeed) { - throw new Error( - "DPKI network seed can not be set when DPKI is disabled. Enable DPKI or do not provide a DPKI network seed." - ); - } - const networkType = options?.networkType ?? NetworkType.WebRtc; if (options?.bootstrapServerUrl && networkType !== NetworkType.WebRtc) { throw new Error( @@ -166,12 +160,6 @@ export class Conductor implements IConductor { } const args = ["sandbox", "--piped", "create", "--in-process-lair"]; - if (options?.noDpki) { - args.push("--no-dpki"); - } - if (options?.dpkiNetworkSeed) { - args.push("--dpki-network-seed", options.dpkiNetworkSeed); - } args.push("network"); if (options?.bootstrapServerUrl) { args.push("--bootstrap", options.bootstrapServerUrl.href); diff --git a/ts/src/trycp/conductor/conductor.ts b/ts/src/trycp/conductor/conductor.ts index b403502c..d2a3c88a 100644 --- a/ts/src/trycp/conductor/conductor.ts +++ b/ts/src/trycp/conductor/conductor.ts @@ -144,13 +144,17 @@ export interface TryCpConductorOptions { * Disable DPKI in the conductor instance. * * default: false // defaults to using DPKI + * + * unstable */ - noDpki?: boolean; + // noDpki?: boolean; /** * Set a DPKI network seed. + * + * unstable */ - dpkiNetworkSeed?: string; + // dpkiNetworkSeed?: string; /** * Start up conductor after creation. @@ -185,11 +189,7 @@ export const createTryCpConductor = async ( const conductor = new TryCpConductor(tryCpClient, options?.id); if (options?.startup !== false) { // configure and startup conductor by default - await conductor.configure( - options?.partialConfig, - options?.noDpki, - options?.dpkiNetworkSeed - ); + await conductor.configure(options?.partialConfig, true, undefined); await conductor.startUp({ logLevel: options?.logLevel }); } return conductor; @@ -210,7 +210,7 @@ export class TryCpConductor implements IConductor { } static defaultPartialConfig() { - return getPartialConfig(); + return getPartialConfig(true); } /** diff --git a/ts/src/trycp/conductor/scenario.ts b/ts/src/trycp/conductor/scenario.ts index 6ae5187e..7c0e7f60 100644 --- a/ts/src/trycp/conductor/scenario.ts +++ b/ts/src/trycp/conductor/scenario.ts @@ -83,8 +83,8 @@ export interface ClientPlayers { * @public */ export class TryCpScenario { - noDpki: boolean; - dpkiNetworkSeed: string; + private noDpki: boolean; + private dpkiNetworkSeed: string; network_seed: string; servicesProcess: ChildProcessWithoutNullStreams | undefined; bootstrapServerUrl: URL | undefined; @@ -92,7 +92,7 @@ export class TryCpScenario { clients: TryCpClient[]; constructor() { - this.noDpki = false; + this.noDpki = true; this.dpkiNetworkSeed = uuidv4(); this.network_seed = uuidv4(); this.clients = []; @@ -144,9 +144,9 @@ export class TryCpScenario { // Conductors must be created in sequence to avoid identical admin ports being assigned multiple times. const conductor = await client.addConductor({ partialConfig: options?.partialConfig, - noDpki: this.noDpki, + // noDpki: this.noDpki, // Set a common unique DPKI network seed. - dpkiNetworkSeed: this.noDpki ? "" : this.dpkiNetworkSeed, + // dpkiNetworkSeed: this.noDpki ? "" : this.dpkiNetworkSeed, }); const app = options.app; let appOptions; @@ -217,8 +217,8 @@ export class TryCpScenario { ) { const conductor = await tryCpClient.addConductor({ logLevel: options?.logLevel, - noDpki: this.noDpki, - dpkiNetworkSeed: this.dpkiNetworkSeed, + // noDpki: this.noDpki, + // dpkiNetworkSeed: this.dpkiNetworkSeed, }); options = { ...options, diff --git a/ts/test/fixture/zomes/coordinator/src/lib.rs b/ts/test/fixture/zomes/coordinator/src/lib.rs index a674d76c..8e29b18e 100644 --- a/ts/test/fixture/zomes/coordinator/src/lib.rs +++ b/ts/test/fixture/zomes/coordinator/src/lib.rs @@ -1,5 +1,5 @@ use hdk::prelude::*; -use integrity::{Content, EntryTypes, EntryTypesUnit, UpdateInput}; +use integrity::{Content, EntryTypes, UpdateInput}; #[hdk_extern] pub fn create(input: Content) -> ExternResult { @@ -43,91 +43,91 @@ fn signal_loopback(value: LoopBack) -> ExternResult<()> { Ok(()) } -#[hdk_extern] -fn create_two_party_countersigning_session( - with_other: AgentPubKey, -) -> ExternResult { - let my_agent_info = agent_info()?; - - let entry = Content("hello".to_string()); - - let entry_hash = hash_entry(EntryTypes::Content(entry.clone()))?; - - let session_times = session_times_from_millis(10_000)?; - let request = PreflightRequest::try_new( - entry_hash, - 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()?)), - PreflightBytes(vec![]), - ) - .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())?; - - let response = match &my_acceptance { - PreflightRequestAcceptance::Accepted(response) => response.clone(), - e => { - return Err(wasm_error!(WasmErrorInner::Guest(format!( - "Unexpected response: {:?}", - e - )))) - } - }; - - Ok(response) -} - -#[hdk_extern] -fn accept_two_party(request: PreflightRequest) -> ExternResult { - let my_accept = accept_countersigning_preflight_request(request)?; - match my_accept { - PreflightRequestAcceptance::Accepted(response) => Ok(response), - e => Err(wasm_error!(WasmErrorInner::Guest(format!( - "Unexpected response: {:?}", - e - )))), - } -} - -#[hdk_extern] -fn commit_two_party(responses: Vec) -> ExternResult<()> { - let inner = Content("hello".to_string()); - - let entry = Entry::CounterSign( - Box::new( - CounterSigningSessionData::try_from_responses(responses, vec![]).map_err( - |countersigning_error| { - wasm_error!(WasmErrorInner::Guest(countersigning_error.to_string())) - }, - )?, - ), - inner.clone().try_into()?, - ); - - let agreement = EntryTypes::Content(inner); - let entry_def_index = ScopedEntryDefIndex::try_from(&agreement)?; - let visibility = EntryVisibility::from(&agreement); - - hdk::prelude::create(CreateInput::new( - entry_def_index, - visibility, - entry, - // Countersigned entries MUST have strict ordering. - ChainTopOrdering::Strict, - ))?; - - Ok(()) -} +// #[hdk_extern] +// fn create_two_party_countersigning_session( +// with_other: AgentPubKey, +// ) -> ExternResult { +// let my_agent_info = agent_info()?; + +// let entry = Content("hello".to_string()); + +// let entry_hash = hash_entry(EntryTypes::Content(entry.clone()))?; + +// let session_times = session_times_from_millis(10_000)?; +// let request = PreflightRequest::try_new( +// entry_hash, +// 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()?)), +// PreflightBytes(vec![]), +// ) +// .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())?; + +// let response = match &my_acceptance { +// PreflightRequestAcceptance::Accepted(response) => response.clone(), +// e => { +// return Err(wasm_error!(WasmErrorInner::Guest(format!( +// "Unexpected response: {:?}", +// e +// )))) +// } +// }; + +// Ok(response) +// } + +// #[hdk_extern] +// fn accept_two_party(request: PreflightRequest) -> ExternResult { +// let my_accept = accept_countersigning_preflight_request(request)?; +// match my_accept { +// PreflightRequestAcceptance::Accepted(response) => Ok(response), +// e => Err(wasm_error!(WasmErrorInner::Guest(format!( +// "Unexpected response: {:?}", +// e +// )))), +// } +// } + +// #[hdk_extern] +// fn commit_two_party(responses: Vec) -> ExternResult<()> { +// let inner = Content("hello".to_string()); + +// let entry = Entry::CounterSign( +// Box::new( +// CounterSigningSessionData::try_from_responses(responses, vec![]).map_err( +// |countersigning_error| { +// wasm_error!(WasmErrorInner::Guest(countersigning_error.to_string())) +// }, +// )?, +// ), +// inner.clone().try_into()?, +// ); + +// let agreement = EntryTypes::Content(inner); +// let entry_def_index = ScopedEntryDefIndex::try_from(&agreement)?; +// let visibility = EntryVisibility::from(&agreement); + +// hdk::prelude::create(CreateInput::new( +// entry_def_index, +// visibility, +// entry, +// // Countersigned entries MUST have strict ordering. +// ChainTopOrdering::Strict, +// ))?; + +// Ok(()) +// } diff --git a/ts/test/local/conductor.ts b/ts/test/local/conductor.ts index 87eab785..09a1c6de 100644 --- a/ts/test/local/conductor.ts +++ b/ts/test/local/conductor.ts @@ -54,7 +54,7 @@ test("Local Conductor - spawn a conductor with mem network", async (t) => { const conductorConfig = readFileSync( tmpDirPath + "/conductor-config.yaml" ).toString(); - t.ok(conductorConfig.includes("transport_pool: []")); + t.ok(conductorConfig.includes("transport_pool:\n - type: mem")); await stopLocalServices(servicesProcess); await cleanAllConductors(); @@ -71,7 +71,6 @@ test("Local Conductor - spawn a conductor with a bootstrap service", async (t) = const conductorConfig = readFileSync( tmpDirPath + "/conductor-config.yaml" ).toString(); - t.ok(conductorConfig.includes("network_type: quic_bootstrap")); t.ok(conductorConfig.includes(`bootstrap_service: ${bootstrapUrl.href}`)); await stopLocalServices(servicesProcess); @@ -88,76 +87,77 @@ test("Local Conductor - spawn a conductor and check for admin ws", async (t) => await cleanAllConductors(); }); -test("Local Conductor - default conductor has DPKI enabled", async (t) => { - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const conductor = await createConductor(signalingServerUrl); - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes("no_dpki: false"), - "DPKI enabled in conductor config" - ); - - await conductor.shutDown(); - await stopLocalServices(servicesProcess); - await cleanAllConductors(); -}); - -test("Local Conductor - spawn a conductor without DPKI enabled", async (t) => { - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const conductor = await createConductor(signalingServerUrl, { noDpki: true }); - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes("no_dpki: true"), - "DPKI disabled in conductor config" - ); - - await conductor.shutDown(); - await stopLocalServices(servicesProcess); - await cleanAllConductors(); -}); - -test("Local Conductor - default conductor has test DPKI network seed", async (t) => { - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const conductor = await createConductor(signalingServerUrl); - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes("network_seed: deepkey-test"), - "default DPKI network seed set in conductor config" - ); - - await conductor.shutDown(); - await stopLocalServices(servicesProcess); - await cleanAllConductors(); -}); - -test("Local Conductor - set a DPKI network seed", async (t) => { - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const networkSeed = "tryorama-test-dpki"; - const conductor = await createConductor(signalingServerUrl, { - dpkiNetworkSeed: networkSeed, - }); - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes(`network_seed: ${networkSeed}`), - "DPKI network seed set in conductor config" - ); - - await conductor.shutDown(); - await stopLocalServices(servicesProcess); - await cleanAllConductors(); -}); +// unstable-dpki +// test("Local Conductor - default conductor has DPKI enabled", async (t) => { +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const conductor = await createConductor(signalingServerUrl); +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes("no_dpki: false"), +// "DPKI enabled in conductor config" +// ); + +// await conductor.shutDown(); +// await stopLocalServices(servicesProcess); +// await cleanAllConductors(); +// }); + +// test("Local Conductor - spawn a conductor without DPKI enabled", async (t) => { +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const conductor = await createConductor(signalingServerUrl, { noDpki: true }); +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes("no_dpki: true"), +// "DPKI disabled in conductor config" +// ); + +// await conductor.shutDown(); +// await stopLocalServices(servicesProcess); +// await cleanAllConductors(); +// }); + +// test("Local Conductor - default conductor has test DPKI network seed", async (t) => { +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const conductor = await createConductor(signalingServerUrl); +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes("network_seed: deepkey-test"), +// "default DPKI network seed set in conductor config" +// ); + +// await conductor.shutDown(); +// await stopLocalServices(servicesProcess); +// await cleanAllConductors(); +// }); + +// test("Local Conductor - set a DPKI network seed", async (t) => { +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const networkSeed = "tryorama-test-dpki"; +// const conductor = await createConductor(signalingServerUrl, { +// dpkiNetworkSeed: networkSeed, +// }); +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes(`network_seed: ${networkSeed}`), +// "DPKI network seed set in conductor config" +// ); + +// await conductor.shutDown(); +// await stopLocalServices(servicesProcess); +// await cleanAllConductors(); +// }); test("Local Conductor - revoke agent key", async (t) => { const { servicesProcess, signalingServerUrl } = await runLocalServices(); diff --git a/ts/test/local/scenario.ts b/ts/test/local/scenario.ts index 910624b2..59384d88 100644 --- a/ts/test/local/scenario.ts +++ b/ts/test/local/scenario.ts @@ -113,87 +113,88 @@ test("Local Scenario - Add players with hApp bundles", async (t) => { await scenario.cleanUp(); }); -test("Local Scenario - All players have DPKI enabled", async (t) => { - const scenario = new Scenario(); - await scenario.addPlayersWithApps([ - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - ]); - scenario.conductors.every((conductor) => { - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes("no_dpki: false"), - "DPKI enabled in conductor config" - ); - }); - - await scenario.cleanUp(); -}); - -test("Local Scenario - All players have DPKI disabled", async (t) => { - const scenario = new Scenario(); - scenario.noDpki = true; - await scenario.addPlayersWithApps([ - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - ]); - scenario.conductors.every((conductor) => { - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes("no_dpki: true"), - "DPKI disabled in conductor config" - ); - }); - - await scenario.cleanUp(); -}); - -test("Local Scenario - All players have a custom DPKI network seed", async (t) => { - const scenario = new Scenario(); - scenario.dpkiNetworkSeed = "tryorama-dpki-test"; - await scenario.addPlayersWithApps([ - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - ]); - scenario.conductors.every((conductor) => { - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes(`network_seed: ${scenario.dpkiNetworkSeed}`), - "default DPKI network seed set in conductor config" - ); - }); - - await scenario.cleanUp(); -}); - -test("Local Scenario - All players have a random DPKI network seed", async (t) => { - const scenario = new Scenario(); - await scenario.addPlayersWithApps([ - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, - ]); - scenario.conductors.every((conductor) => { - const tmpDirPath = conductor.getTmpDirectory(); - const conductorConfig = readFileSync( - tmpDirPath + "/conductor-config.yaml" - ).toString(); - t.assert( - conductorConfig.includes(`network_seed: ${scenario.dpkiNetworkSeed}`), - "DPKI network seed set in conductor config" - ); - }); - - await scenario.cleanUp(); -}); +// unstable-dpki +// test("Local Scenario - All players have DPKI enabled", async (t) => { +// const scenario = new Scenario(); +// await scenario.addPlayersWithApps([ +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// ]); +// scenario.conductors.every((conductor) => { +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes("no_dpki: false"), +// "DPKI enabled in conductor config" +// ); +// }); + +// await scenario.cleanUp(); +// }); + +// test("Local Scenario - All players have DPKI disabled", async (t) => { +// const scenario = new Scenario(); +// scenario.noDpki = true; +// await scenario.addPlayersWithApps([ +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// ]); +// scenario.conductors.every((conductor) => { +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes("no_dpki: true"), +// "DPKI disabled in conductor config" +// ); +// }); + +// await scenario.cleanUp(); +// }); + +// test("Local Scenario - All players have a custom DPKI network seed", async (t) => { +// const scenario = new Scenario(); +// scenario.dpkiNetworkSeed = "tryorama-dpki-test"; +// await scenario.addPlayersWithApps([ +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// ]); +// scenario.conductors.every((conductor) => { +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes(`network_seed: ${scenario.dpkiNetworkSeed}`), +// "default DPKI network seed set in conductor config" +// ); +// }); + +// await scenario.cleanUp(); +// }); + +// test("Local Scenario - All players have a random DPKI network seed", async (t) => { +// const scenario = new Scenario(); +// await scenario.addPlayersWithApps([ +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// { appBundleSource: { path: FIXTURE_HAPP_URL.pathname } }, +// ]); +// scenario.conductors.every((conductor) => { +// const tmpDirPath = conductor.getTmpDirectory(); +// const conductorConfig = readFileSync( +// tmpDirPath + "/conductor-config.yaml" +// ).toString(); +// t.assert( +// conductorConfig.includes(`network_seed: ${scenario.dpkiNetworkSeed}`), +// "DPKI network seed set in conductor config" +// ); +// }); + +// await scenario.cleanUp(); +// }); test("Local Scenario - Create and read an entry, 2 conductors", async (t) => { // The wrapper takes care of creating a scenario and shutting down or deleting @@ -384,73 +385,74 @@ test("Local Scenario - runScenario - call zome by role name", async (t) => { }); }); -test("Local Scenario - countersigning", async (t) => { - await runScenario(async (scenario: Scenario) => { - const appBundleSource: AppBundleSource = { - path: FIXTURE_HAPP_URL.pathname, - }; - const [alice, bob] = await scenario.addPlayersWithApps([ - { appBundleSource }, - { appBundleSource }, - ]); - - const result = new Promise((resolve, reject) => { - const timeout = setTimeout( - () => reject("timeout waiting for signal"), - 60000 - ); - (alice.appWs as AppWebsocket).on("signal", (signal) => { - clearTimeout(timeout); - resolve(signal); - }); - }); - - // Make sure init has been called - await alice.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "create", - payload: "hello", - }); - - await bob.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "create", - payload: "hello", - }); - - const response1: PreflightResponse = await alice.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "create_two_party_countersigning_session", - payload: bob.agentPubKey, - }); - - const response2: PreflightResponse = await bob.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "accept_two_party", - payload: response1.request, - }); - - await alice.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "commit_two_party", - payload: [response1, response2], - }); - - await bob.appWs.callZome({ - role_name: "test", - zome_name: "coordinator", - fn_name: "commit_two_party", - payload: [response1, response2], - }); - - const completionSignal = await result; - assert(SignalType.System in completionSignal); - const systemSignal = completionSignal[SignalType.System]; - t.assert("SuccessfulCountersigning" in systemSignal); - }); -}); +// unstable-countersigning +// test("Local Scenario - countersigning", async (t) => { +// await runScenario(async (scenario: Scenario) => { +// const appBundleSource: AppBundleSource = { +// path: FIXTURE_HAPP_URL.pathname, +// }; +// const [alice, bob] = await scenario.addPlayersWithApps([ +// { appBundleSource }, +// { appBundleSource }, +// ]); + +// const result = new Promise((resolve, reject) => { +// const timeout = setTimeout( +// () => reject("timeout waiting for signal"), +// 60000 +// ); +// (alice.appWs as AppWebsocket).on("signal", (signal) => { +// clearTimeout(timeout); +// resolve(signal); +// }); +// }); + +// // Make sure init has been called +// await alice.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "create", +// payload: "hello", +// }); + +// await bob.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "create", +// payload: "hello", +// }); + +// const response1: PreflightResponse = await alice.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "create_two_party_countersigning_session", +// payload: bob.agentPubKey, +// }); + +// const response2: PreflightResponse = await bob.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "accept_two_party", +// payload: response1.request, +// }); + +// await alice.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "commit_two_party", +// payload: [response1, response2], +// }); + +// await bob.appWs.callZome({ +// role_name: "test", +// zome_name: "coordinator", +// fn_name: "commit_two_party", +// payload: [response1, response2], +// }); + +// const completionSignal = await result; +// assert(SignalType.System in completionSignal); +// const systemSignal = completionSignal[SignalType.System]; +// t.assert("SuccessfulCountersigning" in systemSignal); +// }); +// }); diff --git a/ts/test/trycp/conductor.ts b/ts/test/trycp/conductor.ts index 466a4d3d..d4fcbc9e 100644 --- a/ts/test/trycp/conductor.ts +++ b/ts/test/trycp/conductor.ts @@ -30,51 +30,52 @@ import { FIXTURE_DNA_URL, FIXTURE_HAPP_URL } from "../fixture"; const SERVER_URL = new URL(`ws://${TRYCP_SERVER_HOST}:${TRYCP_SERVER_PORT}`); const ROLE_NAME = "test"; -test("TryCP Conductor - default conductor has DPKI enabled", async (t) => { - const localTryCpServer = await TryCpServer.start(); - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const client = await TryCpClient.create(SERVER_URL); - client.signalingServerUrl = signalingServerUrl; - const conductor = await createTryCpConductor(client); - const agent_key = await conductor.adminWs().generateAgentPubKey(); - const appInfo = await conductor.adminWs().installApp({ - path: FIXTURE_HAPP_URL.pathname, - agent_key, - membrane_proofs: {}, - }); - await conductor - .adminWs() - .enableApp({ installed_app_id: appInfo.installed_app_id }); - const cellIds = await conductor.adminWs().listCellIds(); - t.equal(cellIds.length, 2, "Conductor includes DPKI cell id"); - - await stopLocalServices(servicesProcess); - await client.cleanUp(); - await localTryCpServer.stop(); -}); - -test("TryCP Conductor - startup DPKI disabled conductor", async (t) => { - const localTryCpServer = await TryCpServer.start(); - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const client = await TryCpClient.create(SERVER_URL); - client.signalingServerUrl = signalingServerUrl; - const conductor = await createTryCpConductor(client, { noDpki: true }); - const agent_key = await conductor.adminWs().generateAgentPubKey(); - const appInfo = await conductor.adminWs().installApp({ - path: FIXTURE_HAPP_URL.pathname, - agent_key, - membrane_proofs: {}, - }); - await conductor - .adminWs() - .enableApp({ installed_app_id: appInfo.installed_app_id }); - const cellIds = await conductor.adminWs().listCellIds(); - t.equal(cellIds.length, 1, "Conductor contains only the app cell"); - - await stopLocalServices(servicesProcess); - await client.cleanUp(); - await localTryCpServer.stop(); -}); +// unstable-dpki +// test("TryCP Conductor - default conductor has DPKI enabled", async (t) => { +// const localTryCpServer = await TryCpServer.start(); +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const client = await TryCpClient.create(SERVER_URL); +// client.signalingServerUrl = signalingServerUrl; +// const conductor = await createTryCpConductor(client); +// const agent_key = await conductor.adminWs().generateAgentPubKey(); +// const appInfo = await conductor.adminWs().installApp({ +// path: FIXTURE_HAPP_URL.pathname, +// agent_key, +// membrane_proofs: {}, +// }); +// await conductor +// .adminWs() +// .enableApp({ installed_app_id: appInfo.installed_app_id }); +// const cellIds = await conductor.adminWs().listCellIds(); +// t.equal(cellIds.length, 2, "Conductor includes DPKI cell id"); + +// await stopLocalServices(servicesProcess); +// await client.cleanUp(); +// await localTryCpServer.stop(); +// }); + +// test("TryCP Conductor - startup DPKI disabled conductor", async (t) => { +// const localTryCpServer = await TryCpServer.start(); +// const { servicesProcess, signalingServerUrl } = await runLocalServices(); +// const client = await TryCpClient.create(SERVER_URL); +// client.signalingServerUrl = signalingServerUrl; +// const conductor = await createTryCpConductor(client, { noDpki: true }); +// const agent_key = await conductor.adminWs().generateAgentPubKey(); +// const appInfo = await conductor.adminWs().installApp({ +// path: FIXTURE_HAPP_URL.pathname, +// agent_key, +// membrane_proofs: {}, +// }); +// await conductor +// .adminWs() +// .enableApp({ installed_app_id: appInfo.installed_app_id }); +// const cellIds = await conductor.adminWs().listCellIds(); +// t.equal(cellIds.length, 1, "Conductor contains only the app cell"); + +// await stopLocalServices(servicesProcess); +// await client.cleanUp(); +// await localTryCpServer.stop(); +// }); test("TryCP Conductor - revoke agent key", async (t) => { const localTryCpServer = await TryCpServer.start(); @@ -646,36 +647,6 @@ test("TryCP Conductor - create and read an entry using the entry zome", async (t await localTryCpServer.stop(); }); -test("TryCP Conductor - reading a non-existent entry returns null", async (t) => { - const localTryCpServer = await TryCpServer.start(); - const { servicesProcess, signalingServerUrl } = await runLocalServices(); - const client = await TryCpClient.create(SERVER_URL); - client.signalingServerUrl = signalingServerUrl; - const conductor = await createTryCpConductor(client); - const app = { path: FIXTURE_HAPP_URL.pathname }; - const aliceApp = await conductor.installApp(app); - const adminWs = conductor.adminWs(); - const { port } = await adminWs.attachAppInterface(); - const issued = await adminWs.issueAppAuthenticationToken({ - installed_app_id: aliceApp.installed_app_id, - }); - await conductor.connectAppInterface(issued.token, port); - const appWs = await conductor.connectAppWs(issued.token, port); - const alice = await enableAndGetAgentApp(adminWs, appWs, aliceApp); - - const actual = await alice.cells[0].callZome({ - zome_name: "coordinator", - fn_name: "read", - provenance: alice.agentPubKey, - payload: Buffer.from("hCkk", "base64"), - }); - t.equal(actual, null, "read a non-existing entry returns null"); - - await stopLocalServices(servicesProcess); - await client.cleanUp(); - await localTryCpServer.stop(); -}); - test("TryCP Conductor - create and read an entry using the entry zome, 1 conductor, 2 cells, 2 agents", async (t) => { const localTryCpServer = await TryCpServer.start(); const { servicesProcess, signalingServerUrl } = await runLocalServices(); diff --git a/ts/test/trycp/scenario.ts b/ts/test/trycp/scenario.ts index 0b6eb875..9d496e68 100644 --- a/ts/test/trycp/scenario.ts +++ b/ts/test/trycp/scenario.ts @@ -17,26 +17,27 @@ import { FIXTURE_HAPP_URL } from "../fixture/index.js"; const SERVER_URL = new URL(`ws://${TRYCP_SERVER_HOST}:${TRYCP_SERVER_PORT}`); -test("TryCP Scenario - default player has DPKI enabled", async (t) => { - const tryCpServer = await TryCpServer.start(); - - const scenario = new TryCpScenario(); - ({ - servicesProcess: scenario.servicesProcess, - signalingServerUrl: scenario.signalingServerUrl, - } = await runLocalServices()); - const client = await scenario.addClient(SERVER_URL); - t.ok(client, "client set up"); - - const player = await scenario.addPlayerWithApp(client, { - path: FIXTURE_HAPP_URL.pathname, - }); - const cellIds = await player.conductor.adminWs().listCellIds(); - t.equal(cellIds.length, 2, "conductor has 1 app cell and 1 DPKI cell"); - - await scenario.cleanUp(); - await tryCpServer.stop(); -}); +// unstable-dpki +// test("TryCP Scenario - default player has DPKI enabled", async (t) => { +// const tryCpServer = await TryCpServer.start(); + +// const scenario = new TryCpScenario(); +// ({ +// servicesProcess: scenario.servicesProcess, +// signalingServerUrl: scenario.signalingServerUrl, +// } = await runLocalServices()); +// const client = await scenario.addClient(SERVER_URL); +// t.ok(client, "client set up"); + +// const player = await scenario.addPlayerWithApp(client, { +// path: FIXTURE_HAPP_URL.pathname, +// }); +// const cellIds = await player.conductor.adminWs().listCellIds(); +// t.equal(cellIds.length, 2, "conductor has 1 app cell and 1 DPKI cell"); + +// await scenario.cleanUp(); +// await tryCpServer.stop(); +// }); test("TryCP Scenario - can create player without DPKI", async (t) => { const tryCpServer = await TryCpServer.start(); @@ -49,7 +50,6 @@ test("TryCP Scenario - can create player without DPKI", async (t) => { const client = await scenario.addClient(SERVER_URL); t.ok(client, "client set up"); - scenario.noDpki = true; const player = await scenario.addPlayerWithApp(client, { path: FIXTURE_HAPP_URL.pathname, }); @@ -179,11 +179,7 @@ test("TryCP Scenario - list everything", async (t) => { ); const listCellIds = await alice.conductor.adminWs().listCellIds(); - t.equal( - listCellIds.length, - 2, - "alice's conductor lists 2 cell ids including DPKI" - ); + t.equal(listCellIds.length, 1, "alice's conductor lists 1 cell id"); const listedDnas = await alice.conductor.adminWs().listDnas(); t.equal(listedDnas.length, 1, "alice's conductor lists 1 DNA"); @@ -412,7 +408,6 @@ test("TryCP Scenario - connect to multiple clients without DPKI", async (t) => { } const scenario = new TryCpScenario(); - scenario.noDpki = true; ({ servicesProcess: scenario.servicesProcess, signalingServerUrl: scenario.signalingServerUrl,