pull/3951/head
Oleksii Kosynskyi 2 years ago
parent 2858e526a6
commit fc2878827e
No known key found for this signature in database
GPG Key ID: B4A8D3CCE22EA65E
  1. 1
      libs/remix-simulator/src/VmProxy.ts
  2. 3
      libs/remix-tests/src/run.ts
  3. 168
      libs/remix-tests/tests/testRunner.cli.spec.ts

@ -176,6 +176,7 @@ export class VmProxy {
const topics = [] const topics = []
if (log[1].length > 0) { if (log[1].length > 0) {
for (const k in log[1]) { for (const k in log[1]) {
// @ts-ignore
topics.push('0x' + log[1][k].toString('hex')) topics.push('0x' + log[1][k].toString('hex'))
} }
} else { } else {

@ -127,10 +127,9 @@ commander
nodeUrl: options.nodeUrl || null, nodeUrl: options.nodeUrl || null,
blockNumber: options.blockNumber || null blockNumber: options.blockNumber || null
} }
const web3 = new Web3()
const provider: any = new Provider(providerConfig) const provider: any = new Provider(providerConfig)
await provider.init() await provider.init()
web3.setProvider(provider) const web3 = new Web3(provider)
extend(web3) extend(web3)
runTestFiles(path.resolve(file_path), isDirectory, web3, compilerConfig, (error, totalPassing, totalFailing) => { runTestFiles(path.resolve(file_path), isDirectory, web3, compilerConfig, (error, totalPassing, totalFailing) => {
if (error) process.exit(1) if (error) process.exit(1)

@ -60,12 +60,12 @@ Commands:
it('remix-tests running a test file', function() { it('remix-tests running a test file', function() {
const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')])
console.log(res.stdout.toString()) // console.log(res.stdout.toString())
// match initial lines // match initial lines
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// match test result // match test result
expect(res.stdout.toString().trim()).to.match(/AssertOkTest/gi) expect(res.stdout.toString().trim()).to.match(/AssertOkTest/)
expect(res.stdout.toString().trim()).to.match(/AssertOkTest okPassTest/) // check if console.log is printed expect(res.stdout.toString().trim()).to.match(/AssertOkTest okPassTest/) // check if console.log is printed
expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
expect(res.stdout.toString().trim()).to.match(/AssertOkTest okFailTest/) // check if console.log is printed expect(res.stdout.toString().trim()).to.match(/AssertOkTest okFailTest/) // check if console.log is printed
@ -79,88 +79,88 @@ Commands:
// it('remix-tests running a test file with custom compiler version', () => { it('remix-tests running a test file with custom compiler version', () => {
// const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.4. Latest version is') expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.4. Latest version is')
// expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.4+commit.3f05b770 ...') expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.4+commit.3f05b770 ...')
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// // match test result // match test result
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/) expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
// // match fail test details // match fail test details
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/) expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
// }) })
//
// it('remix-tests running a test file with unavailable custom compiler version (should fail)', () => { it('remix-tests running a test file with unavailable custom compiler version (should fail)', () => {
// const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('No compiler found in releases with version 1.10.4') expect(res.stdout.toString().trim()).to.contain('No compiler found in releases with version 1.10.4')
// }) })
//
// it('remix-tests running a test file with custom EVM', () => { it('remix-tests running a test file with custom EVM', () => {
// const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('EVM set to petersburg') expect(res.stdout.toString().trim()).to.contain('EVM set to petersburg')
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// // match test result // match test result
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/) expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
// // match fail test details // match fail test details
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/) expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
// }) })
//
// it('remix-tests running a test file by enabling optimization', () => { it('remix-tests running a test file by enabling optimization', () => {
// const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim().includes('Optimization is enabled')) expect(res.stdout.toString().trim().includes('Optimization is enabled'))
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// // match test result // match test result
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/) expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
// // match fail test details // match fail test details
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/) expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
// }) })
//
// it('remix-tests running a test file by enabling optimization and setting runs', () => { it('remix-tests running a test file by enabling optimization and setting runs', () => {
// const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('Optimization is enabled') expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
// expect(res.stdout.toString().trim()).to.contain('Runs set to 300') expect(res.stdout.toString().trim()).to.contain('Runs set to 300')
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// // match test result // match test result
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/) expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
// // match fail test details // match fail test details
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/) expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
// }) })
//
// it('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => { it('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => {
// const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('Optimization should be enabled for runs') expect(res.stdout.toString().trim()).to.contain('Optimization should be enabled for runs')
// }) })
//
// it('remix-tests running a test file with all options', () => { it('remix-tests running a test file with all options', () => {
// const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// // match initial lines // match initial lines
// expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.5. Latest version is') expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.5. Latest version is')
// expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.5+commit.eb77ed08 ...') expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.5+commit.eb77ed08 ...')
// expect(res.stdout.toString().trim()).to.contain('EVM set to istanbul') expect(res.stdout.toString().trim()).to.contain('EVM set to istanbul')
// expect(res.stdout.toString().trim()).to.contain('Optimization is enabled') expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
// expect(res.stdout.toString().trim()).to.contain('Runs set to 250') expect(res.stdout.toString().trim()).to.contain('Runs set to 250')
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/) expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../) expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
// // match test result // match test result
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/) expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/) expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
// // match fail test details // match fail test details
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/) expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
// }) })
}) })
}) })

Loading…
Cancel
Save