From b2f3c911e38b7bab35059bc56372dbb95116a73b Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 Jun 2024 16:51:35 +0200 Subject: [PATCH] fix foundry e2e --- apps/remix-ide-e2e/src/tests/remixd.test.ts | 43 ++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/remixd.test.ts b/apps/remix-ide-e2e/src/tests/remixd.test.ts index 0541150794..604277ae6b 100644 --- a/apps/remix-ide-e2e/src/tests/remixd.test.ts +++ b/apps/remix-ide-e2e/src/tests/remixd.test.ts @@ -187,8 +187,8 @@ module.exports = { 'Should listen on compilation result from foundry #group5': function (browser: NightwatchBrowser) { browser.perform(async (done) => { - remixd = await spawnRemixd(join(homedir() + '/hello_foundry')) - console.log('working directory', homedir() + '/hello_foundry') + console.log('working directory', homedir() + '/foundry_tmp/hello_foundry') + remixd = await spawnRemixd(join(homedir(), '/foundry_tmp/hello_foundry')) connectRemixd(browser, done) }) .perform(async (done) => { @@ -197,6 +197,34 @@ module.exports = { }) .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() + }) + }) + }, + + 'Should load compilation result from hardhat when remixd connects #group5': function (browser: NightwatchBrowser) { + + browser.refresh().perform(async (done) => { + console.log('working directory', homedir() + '/foundry_tmp/hello_foundry') + connectRemixd(browser, done) + }) + .expect.element('*[data-id="terminalJournal"]').text.to.contain('receiving compilation result from Foundry').before(60000) + let contractAaddress browser.clickLaunchIcon('filePanel') .openFile('src') @@ -415,8 +443,12 @@ async function installFoundry(): Promise { async function initFoundryProject(): Promise { console.log('initFoundryProject', homedir()) - try { - const server = spawn('forge init hello_foundry', [], { cwd: homedir(), shell: true, detached: true }) + try { + 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('mkdir foundry_tmp', [], { cwd: homedir(), shell: true, detached: true }) + const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && forge init hello_foundry', [], { cwd: homedir() + '/foundry_tmp', shell: true, detached: true }) + server.stdout.pipe(process.stdout) return new Promise((resolve, reject) => { server.on('exit', function (exitCode) { console.log("Child exited with code: " + exitCode); @@ -432,7 +464,8 @@ async function initFoundryProject(): Promise { async function buildFoundryProject(): Promise { console.log('buildFoundryProject', homedir()) try { - const server = spawn('forge build', [], { cwd: homedir() + '/hello_foundry', shell: true, detached: true }) + const server = spawn('export PATH="' + homedir() + '/.foundry/bin:$PATH" && forge build', [], { cwd: homedir() + '/foundry_tmp/hello_foundry', shell: true, detached: true }) + server.stdout.pipe(process.stdout) return new Promise((resolve, reject) => { server.on('exit', function (exitCode) { console.log("Child exited with code: " + exitCode);