fix accouts lib generation when no account available

pull/5370/head
yann300 2 years ago
parent f9e1e6e103
commit 5e3b288e64
  1. 9
      libs/remix-tests/src/compiler.ts

@ -16,12 +16,15 @@ 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)
}

Loading…
Cancel
Save