From 48fbba0577a42df5b6f26e2607903e33394414e9 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 4 Oct 2022 15:28:36 -0700 Subject: [PATCH] chore: add test for structural copying (#206) * chore: add test for structural copying * fix: remove generated import * fix: lint errors * fix: another attempt to make eslint happy * chore: and another attemp to make eslint happy --- test/test-cid.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test-cid.spec.js b/test/test-cid.spec.js index 47754aa8..d203c17d 100644 --- a/test/test-cid.spec.js +++ b/test/test-cid.spec.js @@ -704,4 +704,14 @@ describe('CID', () => { assert.isFalse(Object.keys(cid).includes('asCID')) assert.equal(cid.asCID, cid) }) + + it('CID can be moved across JS realms', async () => { + const cid = CID.parse('bafybeif2pall7dybz7vecqka3zo24irdwabwdi4wc55jznaq75q7eaavvu') + const { port1: sender, port2: receiver } = new MessageChannel() + sender.postMessage(cid) + const cid2 = await new Promise((resolve) => { + receiver.onmessage = (event) => { resolve(event.data) } + }) + assert.equal(cid2.asCID, cid2) + }) })