From 5f92614db410ba6b69d6f03cf2a30c6f484be0ff Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 29 Oct 2021 19:20:08 +0530 Subject: [PATCH] fetch test files --- apps/remix-ide/src/app/tabs/test-tab.js | 6 +++++- libs/remix-core-plugin/src/lib/compiler-content-imports.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 117a88769c..21837df752 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -16,7 +16,7 @@ const TestTabLogic = require('./testTab/testTab') const profile = { name: 'solidityUnitTesting', displayName: 'Solidity unit testing', - methods: ['testFromPath', 'testFromSource', 'setTestFolderPath'], + methods: ['testFromPath', 'testFromSource', 'setTestFolderPath', 'getTestlibs'], events: [], icon: 'assets/img/unitTesting.webp', description: 'Fast tool to generate unit tests for your contracts', @@ -74,6 +74,10 @@ module.exports = class TestTab extends ViewPlugin { } } + getTestlibs() { + return { assertLibCode, accountsLibCode: this.testRunner.accountsLibCode} + } + async onActivation () { const isSolidityActive = await this.call('manager', 'isActive', 'solidity') if (!isSolidityActive) { diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 2e20d5ebb7..1d1cacc5ca 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -117,7 +117,11 @@ export class CompilerImports extends Plugin { * @returns {Promise} - string content */ async resolveAndSave (url, targetPath) { - if (url.indexOf('remix_tests.sol') !== -1) return remixTests.assertLibCode + if (url.indexOf('remix_tests.sol') !== -1 || url.indexOf('remix_accounts.sol') !== -1) { + const {assertLibCode, accountsLibCode} = await this.call('solidityUnitTesting', 'getTestlibs') + if (url === 'remix_tests.sol') return assertLibCode + else if (url === 'remix_accounts.sol') return accountsLibCode + } try { const provider = await this.call('fileManager', 'getProviderOf', url) if (provider) {