-
Notifications
You must be signed in to change notification settings - Fork 565
Conversation
remix-tests/src/runTestFiles.ts
Outdated
export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, opts?: object) { | ||
opts = opts || {} | ||
let sourceASTs: any = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. Here you create an empty object that you mutate later on. But you do not reassign the value. Which means that you can use const
here ;)
remix-tests/src/runTestFiles.ts
Outdated
@@ -44,7 +53,13 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, | |||
function compile(next: Function) { | |||
compileFileOrFiles(filepath, isDirectory, { accounts }, next) | |||
}, | |||
function deployAllContracts (compilationResult, next: Function) { | |||
function deployAllContracts (compilationResult, asts, next: Function) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any tupes for result & AST ? I've some types here for compilation output. I don't know if it can help.
remix-tests/src/runTestSources.ts
Outdated
export async function runTestSources(contractSources, versionUrl, usingWorker, testCallback, resultCallback, finalCallback, importFileCb, opts) { | ||
opts = opts || {} | ||
let sourceASTs: any = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
remix-tests/src/runTestSources.ts
Outdated
function deployAllContracts (compilationResult, next) { | ||
function deployAllContracts (compilationResult, asts, next) { | ||
for(const filename in asts) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the Javascript style for bracket for loops. I'm fine using the C++ version, but if it doesn't make much difference for you I would recommend doing it like that :
for (const filename in asts) { // Bracket at the end of the line
if(filename.includes('_test.sol')) sourceASTs[filename] = asts[filename].ast
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously, we should use javascript style
remix-tests/src/runTestSources.ts
Outdated
@@ -79,7 +96,7 @@ export async function runTestSources(contractSources, versionUrl, usingWorker, t | |||
} | |||
|
|||
async.eachOfLimit(contractsToTest, 1, (contractName: string, index: string | number, cb: ErrorCallback) => { | |||
runTest(contractName, contracts[contractName], contractsToTestDetails[index], { accounts }, _testCallback, (err, result) => { | |||
runTest(contractName, contracts[contractName], contractsToTestDetails[index], sourceASTs[contracts[contractName]['filename']], { accounts }, _testCallback, (err, result) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more readable you can create variables :
const contract = contracts[contractName];
const details = contractsToTestDetails[index];
const iAmNotSure = sourceASTs[contracts[contractName]['filename']]
runTest(contractName, contract, details, iAmNotSure, ...)
remix-tests/src/testRunner.ts
Outdated
*/ | ||
|
||
function getTestFunctionsInterface (jsonInterface: any, funcList: string[]) { | ||
let functionsInterface: any[] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above about const
remix-tests/src/testRunner.ts
Outdated
const specialFunctions = ['beforeAll', 'beforeEach', 'afterAll', 'afterEach'] | ||
for(const func of funcList){ | ||
if(!specialFunctions.includes(func)) | ||
functionsInterface.push(jsonInterface.find(node => node.type === 'function' && node.name === func)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a variable for jsonInterface.find(node => node.type === 'function' && node.name === func)
with a name that describe what it is.
Sequence of tests will be same as they will appear in test contract file. AST is used to ensure this.
Related to #1240