|
| 1 | + |
| 2 | +import { DnaSource, Record, ActionHash, EntryHash } from "@holochain/client"; |
| 3 | +import { pause, runScenario } from "@holochain/tryorama"; |
| 4 | +import { decode } from '@msgpack/msgpack'; |
| 5 | +import pkg from 'tape-promise/tape'; |
| 6 | +const { test } = pkg; |
| 7 | + |
| 8 | +import { sensemakerDnaDna } from "../../utils"; |
| 9 | + |
| 10 | + |
| 11 | +export default () => test("range CRUD tests", async (t) => { |
| 12 | + await runScenario(async scenario => { |
| 13 | + |
| 14 | + const dnas: DnaSource[] = [{ path: sensemakerDnaDna }]; |
| 15 | + |
| 16 | + const [alice, bob] = await scenario.addPlayersWithHapps([dnas, dnas]); |
| 17 | + |
| 18 | + await scenario.shareAllAgents(); |
| 19 | + |
| 20 | + |
| 21 | + const integerRange = { |
| 22 | + "name": "10-scale", |
| 23 | + "kind": { |
| 24 | + "Integer": { "min": 0, "max": 10 } |
| 25 | + }, |
| 26 | + }; |
| 27 | + |
| 28 | + const createDimension = { |
| 29 | + "name": "likeness", |
| 30 | + "range": integerRange, |
| 31 | + } |
| 32 | + |
| 33 | + // Alice creates a range |
| 34 | + const createEntryHash: EntryHash = await alice.cells[0].callZome({ |
| 35 | + zome_name: "sensemaker", |
| 36 | + fn_name: "create_dimension", |
| 37 | + payload: createDimension, |
| 38 | + }); |
| 39 | + t.ok(createEntryHash); |
| 40 | + |
| 41 | + // Wait for the created entry to be propagated to the other node. |
| 42 | + await pause(100); |
| 43 | + |
| 44 | + |
| 45 | + // Bob gets the created range |
| 46 | + const createReadOutput: Record = await bob.cells[0].callZome({ |
| 47 | + zome_name: "sensemaker", |
| 48 | + fn_name: "get_dimension", |
| 49 | + payload: createEntryHash, |
| 50 | + }); |
| 51 | + t.deepEqual(createDimension, decode((createReadOutput.entry as any).Present.entry) as any); |
| 52 | + }); |
| 53 | +}); |
0 commit comments