|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import * as async from 'async' |
|
|
|
|
import Web3 from 'web3'; |
|
|
|
|
import * as assert from 'assert' |
|
|
|
|
import { Provider } from '@remix-project/remix-simulator' |
|
|
|
|
import { Provider, extend } from '@remix-project/remix-simulator' |
|
|
|
|
|
|
|
|
|
import { compileFileOrFiles } from '../src/compiler' |
|
|
|
|
import { deployAll } from '../src/deployer' |
|
|
|
@ -47,6 +47,7 @@ async function compileAndDeploy(filename: string, callback: Function) { |
|
|
|
|
let sourceASTs: any = {} |
|
|
|
|
await provider.init() |
|
|
|
|
web3.setProvider(provider) |
|
|
|
|
extend(web3) |
|
|
|
|
let compilationData: object |
|
|
|
|
async.waterfall([ |
|
|
|
|
function getAccountList(next: Function): void { |
|
|
|
@ -72,7 +73,7 @@ async function compileAndDeploy(filename: string, callback: Function) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
], function (_err: Error | null | undefined, contracts: any): void { |
|
|
|
|
callback(null, compilationData, contracts, sourceASTs, accounts) |
|
|
|
|
callback(null, compilationData, contracts, sourceASTs, accounts, web3) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -106,8 +107,8 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_0/assert_ok_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
runTest('AssertOkTest', contracts.AssertOkTest, compilationData[filename]['AssertOkTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('AssertOkTest', contracts.AssertOkTest, compilationData[filename]['AssertOkTest'], asts[filename], { accounts, web3 }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -121,12 +122,14 @@ describe('testRunner', () => { |
|
|
|
|
assert.equal(results.failureNum, 1) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const hhLogs1 = [ [ "AssertOkTest", "okPassTest"]] |
|
|
|
|
const hhLogs2 = [ [ "AssertOkTest", "okFailTest"]] |
|
|
|
|
it('should return', () => { |
|
|
|
|
deepEqualExcluding(tests, [ |
|
|
|
|
{ type: 'accountList', value: accounts }, |
|
|
|
|
{ type: 'contract', value: 'AssertOkTest', filename: __dirname + '/examples_0/assert_ok_test.sol' }, |
|
|
|
|
{ type: 'testPass', value: 'Ok pass test', filename: __dirname + '/examples_0/assert_ok_test.sol', context: 'AssertOkTest' }, |
|
|
|
|
{ type: 'testFailure', value: 'Ok fail test', filename: __dirname + '/examples_0/assert_ok_test.sol', errMsg: 'okFailTest fails', context: 'AssertOkTest', assertMethod: 'ok', location: '234:36:0', expected: 'true', returned: 'false'}, |
|
|
|
|
{ type: 'testPass', value: 'Ok pass test', filename: __dirname + '/examples_0/assert_ok_test.sol', context: 'AssertOkTest', hhLogs: hhLogs1 }, |
|
|
|
|
{ type: 'testFailure', value: 'Ok fail test', filename: __dirname + '/examples_0/assert_ok_test.sol', errMsg: 'okFailTest fails', context: 'AssertOkTest', hhLogs: hhLogs2, assertMethod: 'ok', location: '370:36:0', expected: 'true', returned: 'false'}, |
|
|
|
|
|
|
|
|
|
], ['time']) |
|
|
|
|
}) |
|
|
|
@ -136,7 +139,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_0/assert_equal_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('AssertEqualTest', contracts.AssertEqualTest, compilationData[filename]['AssertEqualTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -175,7 +178,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_0/assert_notEqual_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('AssertNotEqualTest', contracts.AssertNotEqualTest, compilationData[filename]['AssertNotEqualTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -214,7 +217,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_0/assert_greaterThan_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('AssertGreaterThanTest', contracts.AssertGreaterThanTest, compilationData[filename]['AssertGreaterThanTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -248,7 +251,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_0/assert_lesserThan_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('AssertLesserThanTest', contracts.AssertLesserThanTest, compilationData[filename]['AssertLesserThanTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -283,7 +286,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_1/simple_storage_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll((done) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => { |
|
|
|
|
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) => { |
|
|
|
|
runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -314,7 +317,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_2/simple_storage_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -344,7 +347,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_3/simple_string_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('StringTest', contracts.StringTest, compilationData[filename]['StringTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -370,7 +373,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_5/test/simple_storage_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('StorageResolveTest', contracts.StorageResolveTest, compilationData[filename]['StorageResolveTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -397,7 +400,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/examples_4/SafeMath_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('SafeMathTest', contracts.SafeMathTest, compilationData[filename]['SafeMathTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -417,7 +420,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/number/number_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('IntegerTest', contracts.IntegerTest, compilationData[filename]['IntegerTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -437,7 +440,7 @@ describe('testRunner', () => { |
|
|
|
|
const filename: string = __dirname + '/various_sender/sender_and_value_test.sol' |
|
|
|
|
|
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('SenderAndValueTest', contracts.SenderAndValueTest, compilationData[filename]['SenderAndValueTest'], asts[filename], { accounts }, testCallback, resultsCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -465,7 +468,7 @@ describe('testRunner', () => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
beforeAll(done => { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) { |
|
|
|
|
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[], web3: any) { |
|
|
|
|
runTest('SenderAndValueTest', undefined, compilationData[filename]['SenderAndValueTest'], asts[filename], { accounts }, testCallback, errorCallback(done)) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|