From df93f61838f36e36ce1191e9ae6240f77d7e7d67 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 5 Nov 2021 16:08:09 +0530 Subject: [PATCH] test accounts for deployment --- libs/remix-tests/src/deployer.ts | 10 ++-------- libs/remix-tests/src/runTestFiles.ts | 4 ++-- libs/remix-tests/src/runTestSources.ts | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/libs/remix-tests/src/deployer.ts b/libs/remix-tests/src/deployer.ts index d700b08de5..e2a5e6cb04 100644 --- a/libs/remix-tests/src/deployer.ts +++ b/libs/remix-tests/src/deployer.ts @@ -11,18 +11,12 @@ import { compilationInterface } from './types' * @param callback Callback */ -export function deployAll (compileResult: compilationInterface, web3: Web3, withDoubleGas: boolean, deployCb, callback) { +export function deployAll (compileResult: compilationInterface, web3: Web3, testsAccounts, withDoubleGas: boolean, deployCb, callback) { const compiledObject = {} const contracts = {} - let accounts: string[] = [] + let accounts: string[] = testsAccounts async.waterfall([ - function getAccountList (next) { - web3.eth.getAccounts((_err, _accounts) => { - accounts = _accounts - next() - }) - }, function getContractData (next) { for (const contractFile in compileResult) { for (const contractName in compileResult[contractFile]) { diff --git a/libs/remix-tests/src/runTestFiles.ts b/libs/remix-tests/src/runTestFiles.ts index d9ed0c2b6e..dbf2b16e46 100644 --- a/libs/remix-tests/src/runTestFiles.ts +++ b/libs/remix-tests/src/runTestFiles.ts @@ -61,13 +61,13 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3 for (const filename in asts) { if (filename.endsWith('_test.sol')) { sourceASTs[filename] = asts[filename].ast } } - deployAll(compilationResult, web3, false, null, (err, contracts) => { + deployAll(compilationResult, web3, accounts, false, null, (err, contracts) => { if (err) { // If contract deployment fails because of 'Out of Gas' error, try again with double gas // This is temporary, should be removed when remix-tests will have a dedicated UI to // accept deployment params from UI if (err.message.includes('The contract code couldn\'t be stored, please check your gas limit')) { - deployAll(compilationResult, web3, true, null, (error, contracts) => { + deployAll(compilationResult, web3, accounts, true, null, (error, contracts) => { if (error) next([{ message: 'contract deployment failed after trying twice: ' + error.message, severity: 'error' }]) // IDE expects errors in array else next(null, compilationResult, contracts) }) diff --git a/libs/remix-tests/src/runTestSources.ts b/libs/remix-tests/src/runTestSources.ts index 33825fbc91..9d8b8ba400 100644 --- a/libs/remix-tests/src/runTestSources.ts +++ b/libs/remix-tests/src/runTestSources.ts @@ -59,13 +59,13 @@ export class UnitTestRunner { for (const filename in asts) { if (filename.endsWith('_test.sol')) { sourceASTs[filename] = asts[filename].ast } } - deployAll(compilationResult, this.web3, false, deployCb, (err, contracts) => { + deployAll(compilationResult, this.web3, this.testsAccounts, false, deployCb, (err, contracts) => { if (err) { // If contract deployment fails because of 'Out of Gas' error, try again with double gas // This is temporary, should be removed when remix-tests will have a dedicated UI to // accept deployment params from UI if (err.message.includes('The contract code couldn\'t be stored, please check your gas limit')) { - deployAll(compilationResult, this.web3, true, deployCb, (error, contracts) => { + deployAll(compilationResult, this.web3, this.testsAccounts, true, deployCb, (error, contracts) => { if (error) next([{ message: 'contract deployment failed after trying twice: ' + error.message, severity: 'error' }]) // IDE expects errors in array else next(null, compilationResult, contracts) })