Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 13, 2023
1 parent cf72941 commit 5eabfae
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert, test } from "vitest";

import { runScenario, dhtSync } from '@holochain/tryorama';
import { ActionHash, Record } from '@holochain/client';
import { ActionHash, Record, EntryHash } from '@holochain/client';
import { decode } from '@msgpack/msgpack';
import { EntryRecord } from '@holochain-open-dev/utils';
import { toPromise } from '@holochain-open-dev/stores';
Expand All @@ -15,11 +15,11 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
const { alice, bob } = await setup(scenario);

// Bob gets {{lower_case collection_name}}
let collectionOutput: ActionHash[] = await toPromise(bob.store.{{camel_case collection_name}});
let collectionOutput: {{#if (eq referenceable.hash_type "ActionHash")}}ActionHash{{else}}EntryHash{{/if}}[] = await toPromise(bob.store.{{camel_case collection_name}}{{#if (eq collection_type.type "Global")}}.get(alice.player.agentPubKey{{/if}});
assert.equal(collectionOutput.length, 0);

// Alice creates a {{pascal_case referenceable.name}}
const {{camel_case referenceable.name}}: EntryRecord<{{pascal_case referenceable.name}}> = await bob.store.client.create{{pascal_case referenceable.name}}(sample{{pascal_case referenceable.name}}());
const {{camel_case referenceable.name}}: EntryRecord<{{pascal_case referenceable.name}}> = await alice.store.client.create{{pascal_case referenceable.name}}(await sample{{pascal_case referenceable.name}}(alice.store.client));
assert.ok({{camel_case referenceable.name}});

await dhtSync(
Expand All @@ -28,9 +28,9 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
);

// Bob gets {{lower_case collection_name}} again
collectionOutput = await toPromise(bob.store.{{camel_case collection_name}});
collectionOutput = await toPromise(bob.store.{{camel_case collection_name}}{{#if (eq collection_type.type "Global")}}.get(alice.player.agentPubKey{{/if}});
assert.equal(collectionOutput.length, 1);
assert.deepEqual({{camel_case referenceable.name}}.actionHash, collectionOutput[0]);
assert.deepEqual({{camel_case referenceable.name}}.{{#if (eq referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, collectionOutput[0]);
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer
linksOutput = await toPromise(bob.store.{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress));
assert.equal(linksOutput.length, 1);
{{#if (ne from_referenceable.hash_type "AgentPubKey")}}
assert.deepEqual(baseRecord.{{#if (eq to_referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, linksOutput[0]);
assert.deepEqual(baseRecord.{{#if (eq from_referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, linksOutput[0]);
{{/if}}
{{/if}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert, test } from "vitest";

import { runScenario, dhtSync } from '@holochain/tryorama';
import { ActionHash, Record } from '@holochain/client';
import { ActionHash, Record, EntryHash } from '@holochain/client';
import { decode } from '@msgpack/msgpack';
import { EntryRecord } from '@holochain-open-dev/utils';
import { toPromise } from '@holochain-open-dev/stores';
Expand All @@ -15,11 +15,11 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
const { alice, bob } = await setup(scenario);

// Bob gets {{lower_case collection_name}}
let collectionOutput: ActionHash[] = await toPromise(bob.store.{{camel_case collection_name}});
let collectionOutput: {{#if (eq referenceable.hash_type "ActionHash")}}ActionHash{{else}}EntryHash{{/if}}[] = await toPromise(bob.store.{{camel_case collection_name}}{{#if (eq collection_type.type "Global")}}.get(alice.player.agentPubKey{{/if}});
assert.equal(collectionOutput.length, 0);

// Alice creates a {{pascal_case referenceable.name}}
const {{camel_case referenceable.name}}: EntryRecord<{{pascal_case referenceable.name}}> = await bob.store.client.create{{pascal_case referenceable.name}}(await sample{{pascal_case referenceable.name}}(alice.store.client));
const {{camel_case referenceable.name}}: EntryRecord<{{pascal_case referenceable.name}}> = await alice.store.client.create{{pascal_case referenceable.name}}(await sample{{pascal_case referenceable.name}}(alice.store.client));
assert.ok({{camel_case referenceable.name}});

await dhtSync(
Expand All @@ -28,9 +28,9 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
);

// Bob gets {{lower_case collection_name}} again
collectionOutput = await toPromise(bob.store.{{camel_case collection_name}});
collectionOutput = await toPromise(bob.store.{{camel_case collection_name}}{{#if (eq collection_type.type "Global")}}.get(alice.player.agentPubKey{{/if}});
assert.equal(collectionOutput.length, 1);
assert.deepEqual({{camel_case referenceable.name}}.actionHash, collectionOutput[0]);
assert.deepEqual({{camel_case referenceable.name}}.{{#if (eq referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, collectionOutput[0]);
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer
linksOutput = await toPromise(bob.store.{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress));
assert.equal(linksOutput.length, 1);
{{#if (ne from_referenceable.hash_type "AgentPubKey")}}
assert.deepEqual(baseRecord.{{#if (eq to_referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, linksOutput[0]);
assert.deepEqual(baseRecord.{{#if (eq from_referenceable.hash_type "ActionHash")}}actionHash{{else}}entryHash{{/if}}, linksOutput[0]);
{{/if}}
{{/if}}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ There are two templates available:
1b. If you already have an existing project, run this inside a `nix develop` shell:

`hc scaffold template get https://github.com/holochain-open-dev/templates`

WARNING! If you use the app template, you will encounter [this issue](https://github.com/holochain/scaffolding/issues/135). The quick fix is to upgrade the version of `holochain_integrity_types` in the workspace's Cargo.toml.
2 changes: 2 additions & 0 deletions run_test_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ hc-scaffold link-type agent:creator post:EntryHash --delete false --bidirecciona
hc-scaffold zome profiles --coordinator dnas/forum/zomes/coordinator --integrity dnas/forum/zomes/integrity
hc-scaffold zome file_storage --coordinator dnas/forum/zomes/coordinator --integrity dnas/forum/zomes/integrity
sed -i \"s/holochain_integrity_types = \\\"=0.1.2\\\"/holochain_integrity_types = \\\"=0.2.2\\\"/g\" Cargo.toml
cargo clean
cargo add -p profiles hc_zome_profiles_coordinator
echo \"extern crate hc_zome_profiles_coordinator;\" > dnas/forum/zomes/coordinator/profiles/src/lib.rs
Expand Down

0 comments on commit 5eabfae

Please sign in to comment.