123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- ///<reference path="server/index.d.ts"/>
- import { expect, test } from "@playwright/test";
- const url = "http://localhost:8085";
- test.beforeEach(async ({ page }) => {
- await page.goto(url);
- await page.waitForFunction(() => window.setup != null);
- });
- test.describe("Share", () => {
- test("share and recieve share", async ({ page }) => {
- const result = await page.evaluate(async () => {
- const {
- wnfs: { PrivateForest, Name, NameAccumulator, share, createShareName, receiveShare },
- mock: {
- MemoryBlockStore,
- Rng,
- createSharerDir,
- createRecipientExchangeRoot,
- ExchangeKey,
- },
- } = await window.setup();
- // @ts-ignore
- globalThis.ExchangeKey = ExchangeKey;
- const rng = new Rng();
- var forest = new PrivateForest(rng);
- const sharerRootDid = "did:key:z6MkqZjY";
- const store = new MemoryBlockStore();
- var { rootDir: sharerDir, forest } = await createSharerDir(
- forest,
- store,
- rng
- );
- const [recipientKey, recipientExchRoot] =
- await createRecipientExchangeRoot(store);
- const recipientExchRootCid = await recipientExchRoot.store(store);
- var [accessKey, forest2] = await sharerDir
- .asNode()
- .store(forest, store, rng);
- var forest2 = await share(
- accessKey,
- 0,
- sharerRootDid,
- recipientExchRootCid,
- forest2,
- store
- );
- const modulus = await recipientKey.getPublicKey().getPublicKeyModulus();
- const shareLabel = createShareName(0, sharerRootDid, modulus, forest2);
- const shareLabelSerialized = shareLabel.toNameAccumulator(forest2).toBytes();
- const shareLabelDeserialized = new Name(NameAccumulator.fromBytes(shareLabelSerialized));
- const sharedNode = await receiveShare(
- shareLabelDeserialized,
- recipientKey,
- forest2,
- store
- );
- console.log("sharedNode", sharedNode);
- return sharedNode;
- });
- expect(result).toBeDefined();
- });
- });
|