From 585e3add4e59af8f8d2d6c807589605e14beffb7 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 13 Nov 2024 02:26:31 +0700 Subject: [PATCH] add circom tests --- .../test/tests/app/circom-compiler.test.ts | 50 +++++++++++++++ .../test/tests/app/circom-script.test.ts | 62 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 apps/remixdesktop/test/tests/app/circom-compiler.test.ts create mode 100644 apps/remixdesktop/test/tests/app/circom-script.test.ts diff --git a/apps/remixdesktop/test/tests/app/circom-compiler.test.ts b/apps/remixdesktop/test/tests/app/circom-compiler.test.ts new file mode 100644 index 0000000000..3c70ed4522 --- /dev/null +++ b/apps/remixdesktop/test/tests/app/circom-compiler.test.ts @@ -0,0 +1,50 @@ +import { NightwatchBrowser } from "nightwatch" + + +const tests = { + before: function (browser: NightwatchBrowser, done: VoidFunction) { + browser.hideToolTips() + done() + }, + 'Should create semaphore workspace': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="homeTabGetStartedsemaphore"]', 20000) + .click('*[data-id="homeTabGetStartedsemaphore"]') + .pause(3000) + .windowHandles(function (result) { + console.log(result.value) + browser.switchWindow(result.value[1]) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits"]') + .click('*[data-id="treeViewLitreeViewItemcircuits"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]') + .click('*[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16"]') + .click('*[data-id="treeViewLitreeViewItemscripts/groth16"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16/groth16_trusted_setup.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16/groth16_zkproof.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk"]') + .click('*[data-id="treeViewLitreeViewItemscripts/plonk"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/plonk_trusted_setup.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/plonk_zkproof.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates"]') + .click('*[data-id="treeViewLitreeViewItemtemplates"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates/groth16_verifier.sol.ejs"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates/plonk_verifier.sol.ejs"]') + }) + }, + 'Should compile a simple circuit using editor play button': function (browser: NightwatchBrowser) { + browser + .click('[data-id="treeViewLitreeViewItemcircuits/simple.circom"]') + .pause(2000) + .click('[data-id="play-editor"]') + .waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]') + .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin"]') + .click('[data-id="treeViewLitreeViewItemcircuits/.bin"]') + .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js"]') + .click('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js"]') + .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]') + }, +} + +module.exports = tests \ No newline at end of file diff --git a/apps/remixdesktop/test/tests/app/circom-script.test.ts b/apps/remixdesktop/test/tests/app/circom-script.test.ts new file mode 100644 index 0000000000..45f41c5296 --- /dev/null +++ b/apps/remixdesktop/test/tests/app/circom-script.test.ts @@ -0,0 +1,62 @@ +import { NightwatchBrowser } from "nightwatch" + + +const tests = { + before: function (browser: NightwatchBrowser, done: VoidFunction) { + browser.hideToolTips() + done() + }, + 'Should create semaphore workspace': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="homeTabGetStartedsemaphore"]', 20000) + .click('*[data-id="homeTabGetStartedsemaphore"]') + .pause(3000) + .windowHandles(function (result) { + console.log(result.value) + browser.switchWindow(result.value[1]) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits"]') + .click('*[data-id="treeViewLitreeViewItemcircuits"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]') + .click('*[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16"]') + .click('*[data-id="treeViewLitreeViewItemscripts/groth16"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16/groth16_trusted_setup.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/groth16/groth16_zkproof.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk"]') + .click('*[data-id="treeViewLitreeViewItemscripts/plonk"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/plonk_trusted_setup.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/plonk_zkproof.ts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates"]') + .click('*[data-id="treeViewLitreeViewItemtemplates"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates/groth16_verifier.sol.ejs"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates/plonk_verifier.sol.ejs"]') + }) + }, + 'Should run plonk trusted setup script for hash checker #group6': function (browser: NightwatchBrowser) { + browser + .click('[data-id="treeViewLitreeViewItemscripts/plonk/plonk_trusted_setup.ts"]') + .pause(2000) + .click('[data-id="play-editor"]') + .waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]') + .waitForElementVisible({ + locateStrategy: 'xpath', + selector: "//span[@class='text-log' and contains(., 'setup done.')]", + timeout: 60000 + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/zk"]') + .click('*[data-id="treeViewLitreeViewItemscripts/plonk/zk"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/zk/keys"]') + .click('*[data-id="treeViewLitreeViewItemscripts/plonk/zk/keys"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/plonk/zk/keys/verification_key.json"]') + }, + 'Should run plonk zkproof script for hash checker #group6': function (browser: NightwatchBrowser) { + browser + .click('[data-id="treeViewLitreeViewItemscripts/plonk/plonk_zkproof.ts"]') + .pause(2000) + .click('[data-id="play-editor"]') + } + +} + +module.exports = tests \ No newline at end of file