From efae304de914f809c56dbda9d7c3aa294a6622a8 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 27 Feb 2024 13:42:29 +0530 Subject: [PATCH 1/4] Update bootstrap and signal URLs --- rust-executor/src/holochain_service/mod.rs | 8 +++----- tests/js/utils/utils.ts | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/rust-executor/src/holochain_service/mod.rs b/rust-executor/src/holochain_service/mod.rs index b11501b08..3540e4a8d 100644 --- a/rust-executor/src/holochain_service/mod.rs +++ b/rust-executor/src/holochain_service/mod.rs @@ -351,7 +351,7 @@ impl HolochainService { // staging - https://bootstrap-staging.holo.host // dev - https://bootstrap-dev.holohost.workers.dev // own - http://207.148.16.17:38245 - kitsune_config.bootstrap_service = Some(Url2::parse(String::from("https://bootstrap.holo.host/"))); + kitsune_config.bootstrap_service = Some(Url2::parse(local_config.bootstrap_url)); } else { kitsune_config.bootstrap_service = None; } @@ -365,7 +365,7 @@ impl HolochainService { // prod - wss://signal.holo.host // dev - wss://signal.holotest.net // our - ws://207.148.16.17:42697 - signal_url: String::from("wss://signal.holo.host"), + signal_url: local_config.proxy_url, }]; } else { kitsune_config.transport_pool = vec![ @@ -377,8 +377,6 @@ impl HolochainService { } config.network = kitsune_config; - println!("wow 1 {:?}", config); - config }; @@ -598,7 +596,7 @@ impl HolochainService { let stats = self.conductor.dump_network_stats().await?; info!("Network stats: {}", stats); - + Ok(()) } diff --git a/tests/js/utils/utils.ts b/tests/js/utils/utils.ts index b78162d69..e83925a49 100644 --- a/tests/js/utils/utils.ts +++ b/tests/js/utils/utils.ts @@ -22,7 +22,7 @@ export async function isProcessRunning(processName: string): Promise { })() if (!cmd) throw new Error("Invalid OS"); - + return new Promise((resolve, reject) => { //@ts-ignore exec(cmd, (err: ExecException, stdout: string, stderr: string) => { @@ -30,7 +30,7 @@ export async function isProcessRunning(processName: string): Promise { resolve(stdout.toLowerCase().indexOf(processName.toLowerCase()) > -1) }) - }) + }) } export async function runHcLocalServices(): Promise<{proxyUrl: string | null, bootstrapUrl: string | null, process: ChildProcess}> { @@ -61,8 +61,8 @@ export async function runHcLocalServices(): Promise<{proxyUrl: string | null, bo return {proxyUrl, bootstrapUrl, process: servicesProcess}; } -export async function startExecutor(dataPath: string, - bootstrapSeedPath: string, +export async function startExecutor(dataPath: string, + bootstrapSeedPath: string, gqlPort: number, hcAdminPort: number, hcAppPort: number, @@ -78,15 +78,15 @@ export async function startExecutor(dataPath: string, let executorProcess = null as ChildProcess | null; rmSync(dataPath, { recursive: true, force: true }) execSync(`${command} init --data-path ${dataPath} --network-bootstrap-seed ${bootstrapSeedPath}`, {cwd: process.cwd()}) - + console.log("Starting executor") console.log("USING LOCAL BOOTSTRAP & PROXY URL: ", bootstrapUrl, proxyUrl); - + if (!adminCredential) { - executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap false --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --run-dapp-server false`, {}) + executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap true --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --run-dapp-server false`, {}) } else { - executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap false --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --admin-credential ${adminCredential} --run-dapp-server false`, {}) + executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap true --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --admin-credential ${adminCredential} --run-dapp-server false`, {}) } let executorReady = new Promise((resolve, reject) => { executorProcess!.stdout!.on('data', (data) => { @@ -98,7 +98,7 @@ export async function startExecutor(dataPath: string, if (data.includes(`listening on http://127.0.0.1:${gqlPort}`)) { resolve() } - }); + }); }) executorProcess!.stdout!.on('data', (data) => { @@ -109,7 +109,7 @@ export async function startExecutor(dataPath: string, }); console.log("Waiting for executor to settle...") - await executorReady + await executorReady return executorProcess; } @@ -149,7 +149,7 @@ export function apolloClient(port: number, token?: string): ApolloClient { } }, }); - + return client; } From 24e8c56a14865d513e762c5bc3eed5abf987222b Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 27 Feb 2024 13:42:43 +0530 Subject: [PATCH 2/4] Update function name for receiving remote signal --- .../hc-dna/zomes/direct-message/src/lib.rs | 4 ++-- .../hc-dna/zomes/perspective_diff_sync/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bootstrap-languages/direct-message-language/hc-dna/zomes/direct-message/src/lib.rs b/bootstrap-languages/direct-message-language/hc-dna/zomes/direct-message/src/lib.rs index fc1d08731..1adc742c4 100644 --- a/bootstrap-languages/direct-message-language/hc-dna/zomes/direct-message/src/lib.rs +++ b/bootstrap-languages/direct-message-language/hc-dna/zomes/direct-message/src/lib.rs @@ -13,7 +13,7 @@ fn init(_: ()) -> ExternResult { let mut functions = BTreeSet::new(); functions.insert(( ZomeName::from("direct-message"), - "recv_send_remote_signal".into(), + "recv_remote_signal".into(), )); functions.insert((ZomeName::from("direct-message"), "get_status".into())); let granted_functions: GrantedFunctions = GrantedFunctions::Listed(functions); @@ -117,7 +117,7 @@ pub fn get_status(_: ()) -> ExternResult> { //--------------------------------------------------------- #[hdk_extern] -fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> { +fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> { debug!("RECEIVEING MESSAGE..."); match PerspectiveExpression::try_from(signal) { Ok(message) => { diff --git a/bootstrap-languages/p-diff-sync-socket-signaling/hc-dna/zomes/perspective_diff_sync/src/lib.rs b/bootstrap-languages/p-diff-sync-socket-signaling/hc-dna/zomes/perspective_diff_sync/src/lib.rs index fe976f030..e837a592b 100644 --- a/bootstrap-languages/p-diff-sync-socket-signaling/hc-dna/zomes/perspective_diff_sync/src/lib.rs +++ b/bootstrap-languages/p-diff-sync-socket-signaling/hc-dna/zomes/perspective_diff_sync/src/lib.rs @@ -27,7 +27,7 @@ fn init(_: ()) -> ExternResult { let mut functions = BTreeSet::new(); functions.insert((zome_info()?.name, "get_online_status".into())); //TODO; is this next function needed? - functions.insert((zome_info()?.name, "recv_send_remote_signal".into())); + functions.insert((zome_info()?.name, "recv_remote_signal".into())); let functions: GrantedFunctions = GrantedFunctions::Listed(functions); @@ -97,7 +97,7 @@ pub fn update_current_revision(_hash: Hash) -> ExternResult<()> { /// Signal handling #[hdk_extern] -fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> { +fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> { //Check if its a normal diff expression signal match HashBroadcast::try_from(signal.clone()) { Ok(broadcast) => { From c1d3d939cf699cedc8110b698c9dc3ad2ea8f903 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 27 Feb 2024 13:42:55 +0530 Subject: [PATCH 3/4] Fix test cases and remove skip --- tests/js/tests/agent-language.ts | 6 +++--- tests/js/tests/direct-messages.ts | 14 +++++++------- tests/js/tests/neighbourhood.ts | 30 +++++++++++++++--------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/js/tests/agent-language.ts b/tests/js/tests/agent-language.ts index 516d10ac4..28f9bad2a 100644 --- a/tests/js/tests/agent-language.ts +++ b/tests/js/tests/agent-language.ts @@ -4,10 +4,10 @@ import { expect } from "chai"; export default function agentLanguageTests(testContext: TestContext) { return () => { - it.skip("works across remote agents", async () => { + it("works across remote agents", async () => { const alice = testContext.alice! const didAlice = (await alice.agent.status()).did! - const bob = testContext.bob! + const bob = testContext.bob! const didBob = (await bob.agent.status()).did! const aliceHerself = await alice.agent.me() @@ -22,6 +22,6 @@ export default function agentLanguageTests(testContext: TestContext) { const aliceSeenFromBob = await bob.agent.byDID(didAlice) expect(aliceSeenFromBob).not.to.be.undefined expect(aliceSeenFromBob).to.be.eql(aliceHerself) - }) + }) } } \ No newline at end of file diff --git a/tests/js/tests/direct-messages.ts b/tests/js/tests/direct-messages.ts index f7acf5dae..58d737e6a 100644 --- a/tests/js/tests/direct-messages.ts +++ b/tests/js/tests/direct-messages.ts @@ -10,7 +10,7 @@ export default function directMessageTests(testContext: TestContext) { link.author = "did:test"; link.timestamp = new Date().toISOString(); link.data = new Link({ - source: Literal.from("me").toUrl(), + source: Literal.from("me").toUrl(), predicate: Literal.from("thinks").toUrl(), target: Literal.from("nothing").toUrl() }); @@ -28,11 +28,11 @@ export default function directMessageTests(testContext: TestContext) { }catch(e) { hasThrown = true } - + expect(hasThrown).to.be.true; - }) + }) - describe.skip("with Alice and Bob being friends", () => { + describe("with Alice and Bob being friends", () => { //@ts-ignore let alice, bob, didAlice, didBob @@ -52,7 +52,7 @@ export default function directMessageTests(testContext: TestContext) { link.timestamp = new Date().toISOString(); link.data = new Link({ //@ts-ignore - source: didBob, + source: didBob, predicate: Literal.from("is").toUrl(), target: Literal.from("online").toUrl() }); @@ -60,7 +60,7 @@ export default function directMessageTests(testContext: TestContext) { const statusBob = new Perspective([link]) //@ts-ignore await bob.runtime.setStatus(statusBob) - await sleep(1000) + await sleep(1000) //@ts-ignore const statusAlice = await alice.runtime.friendStatus(didBob) expect(statusAlice).not.to.be.undefined; @@ -91,7 +91,7 @@ export default function directMessageTests(testContext: TestContext) { expect((await bob.runtime.messageInbox(didAlice)).length).to.be.equal(1) //@ts-ignore expect((await bob.runtime.messageInbox("did:test:other")).length).to.be.equal(0) - + }) it("Alice finds her sent message in the outbox", async () => { diff --git a/tests/js/tests/neighbourhood.ts b/tests/js/tests/neighbourhood.ts index 8be8725ab..e9d4e17eb 100644 --- a/tests/js/tests/neighbourhood.ts +++ b/tests/js/tests/neighbourhood.ts @@ -11,7 +11,7 @@ let bobP1: null | PerspectiveHandle = null; export default function neighbourhoodTests(testContext: TestContext) { return () => { - describe.skip('Neighbourhood', () => { + describe('Neighbourhood', () => { it('can publish and join locally @alice', async () => { const ad4mClient = testContext.alice!; @@ -29,7 +29,7 @@ export default function neighbourhoodTests(testContext: TestContext) { link.timestamp = new Date().toISOString(); link.data = new Link({source: "src", target: "target", predicate: "pred"}); link.proof = new ExpressionProof("sig", "key"); - const publishPerspective = await ad4mClient.neighbourhood.publishFromPerspective(create.uuid, socialContext.address, + const publishPerspective = await ad4mClient.neighbourhood.publishFromPerspective(create.uuid, socialContext.address, new Perspective( [link] ) @@ -53,19 +53,19 @@ export default function neighbourhoodTests(testContext: TestContext) { const socialContext = await alice.languages.applyTemplateAndPublish(DIFF_SYNC_OFFICIAL, JSON.stringify({uid: uuidv4(), name: "Alice's neighbourhood with Bob"})); expect(socialContext.name).to.be.equal("Alice's neighbourhood with Bob"); const neighbourhoodUrl = await alice.neighbourhood.publishFromPerspective(aliceP1.uuid, socialContext.address, new Perspective()) - + let bobP1 = await bob.neighbourhood.joinFromUrl(neighbourhoodUrl); - + await testContext.makeAllNodesKnown() - + expect(bobP1!.name).not.to.be.undefined; expect(bobP1!.sharedUrl).to.be.equal(neighbourhoodUrl) expect(bobP1!.neighbourhood).not.to.be.undefined;; expect(bobP1!.neighbourhood!.data.linkLanguage).to.be.equal(socialContext.address); expect(bobP1!.neighbourhood!.data.meta.links.length).to.be.equal(0); }) - - it.skip('shared link created by Alice received by Bob', async () => { + + it('shared link created by Alice received by Bob', async () => { const alice = testContext.alice const bob = testContext.bob @@ -93,7 +93,7 @@ export default function neighbourhoodTests(testContext: TestContext) { bobLinks = await bob.perspective.queryLinks(bobP1!.uuid, new LinkQuery({source: 'root'})) tries++ } - + expect(bobLinks.length).to.be.equal(1) expect(bobLinks[0].data.target).to.be.equal('test://test') expect(bobLinks[0].proof.valid).to.be.true; @@ -127,7 +127,7 @@ export default function neighbourhoodTests(testContext: TestContext) { bobLinks = await bob.perspective.queryLinks(bobP1!.uuid, new LinkQuery({source: 'root'})) tries++ } - + expect(bobLinks.length).to.be.equal(0) }) @@ -143,7 +143,7 @@ export default function neighbourhoodTests(testContext: TestContext) { const perspectives = await alice.perspective.all(); }) - + // it('can get the correct state change signals', async () => { // const aliceP1 = await testContext.alice.perspective.add("state-changes") // expect(aliceP1.state).to.be.equal(PerspectiveState.Private); @@ -221,7 +221,7 @@ export default function neighbourhoodTests(testContext: TestContext) { const bobP1Handle = await bob.neighbourhood.joinFromUrl(neighbourhoodUrl); const bobP1 = await bob.perspective.byUUID(bobP1Handle.uuid) await testContext.makeAllNodesKnown() - + aliceNH = aliceP1.getNeighbourhoodProxy() bobNH = bobP1!.getNeighbourhoodProxy() aliceDID = (await alice.agent.me()).did @@ -259,7 +259,7 @@ export default function neighbourhoodTests(testContext: TestContext) { expect(aliceOnline[0].did).to.be.equal(bobDID) console.log(aliceOnline[0].status); expect(aliceOnline[0].status.data.links).to.deep.equal(testPerspective.links) - + expect(bobOnline.length).to.be.equal(1) expect(bobOnline[0].did).to.be.equal(aliceDID) expect(bobOnline[0].status.data.links).to.deep.equal(testPerspective.links) @@ -267,7 +267,7 @@ export default function neighbourhoodTests(testContext: TestContext) { await aliceNH!.setOnlineStatusU(PerspectiveUnsignedInput.fromLink(new Link({ source: "test://source", - target: "test://target" + target: "test://target" }))) const bobOnline2 = await bobNH!.onlineAgents() @@ -280,7 +280,7 @@ export default function neighbourhoodTests(testContext: TestContext) { // TODO: Signature check for the whole perspective is broken // Got to fix that and add back this assertion //expect(bobOnline2[0].status.proof.valid).to.be.true - + }) it('they can send signals via `sendSignal` and receive callbacks via `addSignalHandler`', async () => { @@ -321,7 +321,7 @@ export default function neighbourhoodTests(testContext: TestContext) { //@ts-ignore expect(bobData.data.links).to.deep.equal(aliceSignal.links) - + let link2 = new Link({source: "bob", target: "alice", predicate: "signal"}); const bobSignal = new PerspectiveUnsignedInput([link2]) From 76da9d4cc2701f70b879e669c7857f72fef98474 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 27 Feb 2024 16:17:23 +0530 Subject: [PATCH 4/4] Fix makeAllNodesKnown function call --- tests/js/tests/integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/js/tests/integration.test.ts b/tests/js/tests/integration.test.ts index 9fa4ed8ff..b521b2314 100644 --- a/tests/js/tests/integration.test.ts +++ b/tests/js/tests/integration.test.ts @@ -167,7 +167,7 @@ describe("Integration tests", function () { await testContext.bob.agent.updatePublicPerspective(new Perspective([link])) - //await testContext.makeAllNodesKnown() + await testContext.makeAllNodesKnown() }) after(async () => {