From 64378d571c2b4eaa171510e55412b2244cea2118 Mon Sep 17 00:00:00 2001 From: Guillem Cordoba Date: Thu, 4 Nov 2021 12:21:40 +0100 Subject: [PATCH 1/3] Tests passing --- Cargo.lock | 146 ++++++++++++++++++-- crates/trycp_server/src/configure_player.rs | 8 +- default.nix | 25 ++-- package.json | 2 +- src/cell.ts | 8 +- src/conductor.ts | 8 +- src/config/gen.ts | 92 ++++++------ src/player.ts | 2 +- src/types.ts | 9 +- test/e2e/fixture/happ.yaml | 2 +- test/e2e/fixture/zomes/test/Cargo.toml | 4 +- test/e2e/fixture/zomes/test/src/lib.rs | 4 +- 12 files changed, 227 insertions(+), 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00328619..8794ff86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.2.1" @@ -48,6 +63,37 @@ dependencies = [ "winapi", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "gcollections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f551fdf23ef80329f754919669147a71c67b6cfe3569cd93b6fabdd62044377" +dependencies = [ + "bit-set", + "num-integer", + "num-traits", + "trilean", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -56,8 +102,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "hdk" -version = "0.0.106" -source = "git+https://github.com/holochain/holochain?rev=ab02f36c87999d42026b7429164ded503bb39853#ab02f36c87999d42026b7429164ded503bb39853" +version = "0.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65dc61d4c07995311fc268453ca4fb41cbba919392a1f35f18f0afc0037aec53" dependencies = [ "hdk_derive", "holo_hash", @@ -74,8 +121,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.0.8" -source = "git+https://github.com/holochain/holochain?rev=ab02f36c87999d42026b7429164ded503bb39853#ab02f36c87999d42026b7429164ded503bb39853" +version = "0.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c806abfdc714f7a2fea73620aef505b0b3a7a3b457b80903c51f5af50d78e66" dependencies = [ "holochain_zome_types", "paste", @@ -86,10 +134,12 @@ dependencies = [ [[package]] name = "holo_hash" -version = "0.0.6" -source = "git+https://github.com/holochain/holochain?rev=ab02f36c87999d42026b7429164ded503bb39853#ab02f36c87999d42026b7429164ded503bb39853" +version = "0.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33a6e5d86f925c391dd7157dc196480836ce329c4dadf4d802eb2ca2c2b3571a" dependencies = [ "holochain_serialized_bytes", + "kitsune_p2p_dht_arc", "serde", "serde_bytes", "thiserror", @@ -147,8 +197,9 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.0.8" -source = "git+https://github.com/holochain/holochain?rev=ab02f36c87999d42026b7429164ded503bb39853#ab02f36c87999d42026b7429164ded503bb39853" +version = "0.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2771f06b41a09e59ca9d6f31767c53d54beb383b92e9c58252e428c3321a99cf" dependencies = [ "chrono", "holo_hash", @@ -182,16 +233,43 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "intervallum" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ccecd834666f695ecec3ff0d5fc32e32c91abea91a28fd0aceb4b35a82cee1" +dependencies = [ + "bit-set", + "gcollections", + "num-integer", + "num-traits", + "trilean", +] + [[package]] name = "itoa" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "kitsune_p2p_dht_arc" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1baec5c5af951a43851ade291e6c6056580ee1ab56e687da8414cd9ac919b95b" +dependencies = [ + "derive_more", + "gcollections", + "intervallum", + "num-traits", + "serde", +] + [[package]] name = "kitsune_p2p_timestamp" -version = "0.0.2" -source = "git+https://github.com/holochain/holochain?rev=ab02f36c87999d42026b7429164ded503bb39853#ab02f36c87999d42026b7429164ded503bb39853" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbac5369262b970c3a966c29502f17689da917678c9d60bdbaa9695d1b1c57fb" dependencies = [ "chrono", "serde", @@ -293,6 +371,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -371,6 +458,15 @@ dependencies = [ "serde", ] +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.5" @@ -383,6 +479,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.123" @@ -588,6 +702,18 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "trilean" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683ba5022fe6dbd7133cad150478ccf51bdb6d861515181e5fc6b4323d4fa424" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-xid" version = "0.2.2" diff --git a/crates/trycp_server/src/configure_player.rs b/crates/trycp_server/src/configure_player.rs index 2922ef02..e27b466e 100644 --- a/crates/trycp_server/src/configure_player.rs +++ b/crates/trycp_server/src/configure_player.rs @@ -76,10 +76,10 @@ pub(crate) fn configure_player( --- environment_path: environment use_dangerous_test_keystore: false -keystore_path: {} -passphrase_service: - type: danger_insecure_from_config - passphrase: password +keystore: + type: lair_server_legacy_deprecated + keystore_path: {} + danger_passphrase_insecure_from_config: test admin_interfaces: - driver: type: websocket diff --git a/default.nix b/default.nix index c8b0f822..644fad80 100644 --- a/default.nix +++ b/default.nix @@ -1,21 +1,29 @@ +{ + holonixPath ? builtins.fetchTarball { url = "https://github.com/holochain/holonix/archive/develop.tar.gz"; } +}: + let - holonixPath = builtins.fetchTarball https://github.com/holochain/holonix/archive/6ae8ffb8e5c1a1faa4f4e1af8a9f7139b2ce0f3c.tar.gz; holonix = import (holonixPath) { - includeHolochainBinaries = true; + include = { + # making this explicit even though it's the default + holochainBinaries = true; + }; + holochainVersionId = "custom"; holochainVersion = { - rev = "ab02f36c87999d42026b7429164ded503bb39853"; - sha256 = "0bwyq34hn5s2rif5g83f8xnkwjk7wl71xj9bxqib9plzk8rc0dkp"; - cargoSha256 = "0bxflwmdh785c99cjgpmynd0h70a5gm40pryzzrfd9xiypr29gi7"; + rev = "holochain-0.0.114"; + sha256 = "1r3fxmcnc6576cbq12vyzyjgdjf6754mfsivzplzmj47bwvx3hx1"; + cargoSha256 = "15d8h3ivr8xdrccxgmpwn5sv4givhvfvvhihdhdgyv1893gpmzl3"; bins = { holochain = "holochain"; hc = "hc"; + kitsune-p2p-proxy = "kitsune_p2p/proxy"; }; lairKeystoreHashes = { - sha256 = "0khg5w5fgdp1sg22vqyzsb2ri7znbxiwl7vr2zx6bwn744wy2cyv"; - cargoSha256 = "1lm8vrxh7fw7gcir9lq85frfd0rdcca9p7883nikjfbn21ac4sn4"; + sha256 = "1zq8mpxcy8p7kbj4xl4qhp2hb0fjxakixhzcb4y1rnygc90q9v01"; + cargoSha256 = "1ln0vx1blzjr4p9rqfhcl4b34blk6jiyziz2w5gh09wv2xbhyaa5"; }; }; }; @@ -24,5 +32,6 @@ in nixpkgs.mkShell { inputsFrom = [ holonix.main ]; buildInputs = with nixpkgs; [ binaryen + nodejs-16_x ]; -} +} \ No newline at end of file diff --git a/package.json b/package.json index e3f1bb5f..f7f1e821 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@holochain/conductor-api": "^0.2.1", + "@holochain/conductor-api": "github:holochain/holochain-conductor-api#update-to-113", "@holochain/hachiko": "^0.5.2", "@iarna/toml": "^2.2.5", "@msgpack/msgpack": "^2.1.0", diff --git a/src/cell.ts b/src/cell.ts index 319283bf..e0b3eb47 100644 --- a/src/cell.ts +++ b/src/cell.ts @@ -1,4 +1,4 @@ -import { CellId, CellNick, HoloHash } from '@holochain/conductor-api' +import { CellId, RoleId, HoloHash } from '@holochain/conductor-api' import { fakeCapSecret } from './common' import { Player } from './player' @@ -6,7 +6,7 @@ type CallZomeFunc = (zome: string, fn: string, params?: any) => Promise type CellConstructorParams = { cellId: CellId, - cellNick: CellNick, + cellRole: RoleId, player: Player } @@ -16,12 +16,12 @@ type CellConstructorParams = { */ export class Cell { cellId: CellId - cellNick: CellNick + cellRole: RoleId _player: Player constructor(o: CellConstructorParams) { this.cellId = o.cellId - this.cellNick = o.cellNick + this.cellRole = o.cellRole this._player = o.player } diff --git a/src/conductor.ts b/src/conductor.ts index b832f35b..a51910ba 100644 --- a/src/conductor.ts +++ b/src/conductor.ts @@ -7,7 +7,7 @@ import { delay } from './util' import env from './env' import * as T from './types' import { - CellNick, + RoleId, AdminWebsocket, AppWebsocket, AgentPubKey, @@ -289,7 +289,7 @@ export class Conductor { let dna = { hash: await this.registerDna(source, this._player.scenarioUID), - nick: `${index}${src}-${uidGen()}` + role_id: `${index}${src}-${uidGen()}` } return dna }) @@ -323,9 +323,9 @@ export class Conductor { const agentPubKey = installedAppResponse.cell_data[0].cell_id[1] const rawCells = Object.entries(installedAppResponse.cell_data) // construct Cell instances which are the most useful class to the client - const cells = rawCells.map(([_, { cell_id, cell_nick }]) => new Cell({ + const cells = rawCells.map(([_, { cell_id, role_id }]) => new Cell({ cellId: cell_id, - cellNick: cell_nick, + cellRole: role_id, player: this._player })) diff --git a/src/config/gen.ts b/src/config/gen.ts index acf46724..1a49b17d 100644 --- a/src/config/gen.ts +++ b/src/config/gen.ts @@ -1,57 +1,61 @@ -import * as T from '../types' -import _ from 'lodash' -import path from 'path' +import * as T from "../types"; +import _ from "lodash"; +import path from "path"; // default networking type is for QuicBootstrap but we don't provide a // bootstrap server, so default action discovery is explicit with shareAllNodes const defaultCommonConfig = { network: { network_type: T.NetworkType.QuicBootstrap, - transport_pool: [{ - type: T.TransportConfigType.Quic, - }], - } -} - -export const gen = ( commonConfig: T.CommonConfig = {} ): T.ConfigSeed => ( - args: T.ConfigSeedArgs -): T.RawConductorConfig => { - const { configDir, adminInterfacePort, uid } = args - const keystorePath = path.join(configDir, 'keystore'); - - // don't put any keys on this object that you want to fall back to defaults - const specific: T.RawConductorConfig = { - environment_path: configDir, - passphrase_service: { - type: "danger_insecure_from_config", - passphrase: "pass" - }, - keystore_path: keystorePath, - admin_interfaces: [ + transport_pool: [ { - driver: { - type: 'websocket', - port: adminInterfacePort, - }, + type: T.TransportConfigType.Quic, }, ], - app_interfaces: [ - { - driver: { - type: 'websocket', - port: commonConfig.appPort || 0, - }, + }, +}; + +export const gen = + (commonConfig: T.CommonConfig = {}): T.ConfigSeed => + (args: T.ConfigSeedArgs): T.RawConductorConfig => { + const { configDir, adminInterfacePort, uid } = args; + const keystorePath = path.join(configDir, "keystore"); + + // don't put any keys on this object that you want to fall back to defaults + const specific: T.RawConductorConfig = { + environment_path: configDir, + keystore: { + type: "lair_server_legacy_deprecated", + keystore_path: keystorePath, + danger_passphrase_insecure_from_config: "pass", }, - ], - ...(commonConfig.db_sync_level ? { db_sync_level: commonConfig.db_sync_level } : {}), - ...(commonConfig.network ? { network: commonConfig.network } : {}) - } + admin_interfaces: [ + { + driver: { + type: "websocket", + port: adminInterfacePort, + }, + }, + ], + app_interfaces: [ + { + driver: { + type: "websocket", + port: commonConfig.appPort || 0, + }, + }, + ], + ...(commonConfig.db_sync_level + ? { db_sync_level: commonConfig.db_sync_level } + : {}), + ...(commonConfig.network ? { network: commonConfig.network } : {}), + }; - // apply from left to right, in order of precedence - // so this will override defaults with specifically set values - // https://lodash.com/docs/4.17.15#merge - return _.merge({}, defaultCommonConfig, specific) -} + // apply from left to right, in order of precedence + // so this will override defaults with specifically set values + // https://lodash.com/docs/4.17.15#merge + return _.merge({}, defaultCommonConfig, specific); + }; export const getConfigPath = (configDir: string) => - path.join(configDir, 'conductor-config.yml') + path.join(configDir, "conductor-config.yml"); diff --git a/src/player.ts b/src/player.ts index aefa7005..8044db6b 100644 --- a/src/player.ts +++ b/src/player.ts @@ -5,7 +5,7 @@ import { Cell } from './cell' import { SpawnConductorFn, ObjectS, RawConductorConfig, InstalledHapps, InstallHapps, InstallAgentsHapps, InstalledAgentHapps, InstallHapp, InstalledHapp } from './types'; import { makeLogger } from './logger'; import { unparkPort } from './config/get-port-cautiously' -import { CellId, CallZomeRequest, CellNick, AdminWebsocket, AgentPubKey, ListAppsRequest, InstallAppRequest, AppWebsocket, HoloHash, AppBundleSource, InstallAppBundleRequest, ListAppsResponse } from '@holochain/conductor-api'; +import { CellId, CallZomeRequest, AdminWebsocket, AgentPubKey, ListAppsRequest, InstallAppRequest, AppWebsocket, HoloHash, AppBundleSource, InstallAppBundleRequest, ListAppsResponse } from '@holochain/conductor-api'; import { unimplemented } from './util'; import { fakeCapSecret } from './common'; import env from './env'; diff --git a/src/types.ts b/src/types.ts index 9d6ef638..5bd74e45 100644 --- a/src/types.ts +++ b/src/types.ts @@ -118,8 +118,7 @@ export interface PassphraseServiceConfig { export interface RawConductorConfig { environment_path: string, - passphrase_service: PassphraseServiceConfig, - use_dangerous_test_keystore?: boolean, + keystore: KeystoreConfig, signing_service_uri?: string, encryption_service_uri?: string, decryption_service_uri?: string, @@ -130,6 +129,12 @@ export interface RawConductorConfig { network?: KitsuneP2pConfig, } +export interface KeystoreConfig { + type: string; + keystore_path: string; + danger_passphrase_insecure_from_config: string; +} + export type Url2 = string export enum TransportConfigType { Mem = 'mem', diff --git a/test/e2e/fixture/happ.yaml b/test/e2e/fixture/happ.yaml index 9ffb1c80..2eb20926 100644 --- a/test/e2e/fixture/happ.yaml +++ b/test/e2e/fixture/happ.yaml @@ -2,7 +2,7 @@ manifest_version: "1" name: test-happ description: "" -slots: +roles: - id: test provisioning: strategy: create diff --git a/test/e2e/fixture/zomes/test/Cargo.toml b/test/e2e/fixture/zomes/test/Cargo.toml index b2ee28da..3dfe3090 100644 --- a/test/e2e/fixture/zomes/test/Cargo.toml +++ b/test/e2e/fixture/zomes/test/Cargo.toml @@ -9,5 +9,5 @@ name = "test_wasm" crate-type = [ "cdylib", "rlib" ] [dependencies] -hdk = {git ="https://github.com/holochain/holochain", rev = "ab02f36c87999d42026b7429164ded503bb39853", package = "hdk"} -serde = "1.0.123" +hdk = "0.0.114" +serde = "*" diff --git a/test/e2e/fixture/zomes/test/src/lib.rs b/test/e2e/fixture/zomes/test/src/lib.rs index da052855..6a103fbe 100644 --- a/test/e2e/fixture/zomes/test/src/lib.rs +++ b/test/e2e/fixture/zomes/test/src/lib.rs @@ -27,13 +27,13 @@ fn delete_link(input: HeaderHash) -> ExternResult { } #[hdk_extern] -fn get_links(_: ()) -> ExternResult { +fn get_links(_: ()) -> ExternResult> { Ok(hdk::prelude::get_links(base()?, None)?) } #[hdk_extern] fn delete_all_links(_: ()) -> ExternResult<()> { - for link in hdk::prelude::get_links(base()?, None)?.into_inner() { + for link in hdk::prelude::get_links(base()?, None)? { hdk::prelude::delete_link(link.create_link_hash)?; } Ok(()) From 9b8fc0799db88d3f536bc8ca06f2e50484d786a1 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Wed, 10 Nov 2021 14:25:18 -0500 Subject: [PATCH 2/3] Updates default.nix to new format and conductor-api to 0.2.4 --- default.nix | 29 +++-------------------------- package.json | 2 +- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/default.nix b/default.nix index 644fad80..c5a089ae 100644 --- a/default.nix +++ b/default.nix @@ -1,32 +1,9 @@ { - holonixPath ? builtins.fetchTarball { url = "https://github.com/holochain/holonix/archive/develop.tar.gz"; } + holonixPath ? builtins.fetchTarball { url = "https://github.com/holochain/holonix/archive/726694e2889a57a28b553541d2fabd8f1fbb52b2.tar.gz"; } }: let - holonix = import (holonixPath) { - include = { - # making this explicit even though it's the default - holochainBinaries = true; - }; - - holochainVersionId = "custom"; - - holochainVersion = { - rev = "holochain-0.0.114"; - sha256 = "1r3fxmcnc6576cbq12vyzyjgdjf6754mfsivzplzmj47bwvx3hx1"; - cargoSha256 = "15d8h3ivr8xdrccxgmpwn5sv4givhvfvvhihdhdgyv1893gpmzl3"; - bins = { - holochain = "holochain"; - hc = "hc"; - kitsune-p2p-proxy = "kitsune_p2p/proxy"; - }; - - lairKeystoreHashes = { - sha256 = "1zq8mpxcy8p7kbj4xl4qhp2hb0fjxakixhzcb4y1rnygc90q9v01"; - cargoSha256 = "1ln0vx1blzjr4p9rqfhcl4b34blk6jiyziz2w5gh09wv2xbhyaa5"; - }; - }; - }; + holonix = import (holonixPath) { }; nixpkgs = holonix.pkgs; in nixpkgs.mkShell { inputsFrom = [ holonix.main ]; @@ -34,4 +11,4 @@ in nixpkgs.mkShell { binaryen nodejs-16_x ]; -} \ No newline at end of file +} diff --git a/package.json b/package.json index f7f1e821..05196e31 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@holochain/conductor-api": "github:holochain/holochain-conductor-api#update-to-113", + "@holochain/conductor-api": "^0.2.4", "@holochain/hachiko": "^0.5.2", "@iarna/toml": "^2.2.5", "@msgpack/msgpack": "^2.1.0", From dd1af7531221311284f0b733521293574479f698 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Thu, 11 Nov 2021 20:04:54 -0500 Subject: [PATCH 3/3] Bump version to 0.4.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05196e31..67dbd173 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/holochain/tryorama" }, - "version": "0.4.5", + "version": "0.4.6", "description": "test framework for holochain hApps", "main": "lib/index.js", "types": "lib/index.d.ts",