browser log

circuitcompiler2
filip mertens 1 year ago
parent 6c76df1894
commit 3a3f335bdd
  1. 6
      apps/circuit-compiler/src/app/components/container.tsx
  2. 6
      apps/circuit-compiler/src/app/components/feedback.tsx
  3. 28
      apps/remix-ide-e2e/src/helpers/init.ts
  4. 58
      apps/remix-ide-e2e/src/tests/circom.test.ts

@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, useEffect } from 'react'
import { CustomTooltip, RenderIf } from '@remix-ui/helper'
import {FormattedMessage} from 'react-intl'
import { CircuitAppContext } from '../contexts'
@ -15,6 +15,10 @@ import { PrimeValue } from '../types'
export function Container () {
const circuitApp = useContext(CircuitAppContext)
useEffect(() => {
console.log('circuitApp.appState.status', circuitApp.appState.status)
}, [circuitApp.appState.status])
const showCompilerLicense = (message = 'License not available') => {
// @ts-ignore
circuitApp.plugin.call('notification', 'modal', { id: 'modal_circuit_compiler_license', title: 'Compiler License', message })

@ -1,4 +1,4 @@
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { CompilerFeedbackProps, CompilerReport } from '../types'
import { RenderIf } from '@remix-ui/helper'
import {CopyToClipboard} from '@remix-ui/clipboard'
@ -11,6 +11,10 @@ export function CompilerFeedback ({ feedback, filePathToId, hideWarnings, openEr
setShowException(false)
}
useEffect(() => {
console.log('feedback', JSON.stringify(feedback))
}, [feedback])
const handleOpenError = (report: CompilerReport) => {
if (report.labels.length > 0) {
openErrorLocation(filePathToId[report.labels[0].file_id], report.labels[0].range.start)

@ -13,7 +13,6 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url
//.switchBrowserTab(0)
.waitForElementVisible('[id="remixTourSkipbtn"]')
.click('[id="remixTourSkipbtn"]')
.perform((done) => {
if (!loadPlugin) return done()
browser
@ -27,30 +26,37 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url
})
.verifyLoad()
.perform(() => {
if (hideToolTips) {
browser.execute(function () { // hide tooltips
function addStyle(styleString) {
const style = document.createElement('style');
style.textContent = styleString;
document.head.append(style);
}
addStyle(`
.bs-popover-right {
display:none !important;
}
.bs-popover-top {
display:none !important;
}
.bs-popover-left {
display:none !important;
}
.bs-popover-bottom {
.popover {
display:none !important;
}
`);
})
}})
.perform(() => {
console.log('init')
browser.execute(function () {
(window as any).logs = []
console.log = function () {
(window as any).logs.push(JSON.stringify(arguments))
}
console.error = function () {
(window as any).logs.push(JSON.stringify(arguments))
}
})
})
.perform(() => {
if (preloadPlugins) {
initModules(browser, () => {
browser

@ -1,5 +1,5 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import {NightwatchBrowser} from 'nightwatch'
import init from '../helpers/init'
module.exports = {
@ -18,7 +18,9 @@ module.exports = {
.click('select[id="wstemplate"]')
.click('select[id="wstemplate"] option[value=semaphore]')
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() })
.execute(function () {
;(document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click()
})
.pause(100)
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]')
@ -28,13 +30,7 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtemplates/groth16_verifier.sol.ejs"]')
},
'Should compile a simple circuit using editor play button #group1': function (browser: NightwatchBrowser) {
browser
.click('[data-id="treeViewLitreeViewItemcircuits/simple.circom"]')
.waitForElementPresent('[data-path="Semaphore - 1/circuits/simple.circom"]')
.waitForElementVisible('[data-path="Semaphore - 1/circuits/simple.circom"]')
.click('[data-id="play-editor"]')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
browser.click('[data-id="treeViewLitreeViewItemcircuits/simple.circom"]').waitForElementPresent('[data-path="Semaphore - 1/circuits/simple.circom"]').waitForElementVisible('[data-path="Semaphore - 1/circuits/simple.circom"]').click('[data-id="play-editor"]').waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]').waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
},
'Should compute a witness for a simple circuit #group1': function (browser: NightwatchBrowser) {
browser
@ -69,16 +65,7 @@ module.exports = {
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
},
'Should generate R1CS for a simple circuit #group2': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('circuit-compiler')
.frame(0)
.waitForElementPresent('button[data-id="generate_r1cs_btn"]')
.waitForElementVisible('button[data-id="generate_r1cs_btn"]')
.click('button[data-id="generate_r1cs_btn"]')
.frameParent()
.clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]')
browser.clickLaunchIcon('circuit-compiler').frame(0).waitForElementPresent('button[data-id="generate_r1cs_btn"]').waitForElementVisible('button[data-id="generate_r1cs_btn"]').click('button[data-id="generate_r1cs_btn"]').frameParent().clickLaunchIcon('filePanel').waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]').waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]')
},
'Should compile a simple circuit using CTRL + S from the editor #group3': function (browser: NightwatchBrowser) {
browser
@ -95,7 +82,10 @@ module.exports = {
},
'Should display warnings for compiled circuit without pragma version #group4': function (browser: NightwatchBrowser) {
browser
.addFile('circuits/warning.circom', { content: warningCircuit })
.captureBrowserConsoleLogs((event) => {
console.log(event.type, event.timestamp, event.args[0].value)
})
.addFile('circuits/warning.circom', {content: warningCircuit})
.waitForElementPresent('[data-path="Semaphore - 1/circuits/warning.circom"]')
.waitForElementVisible('[data-path="Semaphore - 1/circuits/warning.circom"]')
.click('[data-id="treeViewLitreeViewItemcircuits/warning.circom"]')
@ -104,6 +94,7 @@ module.exports = {
.waitForElementPresent('button[data-id="compile_circuit_btn"]')
.waitForElementVisible('button[data-id="compile_circuit_btn"]')
.click('button[data-id="compile_circuit_btn"]')
.waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)')
.frameParent()
.clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/warning.wasm"]')
@ -114,20 +105,24 @@ module.exports = {
.waitForElementVisible('[data-id="circuit_feedback"]')
.assert.hasClass('[data-id="circuit_feedback"]', 'alert-warning')
.waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)')
.execute(
function () {
return (window as any).logs
},
[],
function (result) {
console.log(result)
}
)
},
'Should hide/show warnings for compiled circuit #group4': function (browser: NightwatchBrowser) {
browser
.click('[data-id="hide_circuit_warnings_checkbox_input"]')
.waitForElementNotPresent('[data-id="circuit_feedback"]')
.click('[data-id="hide_circuit_warnings_checkbox_input"]')
.waitForElementVisible('[data-id="circuit_feedback"]')
.waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)')
browser.click('[data-id="hide_circuit_warnings_checkbox_input"]').waitForElementNotPresent('[data-id="circuit_feedback"]').click('[data-id="hide_circuit_warnings_checkbox_input"]').waitForElementVisible('[data-id="circuit_feedback"]').waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)')
},
'Should display error for invalid circuit #group4': function (browser: NightwatchBrowser) {
browser
.frameParent()
.clickLaunchIcon('filePanel')
.addFile('circuits/error.circom', { content: errorCircuit })
.addFile('circuits/error.circom', {content: errorCircuit})
.waitForElementPresent('[data-path="Semaphore - 1/circuits/error.circom"]')
.waitForElementVisible('[data-path="Semaphore - 1/circuits/error.circom"]')
.click('[data-id="treeViewLitreeViewItemcircuits/error.circom"]')
@ -145,14 +140,9 @@ module.exports = {
.click('[data-id="auto_compile_circuit_checkbox_input"]')
.frameParent()
.setEditorValue(validCircuit, function () {
browser
.frame(0)
.waitForElementNotPresent('[data-id="circuit_feedback"]')
.frameParent()
.clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/error.wasm"]')
browser.frame(0).waitForElementNotPresent('[data-id="circuit_feedback"]').frameParent().clickLaunchIcon('filePanel').waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/error.wasm"]')
})
}
},
}
const warningCircuit = `

Loading…
Cancel
Save