fix compile path

circomdesktoptest
bunsenstraat 2 weeks ago
parent af69b9e77a
commit a7c0b19e7e
  1. BIN
      apps/remixdesktop/circom-download/latest/circom-linux-amd64
  2. 42
      apps/remixdesktop/src/tools/circom.ts
  3. 20
      apps/remixdesktop/test/tests/app/circom-compiler.test.ts
  4. 5
      apps/remixdesktop/test/tests/app/circom-script.test.ts

@ -1,4 +1,5 @@
import { app } from 'electron'
import os from 'os'
import { exec } from 'child_process'
import path from 'path'
import fs, { existsSync } from 'fs'
@ -33,16 +34,13 @@ async function downloadFile(url: string, dest: string) {
}
export function getInstallationPath(version) {
switch (process.platform) {
case 'win32':
return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-windows-amd64.exe') : path.join(app.getAppPath(), 'circom-download', version, 'circom-windows-amd64.exe')
case 'darwin':
return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-macos-amd64') : path.join(app.getAppPath(), 'circom-download', version, 'circom-macos-amd64')
case 'linux':
return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-linux-amd64') : path.join(app.getAppPath(), 'circom-download', version, 'circom-linux-amd64')
}
const fileNames = {
win32: 'circom-windows-amd64.exe',
darwin: 'circom-macos-amd64',
linux: 'circom-linux-amd64'
};
return path.join(os.tmpdir(), 'circom-download', version, fileNames[process.platform]);
}
export function getInstallationUrl(version) {
@ -59,25 +57,9 @@ export function getInstallationUrl(version) {
}
export function getLogInputSignalsPath() {
console.log('home: ', app.getPath('home'))
console.log('appData: ', app.getPath('appData'))
console.log('userData: ', app.getPath('userData'))
console.log('temp: ', app.getPath('temp'))
console.log('exe: ', app.getPath('exe'))
console.log('getAppPath: ', app.getAppPath())
switch (process.platform) {
case 'win32':
// eslint-disable-next-line no-case-declarations
const programDir = app.getPath('exe').split('\\').slice(0, -1).join('\\')
return process.env.NODE_ENV === 'production' ? path.join(programDir, 'log_input_signals.txt') : path.join(app.getAppPath(), 'log_input_signals.txt')
case 'darwin':
return path.join(app.getAppPath(), 'log_input_signals.txt')
case 'linux':
return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'log_input_signals.txt') : path.join(app.getAppPath(), 'log_input_signals.txt')
}
const tempFilePath = path.join(os.tmpdir(), 'log_input_signals.txt');
return tempFilePath;
}
export const circomCli = {
@ -106,9 +88,9 @@ export const circomCli = {
async run (filePath: string, version: string, options?: Record<string, string>) {
const installationPath = getInstallationPath(version)
const cmd = `${installationPath} ${filePath} ${Object.keys(options || {}).map((key) => options[key] ? `--${key} ${options[key]}` : `--${key}`).join(' ')}`
console.log(cmd)
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
exec(cmd, { cwd: os.tmpdir() }, (error, stdout, stderr) => {
if (error) {
reject(`${error.message} with error code ${error.code}`)
} else {

@ -36,8 +36,9 @@ const tests = {
'Should compile a simple circuit using editor play button': function (browser: NightwatchBrowser) {
browser
.click('[data-id="treeViewLitreeViewItemcircuits/simple.circom"]')
.pause(2000)
.waitForElementVisible('[data-id="play-editor"]')
.click('[data-id="play-editor"]')
.pause()
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin"]')
.click('[data-id="treeViewLitreeViewItemcircuits/.bin"]')
@ -45,6 +46,23 @@ const tests = {
.click('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
},
'Should compute a witness for a simple circuit #group1': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('circuit-compiler')
.frame(0)
.waitForElementVisible('[data-id="witness_toggler"]')
.click('[data-id="witness_toggler"]')
.waitForElementVisible('[data-id="compute_witness_btn"]')
.waitForElementVisible('[data-id="circuit_input_a"]')
.waitForElementVisible('[data-id="circuit_input_b"]')
.setValue('[data-id="circuit_input_a"]', '1')
.setValue('[data-id="circuit_input_b"]', '2')
.click('[data-id="compute_witness_btn"]')
.frameParent()
.clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wtn"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wtn"]')
},
}
module.exports = tests

@ -55,6 +55,11 @@ const tests = {
.click('[data-id="treeViewLitreeViewItemscripts/plonk/plonk_zkproof.ts"]')
.pause(2000)
.click('[data-id="play-editor"]')
.waitForElementVisible({
locateStrategy: 'xpath',
selector: "//span[@class='text-log' and contains(., 'proof done')]",
timeout: 60000
})
}
}

Loading…
Cancel
Save