Skip to content

Commit e9f887d

Browse files
committed
fix: tryorama tests
1 parent 898518d commit e9f887d

12 files changed

+206
-242
lines changed

tests/src/common.ts

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,21 @@
11
import { fileURLToPath } from "url";
22
import path from "path";
3-
import {
4-
AppBundle,
5-
AppBundleSource,
6-
CellProvisioningStrategy,
7-
} from "@holochain/client";
3+
import { AppBundleSource } from "@holochain/client";
4+
85
const __filename = fileURLToPath(import.meta.url);
96
const __dirname = path.dirname(__filename);
107

11-
const createMewsFeedAppBundleSource = (
12-
properties: any = {}
13-
): AppBundleSource => {
14-
return {
15-
bundle: {
16-
manifest: {
17-
manifest_version: "1",
18-
name: "mewsfeed",
19-
roles: [
20-
{
21-
name: "mewsfeed",
22-
provisioning: {
23-
strategy: CellProvisioningStrategy.Create,
24-
deferred: false,
25-
},
26-
dna: {
27-
path: path.join(
28-
__dirname,
29-
"../../dnas/mewsfeed/workdir/mewsfeed.dna"
30-
),
31-
modifiers: {
32-
properties,
33-
},
34-
},
35-
},
36-
],
37-
},
38-
resources: {},
39-
},
40-
};
8+
export const mewsfeedAppBundleSource: AppBundleSource = {
9+
type: "path",
10+
value: path.join(__dirname, "../../workdir/mewsfeed.happ"),
4111
};
4212

43-
export const mewsfeedAppBundleSource: AppBundleSource =
44-
createMewsFeedAppBundleSource({
45-
mew_characters_min: 5,
46-
mew_characters_max: 200,
47-
prefix_index_width: 3,
48-
});
13+
export const mewsfeedAppBundleSourceNoLengthLimits: AppBundleSource = {
14+
type: "path",
15+
value: path.join(__dirname, "../../workdir/mewsfeed.happ"),
16+
};
4917

50-
export const mewsfeedAppBundleSourceNoLengthLimits: AppBundleSource =
51-
createMewsFeedAppBundleSource();
18+
// Helper to wrap inputs in ZomeFnInput format for the new API
19+
export function wrapInput<T>(input: T, local: boolean = true): { input: T; local: boolean } {
20+
return { input, local };
21+
}

tests/src/mewsfeed/agent_pins/pinner-to-hashes.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import { assert, test } from "vitest";
22

33
import { runScenario, dhtSync } from "@holochain/tryorama";
44
import { AgentPubKey, HoloHash, fakeActionHash } from "@holochain/client";
5+
import { mewsfeedAppBundleSource, wrapInput } from "../../common";
56

67
test("link a Pinner to a Hash", async () => {
78
await runScenario(
89
async (scenario) => {
9-
// Construct proper paths for your app.
10-
// This assumes app bundle created by the `hc app pack` command.
11-
const testAppPath = process.cwd() + "/../workdir/mewsfeed.happ";
12-
1310
// Set up the app to be installed
14-
const appSource = { appBundleSource: { path: testAppPath } };
11+
const appSource = { appBundleSource: mewsfeedAppBundleSource };
1512

1613
// Add 2 players with the test app to the Scenario. The returned players
1714
// can be destructured.
@@ -27,7 +24,7 @@ test("link a Pinner to a Hash", async () => {
2724
let linksOutput: HoloHash[] = await bob.cells[0].callZome({
2825
zome_name: "agent_pins",
2926
fn_name: "get_hashes_for_pinner",
30-
payload: baseAddress,
27+
payload: wrapInput(baseAddress),
3128
});
3229
assert.equal(linksOutput.length, 0);
3330

@@ -44,7 +41,7 @@ test("link a Pinner to a Hash", async () => {
4441
linksOutput = await bob.cells[0].callZome({
4542
zome_name: "agent_pins",
4643
fn_name: "get_hashes_for_pinner",
47-
payload: baseAddress,
44+
payload: wrapInput(baseAddress),
4845
});
4946

5047
assert.equal(linksOutput.length, 1);
@@ -53,7 +50,7 @@ test("link a Pinner to a Hash", async () => {
5350
const pinnersOutput: AgentPubKey[] = await bob.cells[0].callZome({
5451
zome_name: "agent_pins",
5552
fn_name: "get_pinners_for_hash",
56-
payload: targetHash,
53+
payload: wrapInput(targetHash),
5754
});
5855
assert.equal(pinnersOutput.length, 1);
5956

@@ -69,15 +66,15 @@ test("link a Pinner to a Hash", async () => {
6966
linksOutput = await bob.cells[0].callZome({
7067
zome_name: "agent_pins",
7168
fn_name: "get_hashes_for_pinner",
72-
payload: baseAddress,
69+
payload: wrapInput(baseAddress),
7370
});
7471
assert.equal(linksOutput.length, 0);
7572

7673
// Bob gets the links in the inverse direction
7774
linksOutput = await bob.cells[0].callZome({
7875
zome_name: "agent_pins",
7976
fn_name: "get_pinners_for_hash",
80-
payload: targetHash,
77+
payload: wrapInput(targetHash),
8178
});
8279

8380
assert.equal(linksOutput.length, 0);

tests/src/mewsfeed/follows/follower-to-creators.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert, test, expect } from "vitest";
22
import { runScenario, dhtSync } from "@holochain/tryorama";
33
import { AgentPubKey, Record } from "@holochain/client";
4-
import { mewsfeedAppBundleSource } from "../../common";
4+
import { mewsfeedAppBundleSource, wrapInput } from "../../common";
55

66
test("link a Follower to a Creator", async () => {
77
await runScenario(
@@ -23,9 +23,9 @@ test("link a Follower to a Creator", async () => {
2323
let linksOutput: Record[] = await bob.cells[0].callZome({
2424
zome_name: "follows",
2525
fn_name: "get_creators_for_follower",
26-
payload: {
26+
payload: wrapInput({
2727
follower: baseAddress,
28-
},
28+
}),
2929
});
3030
assert.equal(linksOutput.length, 0);
3131

@@ -45,19 +45,19 @@ test("link a Follower to a Creator", async () => {
4545
linksOutput = await bob.cells[0].callZome({
4646
zome_name: "follows",
4747
fn_name: "get_creators_for_follower",
48-
payload: {
48+
payload: wrapInput({
4949
follower: baseAddress,
50-
},
50+
}),
5151
});
5252
assert.equal(linksOutput.length, 1);
5353

5454
// Bob gets the links in the inverse direction
5555
linksOutput = await bob.cells[0].callZome({
5656
zome_name: "follows",
5757
fn_name: "get_followers_for_creator",
58-
payload: {
58+
payload: wrapInput({
5959
creator: targetAddress,
60-
},
60+
}),
6161
});
6262
assert.equal(linksOutput.length, 1);
6363

@@ -76,19 +76,19 @@ test("link a Follower to a Creator", async () => {
7676
linksOutput = await bob.cells[0].callZome({
7777
zome_name: "follows",
7878
fn_name: "get_creators_for_follower",
79-
payload: {
79+
payload: wrapInput({
8080
follower: baseAddress,
81-
},
81+
}),
8282
});
8383
assert.equal(linksOutput.length, 0);
8484

8585
// Bob gets the links in the inverse direction
8686
linksOutput = await bob.cells[0].callZome({
8787
zome_name: "follows",
8888
fn_name: "get_followers_for_creator",
89-
payload: {
89+
payload: wrapInput({
9090
creator: targetAddress,
91-
},
91+
}),
9292
});
9393
assert.equal(linksOutput.length, 0);
9494
},
@@ -257,12 +257,12 @@ test(
257257
const page1: AgentPubKey[] = await alice.cells[0].callZome({
258258
zome_name: "follows",
259259
fn_name: "get_creators_for_follower",
260-
payload: {
260+
payload: wrapInput({
261261
follower: alice.agentPubKey,
262262
page: {
263263
limit: 2,
264264
},
265-
},
265+
}),
266266
});
267267

268268
assert.deepEqual(page1[0], mary.agentPubKey);
@@ -271,41 +271,41 @@ test(
271271
const page2: AgentPubKey[] = await alice.cells[0].callZome({
272272
zome_name: "follows",
273273
fn_name: "get_creators_for_follower",
274-
payload: {
274+
payload: wrapInput({
275275
follower: alice.agentPubKey,
276276
page: {
277277
after_agentpubkey: page1[1],
278278
limit: 2,
279279
},
280-
},
280+
}),
281281
});
282282
assert.deepEqual(page2[0], john.agentPubKey);
283283
assert.deepEqual(page2[1], carol.agentPubKey);
284284

285285
const page3: AgentPubKey[] = await alice.cells[0].callZome({
286286
zome_name: "follows",
287287
fn_name: "get_creators_for_follower",
288-
payload: {
288+
payload: wrapInput({
289289
follower: alice.agentPubKey,
290290
page: {
291291
after_agentpubkey: page2[1],
292292
limit: 2,
293293
},
294-
},
294+
}),
295295
});
296296
assert.lengthOf(page3, 1);
297297
assert.deepEqual(page3[0], bob.agentPubKey);
298298

299299
const page5: AgentPubKey[] = await alice.cells[0].callZome({
300300
zome_name: "follows",
301301
fn_name: "get_creators_for_follower",
302-
payload: {
302+
payload: wrapInput({
303303
follower: alice.agentPubKey,
304304
page: {
305305
after_agentpubkey: page3[0],
306306
limit: 2,
307307
},
308-
},
308+
}),
309309
});
310310
assert.lengthOf(page5, 0);
311311
},
@@ -386,12 +386,12 @@ test(
386386
const page1: AgentPubKey[] = await alice.cells[0].callZome({
387387
zome_name: "follows",
388388
fn_name: "get_followers_for_creator",
389-
payload: {
389+
payload: wrapInput({
390390
creator: alice.agentPubKey,
391391
page: {
392392
limit: 2,
393393
},
394-
},
394+
}),
395395
});
396396

397397
assert.deepEqual(page1[0], mary.agentPubKey);
@@ -400,41 +400,41 @@ test(
400400
const page2: AgentPubKey[] = await alice.cells[0].callZome({
401401
zome_name: "follows",
402402
fn_name: "get_followers_for_creator",
403-
payload: {
403+
payload: wrapInput({
404404
creator: alice.agentPubKey,
405405
page: {
406406
after_agentpubkey: page1[1],
407407
limit: 2,
408408
},
409-
},
409+
}),
410410
});
411411
assert.deepEqual(page2[0], john.agentPubKey);
412412
assert.deepEqual(page2[1], carol.agentPubKey);
413413

414414
const page3: AgentPubKey[] = await alice.cells[0].callZome({
415415
zome_name: "follows",
416416
fn_name: "get_followers_for_creator",
417-
payload: {
417+
payload: wrapInput({
418418
creator: alice.agentPubKey,
419419
page: {
420420
after_agentpubkey: page2[1],
421421
limit: 2,
422422
},
423-
},
423+
}),
424424
});
425425
assert.lengthOf(page3, 1);
426426
assert.deepEqual(page3[0], bob.agentPubKey);
427427

428428
const page5: AgentPubKey[] = await alice.cells[0].callZome({
429429
zome_name: "follows",
430430
fn_name: "get_followers_for_creator",
431-
payload: {
431+
payload: wrapInput({
432432
creator: alice.agentPubKey,
433433
page: {
434434
after_agentpubkey: page3[0],
435435
limit: 2,
436436
},
437-
},
437+
}),
438438
});
439439
assert.lengthOf(page5, 0);
440440
},

tests/src/mewsfeed/likes/liker-to-hashes.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert, expect, test } from "vitest";
22
import { runScenario, dhtSync } from "@holochain/tryorama";
33
import { Record, fakeActionHash } from "@holochain/client";
4-
import { mewsfeedAppBundleSource } from "../../common";
4+
import { mewsfeedAppBundleSource, wrapInput } from "../../common";
55

66
test("link a Liker to a Hash", async () => {
77
await runScenario(
@@ -23,7 +23,7 @@ test("link a Liker to a Hash", async () => {
2323
let linksOutput: Record[] = await bob.cells[0].callZome({
2424
zome_name: "likes",
2525
fn_name: "get_hashes_for_liker",
26-
payload: baseAddress,
26+
payload: wrapInput(baseAddress),
2727
});
2828
assert.equal(linksOutput.length, 0);
2929

@@ -43,15 +43,15 @@ test("link a Liker to a Hash", async () => {
4343
linksOutput = await bob.cells[0].callZome({
4444
zome_name: "likes",
4545
fn_name: "get_hashes_for_liker",
46-
payload: baseAddress,
46+
payload: wrapInput(baseAddress),
4747
});
4848
assert.equal(linksOutput.length, 1);
4949

5050
// Bob gets the links in the inverse direction
5151
linksOutput = await bob.cells[0].callZome({
5252
zome_name: "likes",
5353
fn_name: "get_likers_for_hash",
54-
payload: targetAddress,
54+
payload: wrapInput(targetAddress),
5555
});
5656
assert.equal(linksOutput.length, 1);
5757

@@ -70,15 +70,15 @@ test("link a Liker to a Hash", async () => {
7070
linksOutput = await bob.cells[0].callZome({
7171
zome_name: "likes",
7272
fn_name: "get_hashes_for_liker",
73-
payload: baseAddress,
73+
payload: wrapInput(baseAddress),
7474
});
7575
assert.equal(linksOutput.length, 0);
7676

7777
// Bob gets the links in the inverse direction
7878
linksOutput = await bob.cells[0].callZome({
7979
zome_name: "likes",
8080
fn_name: "get_likers_for_hash",
81-
payload: targetAddress,
81+
payload: wrapInput(targetAddress),
8282
});
8383
assert.equal(linksOutput.length, 0);
8484
},

0 commit comments

Comments
 (0)