From 12f36183d7f07dd734a034b046300425ee8e8bee Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 10 Mar 2023 23:51:11 +0100 Subject: [PATCH] update the accounts lib each time there's a test run --- apps/remix-ide/src/app/tabs/test-tab.js | 6 +++--- libs/remix-tests/sol/tests_accounts.sol.ts | 1 - .../solidity-unit-testing/src/lib/solidity-unit-testing.tsx | 5 ++++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 3ed78a474a..df16f47574 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -110,6 +110,8 @@ module.exports = class TestTab extends ViewPlugin { */ async testFromSource (content, path = 'browser/unit_test.sol') { const web3 = await this.call('blockchain', 'web3VM') + await this.testRunner.init(web3) + await this.createTestLibs() return new Promise((resolve, reject) => { const runningTest = {} runningTest[path] = { content } @@ -127,9 +129,7 @@ module.exports = class TestTab extends ViewPlugin { resolve(result) }, (url, cb) => { return this.contentImport.resolveAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message)) - }, { - web3 - }) + }, {}) }) } diff --git a/libs/remix-tests/sol/tests_accounts.sol.ts b/libs/remix-tests/sol/tests_accounts.sol.ts index 847e37f083..1d9533a613 100644 --- a/libs/remix-tests/sol/tests_accounts.sol.ts +++ b/libs/remix-tests/sol/tests_accounts.sol.ts @@ -5,7 +5,6 @@ pragma solidity >=0.4.22 <0.9.0; library TestsAccounts { function getAccount(uint index) pure public returns (address) { >accounts< - return accounts[index]; } } ` diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 58acc7421d..0ba6b43f4d 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -557,6 +557,9 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d const compilerData = await testTab.call('compilerArtefacts', 'getCompilerAbstract', file) await testTab.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilerData) } + + await testTab.testRunner.init(await testTab.call('blockchain', 'web3VM')) + await testTab.createTestLibs() testTab.testRunner.runTestSources( runningTests, compilerConfig, @@ -568,7 +571,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d callback(error) }, (url: string, cb: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any return testTab.contentImport.resolveAndSave(url).then((result: any) => cb(null, result)).catch((error: Error) => cb(error.message)) // eslint-disable-line @typescript-eslint/no-explicit-any - }, { testFilePath: testFilePath, web3: await testTab.call('blockchain', 'web3VM') } + }, { testFilePath: testFilePath } ) }).catch((error: Error) => { console.log(error)