From 5e3b288e6453d4c69914f11d3f211df8e6c6469b Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 10 Mar 2023 23:50:38 +0100 Subject: [PATCH] fix accouts lib generation when no account available --- libs/remix-tests/src/compiler.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index 7fedf9c830..887c3d43a1 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -16,13 +16,16 @@ function regexIndexOf (inputString: string, regex: RegExp, startpos = 0) { export function writeTestAccountsContract (accounts: string[]) { const testAccountContract = require('../sol/tests_accounts.sol') // eslint-disable-line - let body = `address[${accounts.length}] memory accounts;` - if (!accounts.length) body += ';' - else { + let body = '' + if (accounts.length) { + body = `address[${accounts.length}] memory accounts;` accounts.map((address, index) => { body += `\n\t\taccounts[${index}] = ${address};\n` }) - } + body = `return accounts[index];` + body + } else { + body = `return address(0);` + } return testAccountContract.replace('>accounts<', body) }