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..fb21cf0349 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -106,6 +106,13 @@ export class CompilerImports extends Plugin { }) } + async importTestFiles () { + const provider = await this.call('fileManager', 'getProviderOf', null) + const content = remixTests.assertLibCode + if (provider) provider.addExternal('.deps/remix-tests/remix-tests.sol', content, 'remix_tests.sol') + return content + } + /** * import the content of @arg url. * first look in the browser localstorage (browser explorer) or locahost explorer. if the url start with `browser/*` or `localhost/*` @@ -117,7 +124,9 @@ 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) { + return await this.importTestFiles() + } try { const provider = await this.call('fileManager', 'getProviderOf', url) if (provider) { diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index e15bb656e4..ee1846b7a3 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -177,7 +177,7 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile // Iterate over sources keys. Inject test libraries. Inject test library import statements. if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) { sources['tests.sol'] = { content: require('../sol/tests.sol.js') } - sources['remix_tests.sol'] = { content: require('../sol/tests.sol.js') } + // sources['remix_tests.sol'] = { content: require('../sol/tests.sol.js') } sources['remix_accounts.sol'] = { content: writeTestAccountsContract(accounts) } } const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm