diff --git a/apps/remix-ide-e2e/src/commands/checkVariableDebug.ts b/apps/remix-ide-e2e/src/commands/checkVariableDebug.ts index 572c4893f3..037c005b6e 100644 --- a/apps/remix-ide-e2e/src/commands/checkVariableDebug.ts +++ b/apps/remix-ide-e2e/src/commands/checkVariableDebug.ts @@ -29,6 +29,7 @@ function checkDebug(browser: NightwatchBrowser, id: string, debugValue: Nightwat }, [id], (result) => { if (result.value) { try { + console.log('checkDebug', result.value) resultOfElement = JSON.parse(result.value) isEqual = deepequal(debugValue, resultOfElement) } catch (e) { diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index b5c9518d23..3a448c8aa4 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -109,7 +109,7 @@ module.exports = class TestTab extends ViewPlugin { Test is not associated with the UI */ testFromSource (content, path = 'browser/unit_test.sol') { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { const runningTest = {} runningTest[path] = { content } const { currentVersion, evmVersion, optimize, runs } = this.compileTab.getCurrentCompilerConfig() @@ -126,6 +126,8 @@ 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: await this.call('blockchain', 'web3VM') }) }) } diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 010696456f..509e2d4ea3 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -22,7 +22,7 @@ const profile = { name: 'blockchain', displayName: 'Blockchain', description: 'Blockchain - Logic', - methods: ['getCode', 'getTransactionReceipt', 'addProvider', 'removeProvider'], + methods: ['getCode', 'getTransactionReceipt', 'addProvider', 'removeProvider', 'getCurrentFork', 'web3VM'], version: packageJson.version } @@ -401,6 +401,10 @@ export class Blockchain extends Plugin { this.getCurrentProvider().signMessage(message, account, passphrase, cb) } + web3VM () { + return this.providers.vm.web3 + } + web3 () { // @todo(https://github.com/ethereum/remix-project/issues/431) const isVM = this.getProvider() === 'vm' diff --git a/libs/remix-tests/src/runTestSources.ts b/libs/remix-tests/src/runTestSources.ts index 40f0d87788..6e8c0bfc82 100644 --- a/libs/remix-tests/src/runTestSources.ts +++ b/libs/remix-tests/src/runTestSources.ts @@ -30,10 +30,7 @@ export class UnitTestRunner { } async createWeb3Provider (optWeb3) { - const web3 = optWeb3 || new Web3() - const provider: any = new Provider() - await provider.init() - web3.setProvider(provider) + const web3 = optWeb3 extend(web3) return web3 } 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 a377a6f73f..5b114499dd 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 @@ -537,7 +537,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d updateFinalResult(null, null, testFilePath) return } - testTab.fileManager.readFile(testFilePath).then((content: string) => { + testTab.fileManager.readFile(testFilePath).then(async (content: string) => { const runningTests: Record> = {} runningTests[testFilePath] = { content } filesContent[testFilePath] = { content } @@ -565,7 +565,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: testFilePath, web3: await testTab.call('blockchain', 'web3VM') } ) }).catch((error: Error) => { console.log(error)