Skip to content

Commit c6942c7

Browse files
authored
feat: end to end tests (#487)
* WIP: e2e tests * feat: working end-to-end TEE * chore: cleanup wasm testing Now has mode for tee and origo * fix: should run different modes now * cleanup * fix: use stdout for notary startup * Update test_client_native_tee.yaml * fix: use cached builds if available * fix * fixes * try to fix ci * LET'S TRY AGAIN SHALL WE
1 parent 21e76d1 commit c6942c7

File tree

12 files changed

+257
-19
lines changed

12 files changed

+257
-19
lines changed

.github/workflows/test_client_native_tee.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,4 @@ jobs:
3636
- run: chmod +x target/release/client
3737

3838
- run: |
39-
export RUST_LOG=DEBUG
40-
./target/release/notary --config ./fixture/notary-config.toml &
41-
sleep 10
42-
43-
./target/release/client --config ./fixture/client.tee_tcp_local.json
39+
cargo test -p web-prover-tests

.github/workflows/test_client_wasm_origo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ jobs:
6262
(cd client_wasm/demo/static && rm -rf build && ln -s ../../../proofs/web_proof_circuits build)
6363
6464
cd client_wasm/demo
65-
npm test
65+
npm test origo

.github/workflows/test_client_wasm_tee.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,5 @@ jobs:
6161
# symlink proofs/web_proof_circuits
6262
(cd client_wasm/demo/static && rm -rf build && ln -s ../../../proofs/web_proof_circuits build)
6363
64-
# TODO quick workaround to use TEE fixture instead of Origo fixture in
65-
# client_wasm/demo/js/index.js proverConfig
66-
cp fixture/client.tee_tcp_local.json fixture/client.origo_tcp_local.json
67-
6864
cd client_wasm/demo
69-
npm test
65+
npm test tee

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ name ="webprover"
33
edition="2021"
44

55
[workspace]
6-
members=["client", "client_ios", "client_wasm", "notary", "proofs", "web-prover-core"]
7-
# members =["client", "client_wasm", "proofs"] # config for wasm32 rust analyzer
8-
# members =["client", "client_ios"] # config for ios rust analyzer
6+
members =["client", "client_ios", "client_wasm", "notary", "proofs", "web-prover-core", "tests"]
97
resolver="2"
108

119
[workspace.metadata]
@@ -16,6 +14,7 @@ web_prover_circuits_version="0.10.0"
1614
# Local re-exporting
1715
client ={ path="client" }
1816
proofs ={ path="proofs" }
17+
notary ={ path="notary" }
1918
web-prover-core={ path="web-prover-core" }
2019
# Serde
2120
serde ={ version="1.0.204", features=["derive"] }
@@ -66,6 +65,8 @@ ff ={ version="0.13", default-features=false, features=["derive"] }
6665
tiny-keccak={ version="2.0.2", features=["keccak"] }
6766
url ="2.5.4"
6867

68+
tracing-test="0.2"
69+
6970
[profile.dev]
7071
opt-level =1
7172
split-debuginfo="unpacked"

client_wasm/demo/js/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import init, { setup_tracing, initThreadPool } from "../pkg/client_wasm.js";
2-
import { witness } from "./witness";
32
import { WEB_PROVER_CIRCUITS_VERSION } from "./config";
3+
import teeConfig from "../../../fixture/client.tee_tcp_local.json";
4+
import origoConfig from "../../../fixture/client.origo_tcp_local.json";
5+
import { DEFAULT_MODE } from "../scripts/test.js";
46

57
const numConcurrency = navigator.hardwareConcurrency;
68

@@ -65,7 +67,10 @@ const getByteParams = async function (setupFile) {
6567

6668
start();
6769

68-
import proverConfig from "../../../fixture/client.origo_tcp_local.json";
70+
const mode = window.MODE || DEFAULT_MODE; // Get the mode from window object
71+
const proverConfig = mode === 'origo' ? origoConfig : teeConfig;
72+
73+
console.log(`Using ${mode} mode`);
6974

7075
const proofWorker = new Worker(new URL("./proof.js", import.meta.url), {
7176
type: "module",

client_wasm/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"prestart": "node scripts/generate-config.js",
77
"start": "webpack-dev-server --port 8090",
8-
"test": "node scripts/generate-config.js && playwright test --browser=chromium"
8+
"test": "node scripts/generate-config.js && node scripts/test.js"
99
},
1010
"devDependencies": {
1111
"@wasm-tool/wasm-pack-plugin": "^1.7.0",

client_wasm/demo/scripts/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { spawn } = require('child_process');
2+
3+
const DEFAULT_MODE = "tee"
4+
5+
const mode = process.argv[2] || DEFAULT_MODE; // Default to tee if no argument provided
6+
process.env.MODE = mode;
7+
8+
// Run the playwright test
9+
spawn('npx', ['playwright', 'test', '--browser=chromium'], {
10+
stdio: 'inherit',
11+
env: process.env
12+
});

client_wasm/demo/tests/proof.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const { test, expect } = require('@playwright/test')
22

33
test('should generate proof', async ({ page }) => {
4+
// Set the mode on window before loading the page
5+
await page.addInitScript(`window.MODE = '${process.env.MODE || 'tee'}'`);
6+
47
test.setTimeout(600000) // 10 min
58

69
// Add page error handler

proofs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ wasm-bindgen-futures="0.4.37"
4040
circom_witnesscalc={ git="https://github.com/pluto/circom-witnesscalc" } # Fork is needed apparently??
4141

4242
[dev-dependencies]
43-
tracing-test="0.2.5"
44-
tempdir ="0.3.7"
43+
tracing-test.workspace=true
44+
tempdir ="0.3.7"
4545

4646
[build-dependencies]
4747
cargo_metadata="0.19.1"

0 commit comments

Comments
 (0)