make tests pass in typescript

pull/7/head
Omkara 6 years ago
parent cd06975f88
commit cffd6cd36f
  1. 7
      remix-tests/dist/runTestFiles.js
  2. 2
      remix-tests/dist/runTestFiles.js.map
  3. 10
      remix-tests/dist/runTestSources.js
  4. 2
      remix-tests/dist/runTestSources.js.map
  5. 3
      remix-tests/dist/testRunner.d.ts
  6. 25
      remix-tests/dist/testRunner.js
  7. 2
      remix-tests/dist/testRunner.js.map
  8. 4
      remix-tests/src/runTestFiles.ts
  9. 2
      remix-tests/src/runTestSources.ts
  10. 4
      remix-tests/src/testRunner.ts
  11. 162
      remix-tests/tests/testRunner.ts

@ -1,8 +1,11 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var async = require("async"); var async = require("async");
var path = require("path"); var path = require("path");
var fs = require("./fs"); var fs = require("./fs");
var runTest = require("./testRunner.js"); var testRunner_1 = __importDefault(require("./testRunner"));
require('colors'); require('colors');
var Compiler = require("./compiler.js"); var Compiler = require("./compiler.js");
var Deployer = require("./deployer.js"); var Deployer = require("./deployer.js");
@ -97,7 +100,7 @@ function runTestFiles(filepath, isDirectory, web3, opts) {
cb(); cb();
}; };
async.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) { async.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) {
runTest(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, testCallback, function (err, result) { testRunner_1.default(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, testCallback, function (err, result) {
if (err) { if (err) {
return cb(err); return cb(err);
} }

@ -1 +1 @@
{"version":3,"file":"runTestFiles.js","sourceRoot":"","sources":["../src/runTestFiles.ts"],"names":[],"mappings":";AAAA,6BAA+B;AAC/B,2BAA6B;AAC7B,yBAA2B;AAC3B,yCAA2C;AAC3C,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEjB,wCAA0C;AAC1C,wCAA0C;AAE1C,SAAS,YAAY,CAAC,QAA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IAAI,YAAY,GAAG,CAAC,EAAE;oBAClB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,EAAC,cAAc,EAAC,aAAa,CAAC,CAAA;iBAC/G;gBACD,IAAI,YAAY,GAAG,CAAC,EAAE;oBAClB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC,EAAC,YAAY,CAAC,CAAA;iBACjE;gBACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBAEf,MAAM,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,KAAK;oBACxB,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,GAAG,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;oBAC1E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;oBACf,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,EAAC,YAAY,CAAC,CAAA;gBAC7D,CAAC,CAAC,CAAA;gBACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBAEf,IAAI,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;QACN,CAAC;KACJ,EAAE;IACH,CAAC,CAAC,CAAA;AACN,CAAC;AAED,iBAAS,YAAY,CAAC"}

@ -2,11 +2,11 @@
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
var async = require("async"); var async_1 = __importDefault(require("async"));
require('colors'); require('colors');
var Compiler = require("./compiler.js"); var Compiler = require("./compiler.js");
var Deployer = require("./deployer.js"); var Deployer = require("./deployer.js");
var runTest = require("./testRunner.js"); var testRunner_1 = __importDefault(require("./testRunner"));
var Web3 = require("web3"); var Web3 = require("web3");
var remix_simulator_1 = __importDefault(require("remix-simulator")); var remix_simulator_1 = __importDefault(require("remix-simulator"));
var createWeb3Provider = function () { var createWeb3Provider = function () {
@ -18,7 +18,7 @@ function runTestSources(contractSources, testCallback, resultCallback, finalCall
opts = opts || {}; opts = opts || {};
var web3 = opts.web3 || createWeb3Provider(); var web3 = opts.web3 || createWeb3Provider();
var accounts = opts.accounts || null; var accounts = opts.accounts || null;
async.waterfall([ async_1.default.waterfall([
function getAccountList(next) { function getAccountList(next) {
if (accounts) if (accounts)
return next(); return next();
@ -73,8 +73,8 @@ function runTestSources(contractSources, testCallback, resultCallback, finalCall
totalTime += result.timePassed; totalTime += result.timePassed;
cb(); cb();
}; };
async.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) { async_1.default.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) {
runTest(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, _testCallback, function (err, result) { testRunner_1.default(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, _testCallback, function (err, result) {
if (err) { if (err) {
return cb(err); return cb(err);
} }

@ -1 +1 @@
{"version":3,"file":"runTestSources.js","sourceRoot":"","sources":["../src/runTestSources.ts"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEjB,wCAA0C;AAC1C,wCAA0C;AAC1C,yCAA2C;AAE3C,2BAA6B;AAC7B,oEAAsC;AAStC,IAAI,kBAAkB,GAAG;IACrB,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;IACrB,IAAI,CAAC,WAAW,CAAC,IAAI,yBAAQ,EAAE,CAAC,CAAA;IAChC,OAAO,IAAI,CAAA;AACf,CAAC,CAAA;AAED,SAAS,cAAc,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI;IACpG,IA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cAAc,CAAC"}

@ -1,2 +1 @@
declare function runTest(testName: any, testObject: any, contractDetails: any, opts: any, testCallback: any, resultsCallback: any): void; export default function runTest(testName: any, testObject: any, contractDetails: any, opts: any, testCallback: Function, resultsCallback: Function): void;
export = runTest;

@ -1,7 +1,18 @@
"use strict"; "use strict";
var async = require("async"); var __importDefault = (this && this.__importDefault) || function (mod) {
var changeCase = require("change-case"); return (mod && mod.__esModule) ? mod : { "default": mod };
var Web3 = require("web3"); };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var async_1 = __importDefault(require("async"));
var changeCase = __importStar(require("change-case"));
var web3_1 = __importDefault(require("web3"));
function getFunctionFullName(signature, methodIdentifiers) { function getFunctionFullName(signature, methodIdentifiers) {
for (var method in methodIdentifiers) { for (var method in methodIdentifiers) {
if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) { if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) {
@ -50,7 +61,7 @@ function runTest(testName, testObject, contractDetails, opts, testCallback, resu
var passingNum = 0; var passingNum = 0;
var failureNum = 0; var failureNum = 0;
var timePassed = 0; var timePassed = 0;
var web3 = new Web3(); var web3 = new web3_1.default();
var userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-'; var userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-';
var isBrowser = !(typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1); var isBrowser = !(typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1);
if (!isBrowser) { if (!isBrowser) {
@ -61,7 +72,7 @@ function runTest(testName, testObject, contractDetails, opts, testCallback, resu
signale.warn('TestsAccounts.getAccount(' + opts.accounts.length + ')'); signale.warn('TestsAccounts.getAccount(' + opts.accounts.length + ')');
} }
testCallback({ type: 'contract', value: testName, filename: testObject.filename }); testCallback({ type: 'contract', value: testName, filename: testObject.filename });
async.eachOfLimit(runList, 1, function (func, index, next) { async_1.default.eachOfLimit(runList, 1, function (func, index, next) {
var sender; var sender;
if (func.signature) { if (func.signature) {
sender = getOverridedSender(contractDetails.userdoc, func.signature, contractDetails.evm.methodIdentifiers); sender = getOverridedSender(contractDetails.userdoc, func.signature, contractDetails.evm.methodIdentifiers);
@ -93,7 +104,7 @@ function runTest(testName, testObject, contractDetails, opts, testCallback, resu
method.send(sendParams).on('receipt', function (receipt) { method.send(sendParams).on('receipt', function (receipt) {
try { try {
var time = Math.ceil((Date.now() - startTime) / 1000.0); var time = Math.ceil((Date.now() - startTime) / 1000.0);
var topic = Web3.utils.sha3('AssertionEvent(bool,string)'); var topic = web3_1.default.utils.sha3('AssertionEvent(bool,string)');
var testPassed = false; var testPassed = false;
for (var i in receipt.events) { for (var i in receipt.events) {
var event_1 = receipt.events[i]; var event_1 = receipt.events[i];
@ -131,5 +142,5 @@ function runTest(testName, testObject, contractDetails, opts, testCallback, resu
}); });
}); });
} }
module.exports = runTest; exports.default = runTest;
//# sourceMappingURL=testRunner.js.map //# sourceMappingURL=testRunner.js.map

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
import async = require('async') import async = require('async')
import path = require('path') import path = require('path')
import fs = require('./fs') import fs = require('./fs')
import runTest = require('./testRunner.js') import runTest from './testRunner'
require('colors') require('colors')
import Compiler = require('./compiler.js') import Compiler = require('./compiler.js')
@ -130,4 +130,4 @@ function runTestFiles(filepath, isDirectory, web3, opts) {
}) })
} }
export = runTestFiles; export = runTestFiles;

@ -3,7 +3,7 @@ require('colors')
import Compiler = require('./compiler.js') import Compiler = require('./compiler.js')
import Deployer = require('./deployer.js') import Deployer = require('./deployer.js')
import runTest = require('./testRunner.js') import runTest from './testRunner'
import Web3 = require('web3') import Web3 = require('web3')
import Provider from 'remix-simulator' import Provider from 'remix-simulator'

@ -53,7 +53,7 @@ function createRunList (jsonInterface) {
return runList return runList
} }
function runTest (testName, testObject, contractDetails, opts, testCallback, resultsCallback) { export default function runTest (testName, testObject: any, contractDetails: any, opts: any, testCallback: Function, resultsCallback: Function) {
let runList = createRunList(testObject._jsonInterface) let runList = createRunList(testObject._jsonInterface)
let passingNum = 0 let passingNum = 0
@ -143,5 +143,3 @@ function runTest (testName, testObject, contractDetails, opts, testCallback, res
}) })
}) })
} }
export = runTest

@ -1,11 +1,11 @@
import async from 'async' import * as async from 'async'
import Web3 from 'web3' import Web3 from 'web3'
import * as assert from 'assert' import * as assert from 'assert'
import { Provider } from 'remix-simulator' import { Provider } from 'remix-simulator'
let Compiler = require('../src/compiler.js') let Compiler = require('../src/compiler.js')
let Deployer = require('../src/deployer.js') let Deployer = require('../src/deployer.js')
let TestRunner = require('../src/testRunner.ts') import runTest from '../dist/testRunner.js'
interface Results { interface Results {
passingNum: number, passingNum: number,
@ -13,51 +13,50 @@ interface Results {
} }
function compileAndDeploy (filename: string, callback: Function) { function compileAndDeploy (filename: string, callback: Function) {
let web3 = new Web3() let web3: Web3 = new Web3()
web3.setProvider(new Provider()) web3.setProvider(new Provider())
let compilationData: Object let compilationData: object
let accounts: Object let accounts: object
async.waterfall([ async.waterfall([
function getAccountList (next: Function) { function getAccountList(next: Function): void {
web3.eth.getAccounts((_err: Error, _accounts: Object) => { web3.eth.getAccounts((_err: Error, _accounts: object) => {
accounts = _accounts accounts = _accounts
next(_err) next(_err)
}) })
}, },
function compile (next: Function) { function compile(next: Function) {
Compiler.compileFileOrFiles(filename, false, {accounts}, next) Compiler.compileFileOrFiles(filename, false, {accounts}, next)
}, },
function deployAllContracts (compilationResult, next) { function deployAllContracts(compilationResult: object, next: Function): void {
try { try {
compilationData = compilationResult compilationData = compilationResult
Deployer.deployAll(compilationResult, web3, next) Deployer.deployAll(compilationResult, web3, next)
next()
} catch(e) { } catch(e) {
throw e throw e
} }
} }
], function (_err, contracts) { ], function(_err: Error | null | undefined, contracts: any): void {
callback(null, compilationData, contracts, accounts) callback(null, compilationData, contracts, accounts)
}) })
} }
describe('testRunner', function () { describe('testRunner', () => {
describe('#runTest', function() { describe('#runTest', () => {
describe('test with beforeAll', function () { describe('test with beforeAll', () => {
let filename = 'tests/examples_1/simple_storage_test.sol' let filename = 'tests/examples_1/simple_storage_test.sol'
let tests:any[] = [], results:Results; let tests:any[] = [], results:Results;
before(function (done) { before((done) => {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { compileAndDeploy(filename, (_err: Error, compilationData: object, contracts: any, accounts: object) => {
var testCallback = function (test) { var testCallback = (test: object) => {
tests.push(test) tests.push(test)
} }
var resultsCallback = function (_err, _results) { var resultsCallback = (_err: Error, _results: Results) => {
results = _results results = _results
done() done()
} }
TestRunner.runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], { accounts }, testCallback, resultsCallback) runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], { accounts }, testCallback, resultsCallback)
}) })
}) })
@ -79,130 +78,5 @@ function compileAndDeploy (filename: string, callback: Function) {
]) ])
}) })
}) })
describe('test with beforeEach', function () {
let filename = 'tests/examples_2/simple_storage_test.sol'
let tests:any[] = [], results:Results;
before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) {
var testCallback = function (test) {
tests.push(test)
}
var resultsCallback = function (_err, _results) {
results = _results
done()
}
TestRunner.runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], { accounts }, testCallback, resultsCallback)
})
})
it('should 2 passing tests', function () {
assert.equal(results.passingNum, 2)
})
it('should 0 failing tests', function () {
assert.equal(results.failureNum, 0)
})
it('should returns 3 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest', filename: 'tests/examples_2/simple_storage_test.sol' },
{ type: 'testPass', value: 'Initial value should be100', time: 1, context: 'MyTest' },
{ type: 'testPass', value: 'Initial value should be200', time: 1, context: 'MyTest' }
])
})
})
// Test string equality
describe('test string equality', function () {
let filename = 'tests/examples_3/simple_string_test.sol'
let tests:any[] = [], results:Results;
before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) {
var testCallback = function (test) {
tests.push(test)
}
var resultsCallback = function (_err, _results) {
results = _results
done()
}
TestRunner.runTest('StringTest', contracts.StringTest, compilationData[filename]['StringTest'], { accounts }, testCallback, resultsCallback)
TestRunner.runTest('StringTest2', contracts.StringTest2, compilationData[filename]['StringTest2'], { accounts }, testCallback, resultsCallback)
})
})
it('should 2 passing tests', function () {
assert.equal(results.passingNum, 2)
})
it('should 1 failing tests', function () {
assert.equal(results.failureNum, 1)
})
it('should returns 3 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'StringTest', filename: 'tests/examples_3/simple_string_test.sol' },
{ type: 'testFailure', value: 'Value should be hello world', time: 1, context: 'StringTest', "errMsg": "initial value is not correct" },
{ type: 'testPass', value: 'Value should not be hello wordl', time: 1, context: 'StringTest' },
{ type: 'testPass', value: 'Initial value should be hello', time: 1, context: 'StringTest' },
])
})
})
// Test signed/unsigned integer weight
describe('test number weight', function () {
let filename = 'tests/number/number_test.sol'
let tests:any[] = [], results:Results;
before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) {
var testCallback = function (test) {
tests.push(test)
}
var resultsCallback = function (_err, _results) {
results = _results
done()
}
TestRunner.runTest('IntegerTest', contracts.IntegerTest, compilationData[filename]['IntegerTest'], { accounts }, testCallback, resultsCallback)
})
})
it('should have 6 passing tests', function () {
assert.equal(results.passingNum, 6)
})
it('should have 2 failing tests', function () {
assert.equal(results.failureNum, 2)
})
})
// Test Transaction with different sender
describe('various sender', function () {
let filename = 'tests/various_sender/sender_test.sol'
let tests:any[] = [], results:Results;
before(function (done) {
compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) {
var testCallback = function (test) {
tests.push(test)
}
var resultsCallback = function (_err, _results) {
results = _results
done()
}
TestRunner.runTest('SenderTest', contracts.SenderTest, compilationData[filename]['SenderTest'], { accounts }, testCallback, resultsCallback)
})
})
it('should have 4 passing tests', function () {
assert.equal(results.passingNum, 4)
})
it('should have 1 failing tests', function () {
assert.equal(results.failureNum, 0)
})
})
}) })
}) })

Loading…
Cancel
Save