Commit 02c68046 authored by aniket-engg's avatar aniket-engg

tests for custom optimize option

parent 8d59edf1
...@@ -126,15 +126,20 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts: ...@@ -126,15 +126,20 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
async.waterfall([ async.waterfall([
function loadCompiler(next) { function loadCompiler(next) {
compiler = new RemixCompiler() compiler = new RemixCompiler()
const {currentCompilerUrl, evmVersion, optimize, runs} = compilerConfig if(compilerConfig) {
evmVersion ? compiler.set('evmVersion', evmVersion) : const {currentCompilerUrl, evmVersion, optimize, runs} = compilerConfig
optimize ? compiler.set('optimize', optimize) : evmVersion ? compiler.set('evmVersion', evmVersion) : null
runs ? compiler.set('runs', runs) : '' optimize ? compiler.set('optimize', optimize) : null
if(currentCompilerUrl) { runs ? compiler.set('runs', runs) : null
compiler.loadRemoteVersion(currentCompilerUrl) if(currentCompilerUrl) {
compiler.event.register('compilerLoaded', this, function (version) { compiler.loadRemoteVersion(currentCompilerUrl)
compiler.event.register('compilerLoaded', this, function (version) {
next()
});
} else {
compiler.onInternalCompilerLoaded()
next() next()
}); }
} else { } else {
compiler.onInternalCompilerLoaded() compiler.onInternalCompilerLoaded()
next() next()
......
...@@ -99,8 +99,8 @@ commander ...@@ -99,8 +99,8 @@ commander
} }
if (commander.optimize) { if (commander.optimize) {
compilerConfig.optimize = commander.optimize compilerConfig.optimize = commander.optimize
log.info(`Optimization is ${compilerConfig.optimize ? 'enabled' : 'disabled'}`) log.info(`Optimization is ${compilerConfig.optimize ? 'enabled' : 'disabled'}`)
} }
const web3 = new Web3() const web3 = new Web3()
......
...@@ -77,5 +77,18 @@ Commands: ...@@ -77,5 +77,18 @@ Commands:
// macth fail test details // macth fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/) expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
}) })
test('remix-tests running a test file by enabling optimization', () => {
const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// match initial lines
expect(res.stdout.toString().trim().includes('Optimization is enabled')).toBeTruthy()
expect(res.stdout.toString().trim()).toMatch(/:: Running remix-tests - Unit testing for solidity ::/)
expect(res.stdout.toString().trim()).toMatch(/creation of library remix_tests.sol:Assert pending.../)
// match test result
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// macth fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
})
}) })
}) })
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment