foundry test

pull/5370/head
bunsenstraat 5 months ago
parent 345b0023b6
commit aa567cacdd
  1. 71
      apps/remixdesktop/test/tests/app/foundry.test.ts

@ -13,10 +13,10 @@ const tests = {
}, },
installFoundry: function (browser: NightwatchBrowser) { installFoundry: function (browser: NightwatchBrowser) {
browser.perform(async (done) => { browser.perform(async (done) => {
await downloadFoundry() await downloadFoundry()
await installFoundry() await installFoundry()
await initFoundryProject() await initFoundryProject()
done() done()
}) })
}, },
addScript: function (browser: NightwatchBrowser) { addScript: function (browser: NightwatchBrowser) {
@ -26,7 +26,7 @@ const tests = {
}, [dir], () => { }, [dir], () => {
console.log('done window opened') console.log('done window opened')
}) })
.waitForElementVisible('*[data-id="treeViewDivDraggableItemhardhat.config.js"]', 10000) .waitForElementVisible('*[data-id="treeViewDivDraggableItemfoundry.toml"]', 10000)
}, },
compile: function (browser: NightwatchBrowser) { compile: function (browser: NightwatchBrowser) {
browser.perform(async (done) => { browser.perform(async (done) => {
@ -34,7 +34,26 @@ const tests = {
await buildFoundryProject() await buildFoundryProject()
done() done()
}) })
.expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Foundry').before(60000) .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Foundry').before(60000)
let contractAaddress
browser.clickLaunchIcon('filePanel')
.openFile('src')
.openFile('src/Counter.sol')
.clickLaunchIcon('udapp')
.selectContract('Counter')
.createContract('')
.getAddressAtPosition(0, (address) => {
console.log(contractAaddress)
contractAaddress = address
})
.clickInstance(0)
.clickFunction('increment - transact (not payable)')
.perform((done) => {
browser.testConstantFunction(contractAaddress, 'number - call', null, '0:\nuint256: 1').perform(() => {
done()
})
})
} }
} }
async function downloadFoundry(): Promise<void> { async function downloadFoundry(): Promise<void> {
@ -60,9 +79,9 @@ async function downloadFoundry(): Promise<void> {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
async function installFoundry(): Promise<void> { async function installFoundry(): Promise<void> {
console.log('installFoundry', process.cwd()) console.log('installFoundry', process.cwd())
try { try {
const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && foundryup', [], { cwd: process.cwd(), shell: true, detached: true }) const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && foundryup', [], { cwd: process.cwd(), shell: true, detached: true })
@ -84,12 +103,12 @@ async function downloadFoundry(): Promise<void> {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
async function initFoundryProject(): Promise<void> { async function initFoundryProject(): Promise<void> {
console.log('initFoundryProject', homedir()) console.log('initFoundryProject', homedir())
try { try {
if(process.env.CIRCLECI) { if (process.env.CIRCLECI) {
spawn('git config --global user.email \"you@example.com\"', [], { cwd: homedir(), shell: true, detached: true }) spawn('git config --global user.email \"you@example.com\"', [], { cwd: homedir(), shell: true, detached: true })
spawn('git config --global user.name \"Your Name\"', [], { cwd: homedir(), shell: true, detached: true }) spawn('git config --global user.name \"Your Name\"', [], { cwd: homedir(), shell: true, detached: true })
} }
@ -98,35 +117,35 @@ async function downloadFoundry(): Promise<void> {
server.stdout.pipe(process.stdout) server.stdout.pipe(process.stdout)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
server.on('exit', function (exitCode) { server.on('exit', function (exitCode) {
console.log("Child exited with code: " + exitCode); console.log("Child exited with code: " + exitCode);
console.log('end') console.log('end')
resolve() resolve()
}) })
}) })
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
async function buildFoundryProject(): Promise<void> { async function buildFoundryProject(): Promise<void> {
console.log('buildFoundryProject', homedir()) console.log('buildFoundryProject', homedir())
try { try {
const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && forge build', [], { cwd: dir + '/hello_foundry', shell: true, detached: true }) const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && forge build', [], { cwd: dir + '/hello_foundry', shell: true, detached: true })
server.stdout.pipe(process.stdout) server.stdout.pipe(process.stdout)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
server.on('exit', function (exitCode) { server.on('exit', function (exitCode) {
console.log("Child exited with code: " + exitCode); console.log("Child exited with code: " + exitCode);
console.log('end') console.log('end')
resolve() resolve()
}) })
}) })
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
module.exports = { module.exports = {
...tests ...process.platform.startsWith('linux') ? tests : {}
} }
Loading…
Cancel
Save