Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Wasm README.md example Add Wasm examples CI job. Update build-and-test CI to run wasm_bindgen annotated tests. * Add txm annotations to test Wasm README.md example Add txm to examples CI job. * Fix Wasm node and README.md examples tests The examples will now throw error codes on unsuccessful termination. * Enable wasm examples CI job on PR temporarily * Add configurable branch/ref for example CI * Disable examples CI job on pull requests * Rename Wasm Examples CI job * Switch to jest for testing node bindings examples * Add wasm browser example tests with cypress Fix broken browser examples, doc strings. Update example CI job with browser tests. Temporarily enable examples CI job on PR for testing. * Disable examples CI on PR Update yarn.lock to include cypress * improve node tests reliability * improve browser test reliability Co-authored-by: Abdulrahim Al Methiab <abdulrahim.almethiab@iota.org>
- Loading branch information
Showing
32 changed files
with
3,064 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Wasm Examples | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # run at midnight every day | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: "Branch/ref (default dev branch)" | ||
required: true | ||
default: 'dev' # checkout dev branch by default, not main | ||
|
||
jobs: | ||
build-and-test-examples: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
|
||
- name: Install stable toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15.x | ||
|
||
- name: Install txm # for running README.md examples https://github.com/anko/txm | ||
run: yarn global add txm | ||
|
||
- name: Install wasm-pack | ||
run: yarn global add wasm-pack | ||
|
||
- name: Install JS dependencies | ||
run: yarn | ||
working-directory: bindings/wasm | ||
|
||
- name: Build Wasm bindings | ||
run: yarn build | ||
working-directory: bindings/wasm | ||
|
||
- name: Test Wasm examples (node) | ||
run: yarn run test:node | ||
working-directory: bindings/wasm | ||
|
||
- name: Test Wasm examples (browser) | ||
run: yarn run test:browser | ||
working-directory: bindings/wasm | ||
|
||
- name: Test Wasm README.md examples | ||
run: yarn run test:readme | ||
working-directory: bindings/wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
/target | ||
# Rust | ||
target/ | ||
Cargo.lock | ||
|
||
node_modules | ||
wasm-web | ||
wasm-node | ||
web | ||
node | ||
pkg | ||
# npm / yarn | ||
node_modules/ | ||
|
||
# Build artifacts | ||
wasm-web/ | ||
wasm-node/ | ||
web/ | ||
node/ | ||
pkg/ | ||
|
||
# cypress | ||
cypress/screenshots/ | ||
cypress/videos/ | ||
|
||
.DS_STORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"screenshotOnRunFailure": false, | ||
"video": false | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { defaultClientConfig, initIdentity } from "../../examples/browser/utils"; | ||
import { createIdentity } from "../../examples/browser/create_did.js"; | ||
import { createVC } from "../../examples/browser/create_vc.js"; | ||
import { manipulateIdentity } from "../../examples/browser/mainpulate_did.js"; | ||
import { resolveIdentity } from "../../examples/browser/resolve.js"; | ||
import { createVP } from "../../examples/browser/create_vp.js"; | ||
import { revoke } from "../../examples/browser/revocation.js"; | ||
import { merkleKey } from "../../examples/browser/merkle_key.js"; | ||
|
||
// Test that the browser examples do not throw uncaught exceptions twice, including syntax errors etc. | ||
describe( | ||
"Test browser examples", | ||
{ | ||
defaultCommandTimeout: 120000, // 2 minutes to account for spurious network delays | ||
}, | ||
() => { | ||
beforeEach(async () => { | ||
// The working directory is under __cypress at test runtime, so we need to go up one more level than usual | ||
await initIdentity("../../../web/identity_wasm_bg.wasm", false); | ||
|
||
// NOTE: `cy.wrap(defaultClientConfig()).as('config')` does not always work to make the config available | ||
// from the shared context as `this.config` because it has a race condition with initializing the wasm. | ||
// So call `defaultClientConfig()` manually for now. | ||
}); | ||
|
||
it("create identity", async function () { | ||
let identityResult; | ||
try { | ||
identityResult = await createIdentity(defaultClientConfig(), false); | ||
} catch (e) { | ||
identityResult = await createIdentity(defaultClientConfig(), false); | ||
} | ||
// example of testing the output, can remove if needed | ||
expect(identityResult).to.have.all.keys("key", "doc", "receipt", "explorerUrl"); | ||
}); | ||
|
||
it("manipulate identity", async function () { | ||
try { | ||
await manipulateIdentity(defaultClientConfig(), false); | ||
} catch (e) { | ||
await manipulateIdentity(defaultClientConfig(), false); | ||
} | ||
}); | ||
|
||
it("resolve identity", async function () { | ||
try { | ||
await resolveIdentity(defaultClientConfig(), false, false); | ||
} catch (e) { | ||
await resolveIdentity(defaultClientConfig(), false, false); | ||
} | ||
}); | ||
|
||
it("create verifiable credential", async function () { | ||
try { | ||
await createVC(defaultClientConfig(), false); | ||
} catch (e) { | ||
await createVC(defaultClientConfig(), false); | ||
} | ||
}); | ||
|
||
it("revoke verifiable credential", async function () { | ||
try { | ||
await revoke(defaultClientConfig(), false); | ||
} catch (e) { | ||
await revoke(defaultClientConfig(), false); | ||
} | ||
}); | ||
|
||
it("create verifiable presentation", async function () { | ||
try { | ||
await createVP(defaultClientConfig(), false); | ||
} catch (e) { | ||
await createVP(defaultClientConfig(), false); | ||
} | ||
}); | ||
|
||
it("merkle key", async function () { | ||
try { | ||
await merkleKey(defaultClientConfig(), false); | ||
} catch (e) { | ||
await merkleKey(defaultClientConfig(), false); | ||
} | ||
}); | ||
} | ||
); |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.