test migrated to typescript

pull/5370/head
Sab94 6 years ago
parent 0e2c6f2bdd
commit 67c5852658
  1. 1
      remix-tests/dist/index.d.ts
  2. 15
      remix-tests/dist/index.js
  3. 1
      remix-tests/dist/index.js.map
  4. 2
      remix-tests/dist/runTestFiles.d.ts
  5. 131
      remix-tests/dist/runTestFiles.js
  6. 1
      remix-tests/dist/runTestFiles.js.map
  7. 2
      remix-tests/dist/runTestSources.d.ts
  8. 106
      remix-tests/dist/runTestSources.js
  9. 1
      remix-tests/dist/runTestSources.js.map
  10. 2
      remix-tests/dist/testRunner.d.ts
  11. 4
      remix-tests/dist/testRunner.js
  12. 1
      remix-tests/dist/testRunner.js.map
  13. 2
      remix-tests/package.json
  14. 10
      remix-tests/src/_index.js
  15. 133
      remix-tests/src/_runTestFiles.js
  16. 107
      remix-tests/src/_runTestSources.js
  17. 149
      remix-tests/src/_testRunner.js
  18. 198
      remix-tests/tests/testRunner.js
  19. 203
      remix-tests/tests/testRunner.ts
  20. 6
      remix-tests/tsconfig.json

@ -0,0 +1 @@
export {};

@ -0,0 +1,15 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var runTestFiles_1 = __importDefault(require("./runTestFiles"));
var runTestSources_1 = __importDefault(require("./runTestSources"));
var testRunner_1 = __importDefault(require("./testRunner"));
module.exports = {
runTestFiles: runTestFiles_1.default,
runTestSources: runTestSources_1.default,
runTest: testRunner_1.default,
assertLibCode: require('../sol/tests.sol.js')
};
//# sourceMappingURL=index.js.map

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,gEAAyC;AACzC,oEAA6C;AAC7C,4DAAkC;AAElC,MAAM,CAAC,OAAO,GAAG;IACf,YAAY,EAAE,sBAAY;IAC1B,cAAc,EAAE,wBAAc;IAC9B,OAAO,EAAE,oBAAO;IAChB,aAAa,EAAE,OAAO,CAAC,qBAAqB,CAAC;CAC9C,CAAA"}

@ -0,0 +1,2 @@
declare function runTestFiles(filepath: any, isDirectory: any, web3: any, opts: any): void;
export = runTestFiles;

@ -0,0 +1,131 @@
"use strict";
var async = require("async");
var path = require("path");
var fs = require("./fs");
var runTest = require("./testRunner.js");
require('colors');
var Compiler = require("./compiler.js");
var Deployer = require("./deployer.js");
function runTestFiles(filepath, isDirectory, web3, opts) {
opts = opts || {};
var Signale = require('signale').Signale;
// signale configuration
var options = {
types: {
result: {
badge: '\t✓',
label: '',
color: 'greenBright'
},
name: {
badge: '\n\t◼',
label: '',
color: 'white'
},
error: {
badge: '\t✘',
label: '',
color: 'redBright'
}
}
};
var signale = new Signale(options);
var accounts = opts.accounts || null;
async.waterfall([
function getAccountList(next) {
if (accounts)
return next(null);
web3.eth.getAccounts(function (_err, _accounts) {
accounts = _accounts;
next(null);
});
},
function compile(next) {
Compiler.compileFileOrFiles(filepath, isDirectory, { accounts: accounts }, next);
},
function deployAllContracts(compilationResult, next) {
Deployer.deployAll(compilationResult, web3, function (err, contracts) {
if (err) {
next(err);
}
next(null, compilationResult, contracts);
});
},
function determineTestContractsToRun(compilationResult, contracts, next) {
var contractsToTest = [];
var contractsToTestDetails = [];
var gatherContractsFrom = function (filename) {
if (filename.indexOf('_test.sol') < 0) {
return;
}
Object.keys(compilationResult[path.basename(filename)]).forEach(function (contractName) {
contractsToTest.push(contractName);
contractsToTestDetails.push(compilationResult[path.basename(filename)][contractName]);
});
};
if (isDirectory) {
fs.walkSync(filepath, function (foundpath) {
gatherContractsFrom(foundpath);
});
}
else {
gatherContractsFrom(filepath);
}
next(null, contractsToTest, contractsToTestDetails, contracts);
},
function runTests(contractsToTest, contractsToTestDetails, contracts, next) {
var totalPassing = 0;
var totalFailing = 0;
var totalTime = 0;
var errors = [];
var testCallback = function (result) {
if (result.type === 'contract') {
signale.name(result.value.white);
}
else if (result.type === 'testPass') {
signale.result(result.value);
}
else if (result.type === 'testFailure') {
signale.result(result.value.red);
errors.push(result);
}
};
var resultsCallback = function (_err, result, cb) {
totalPassing += result.passingNum;
totalFailing += result.failureNum;
totalTime += result.timePassed;
cb();
};
async.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) {
runTest(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, testCallback, function (err, result) {
if (err) {
return cb(err);
}
resultsCallback(null, result, cb);
});
}, function (err) {
if (err) {
return next(err);
}
console.log('\n');
if (totalPassing > 0) {
console.log(('%c ' + totalPassing + ' passing ') + ('%c(' + totalTime + 's)'), 'color: green', 'color: grey');
}
if (totalFailing > 0) {
console.log(('%c ' + totalFailing + ' failing'), 'color: red');
}
console.log('');
errors.forEach(function (error, index) {
console.log(' ' + (index + 1) + ') ' + error.context + ' ' + error.value);
console.log('');
console.log(('%c\t error: ' + error.errMsg), 'color: red');
});
console.log('');
next();
});
}
], function () {
});
}
module.exports = runTestFiles;
//# sourceMappingURL=runTestFiles.js.map

@ -0,0 +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,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI;IACnD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;IACT,IAAA,oCAAO,CAAuB;IACtC,wBAAwB;IACxB,IAAM,OAAO,GAAG;QACZ,KAAK,EAAE;YACH,MAAM,EAAE;gBACJ,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE,aAAa;aACvB;YACD,IAAI,EAAE;gBACF,KAAK,EAAE,OAAO;gBACd,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE,OAAO;aACjB;YACD,KAAK,EAAE;gBACH,KAAK,EAAE,K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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"}

@ -0,0 +1,2 @@
declare function runTestSources(contractSources: any, testCallback: any, resultCallback: any, finalCallback: any, importFileCb: any, opts: any): void;
export = runTestSources;

@ -0,0 +1,106 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var async = require("async");
require('colors');
var Compiler = require("./compiler.js");
var Deployer = require("./deployer.js");
var runTest = require("./testRunner.js");
var Web3 = require("web3");
var remix_simulator_1 = __importDefault(require("remix-simulator"));
var createWeb3Provider = function () {
var web3 = new Web3();
web3.setProvider(new remix_simulator_1.default());
return web3;
};
function runTestSources(contractSources, testCallback, resultCallback, finalCallback, importFileCb, opts) {
opts = opts || {};
var web3 = opts.web3 || createWeb3Provider();
var accounts = opts.accounts || null;
async.waterfall([
function getAccountList(next) {
if (accounts)
return next();
web3.eth.getAccounts(function (_err, _accounts) {
accounts = _accounts;
next();
});
},
function compile(next) {
Compiler.compileContractSources(contractSources, importFileCb, next);
},
function deployAllContracts(compilationResult, next) {
Deployer.deployAll(compilationResult, web3, function (err, contracts) {
if (err) {
next(err);
}
next(null, compilationResult, contracts);
});
},
function determineTestContractsToRun(compilationResult, contracts, next) {
var contractsToTest = [];
var contractsToTestDetails = [];
var _loop_1 = function (filename) {
if (filename.indexOf('_test.sol') < 0) {
return "continue";
}
Object.keys(compilationResult[filename]).forEach(function (contractName) {
contractsToTestDetails.push(compilationResult[filename][contractName]);
contractsToTest.push(contractName);
});
};
for (var filename in compilationResult) {
_loop_1(filename);
}
next(null, contractsToTest, contractsToTestDetails, contracts);
},
function runTests(contractsToTest, contractsToTestDetails, contracts, next) {
var totalPassing = 0;
var totalFailing = 0;
var totalTime = 0;
var errors = [];
var _testCallback = function (result) {
if (result.type === 'testFailure') {
errors.push(result);
}
testCallback(result);
};
var _resultsCallback = function (_err, result, cb) {
resultCallback(_err, result, function () { });
totalPassing += result.passingNum;
totalFailing += result.failureNum;
totalTime += result.timePassed;
cb();
};
async.eachOfLimit(contractsToTest, 1, function (contractName, index, cb) {
runTest(contractName, contracts(contractName), contractsToTestDetails[index], { accounts: accounts }, _testCallback, function (err, result) {
if (err) {
return cb(err);
}
_resultsCallback(null, result, cb);
});
}, function (err) {
if (err) {
return next(err);
}
var finalResults = {
totalPassing: 0,
totalFailing: 0,
totalTime: 0,
errors: [],
};
finalResults.totalPassing = totalPassing || 0;
finalResults.totalFailing = totalFailing || 0;
finalResults.totalTime = totalTime || 0;
finalResults.errors = [];
errors.forEach(function (error, _index) {
finalResults.errors.push({ context: error.context, value: error.value, message: error.errMsg });
});
next(null, finalResults);
});
}
], finalCallback);
}
module.exports = runTestSources;
//# sourceMappingURL=runTestSources.js.map

@ -0,0 +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,kB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AAC;AACD,iBAAS,cAAc,CAAC"}

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

@ -1,5 +1,4 @@
"use strict";
exports.__esModule = true;
var async = require("async");
var changeCase = require("change-case");
var Web3 = require("web3");
@ -132,4 +131,5 @@ function runTest(testName, testObject, contractDetails, opts, testCallback, resu
});
});
}
exports.runTest = runTest;
module.exports = runTest;
//# sourceMappingURL=testRunner.js.map

File diff suppressed because one or more lines are too long

@ -52,6 +52,8 @@
"yo-yoify": "latest"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.21",
"babel-preset-es2017": "^6.24.1",
"mocha": "^5.1.0",
"standard": "^10.0.3",

@ -1,10 +0,0 @@
const runTestFiles = require('./runTestFiles.js')
const runTestSources = require('./runTestSources.js')
const TestRunner = require('./testRunner.js')
module.exports = {
runTestFiles: runTestFiles,
runTestSources: runTestSources,
runTest: TestRunner.runTest,
assertLibCode: require('../sol/tests.sol.js')
}

@ -1,133 +0,0 @@
const async = require('async')
const path = require('path')
const fs = require('./fs')
const TestRunner = require('./testRunner.js')
require('colors')
let Compiler = require('./compiler.js')
let Deployer = require('./deployer.js')
const runTestFiles = function (filepath, isDirectory, web3, opts) {
opts = opts || {}
const { Signale } = require('signale')
// signale configuration
const options = {
types: {
result: {
badge: '\t✓',
label: '',
color: 'greenBright'
},
name: {
badge: '\n\t◼',
label: '',
color: 'white'
},
error: {
badge: '\t✘',
label: '',
color: 'redBright'
}
}
}
const signale = new Signale(options)
let accounts = opts.accounts || null
async.waterfall([
function getAccountList (next) {
if (accounts) return next(null)
web3.eth.getAccounts((_err, _accounts) => {
accounts = _accounts
next(null)
})
},
function compile (next) {
Compiler.compileFileOrFiles(filepath, isDirectory, { accounts }, next)
},
function deployAllContracts (compilationResult, next) {
Deployer.deployAll(compilationResult, web3, function (err, contracts) {
if (err) {
next(err)
}
next(null, compilationResult, contracts)
})
},
function determineTestContractsToRun (compilationResult, contracts, next) {
let contractsToTest = []
let contractsToTestDetails = []
const gatherContractsFrom = (filename) => {
if (filename.indexOf('_test.sol') < 0) {
return
}
Object.keys(compilationResult[path.basename(filename)]).forEach(contractName => {
contractsToTest.push(contractName)
contractsToTestDetails.push(compilationResult[path.basename(filename)][contractName])
})
}
if (isDirectory) {
fs.walkSync(filepath, foundpath => {
gatherContractsFrom(foundpath)
})
} else {
gatherContractsFrom(filepath)
}
next(null, contractsToTest, contractsToTestDetails, contracts)
},
function runTests (contractsToTest, contractsToTestDetails, contracts, next) {
let totalPassing = 0
let totalFailing = 0
let totalTime = 0
let errors = []
var testCallback = function (result) {
if (result.type === 'contract') {
signale.name(result.value.white)
} else if (result.type === 'testPass') {
signale.result(result.value)
} else if (result.type === 'testFailure') {
signale.result(result.value.red)
errors.push(result)
}
}
var resultsCallback = function (_err, result, cb) {
totalPassing += result.passingNum
totalFailing += result.failureNum
totalTime += result.timePassed
cb()
}
async.eachOfLimit(contractsToTest, 1, (contractName, index, cb) => {
TestRunner.runTest(contractName, contracts[contractName], contractsToTestDetails[index], { accounts }, testCallback, (err, result) => {
if (err) {
return cb(err)
}
resultsCallback(null, result, cb)
})
}, function (err, _results) {
if (err) {
return next(err)
}
console.log('\n')
if (totalPassing > 0) {
console.log((' ' + totalPassing + ' passing ').green + ('(' + totalTime + 's)').grey)
}
if (totalFailing > 0) {
console.log((' ' + totalFailing + ' failing').red)
}
console.log('')
errors.forEach((error, index) => {
console.log(' ' + (index + 1) + ') ' + error.context + ' ' + error.value)
console.log('')
console.log(('\t error: ' + error.errMsg).red)
})
console.log('')
next()
})
}
], function () {
})
}
module.exports = runTestFiles

@ -1,107 +0,0 @@
const async = require('async')
require('colors')
let Compiler = require('./compiler.js')
let Deployer = require('./deployer.js')
let TestRunner = require('./testRunner.js')
const Web3 = require('web3')
const Provider = require('remix-simulator').Provider
var createWeb3Provider = function () {
let web3 = new Web3()
web3.setProvider(new Provider())
return web3
}
const runTestSources = function (contractSources, testCallback, resultCallback, finalCallback, importFileCb, opts) {
opts = opts || {}
let web3 = opts.web3 || createWeb3Provider()
let accounts = opts.accounts || null
async.waterfall([
function getAccountList (next) {
if (accounts) return next()
web3.eth.getAccounts((_err, _accounts) => {
accounts = _accounts
next()
})
},
function compile (next) {
Compiler.compileContractSources(contractSources, importFileCb, next)
},
function deployAllContracts (compilationResult, next) {
Deployer.deployAll(compilationResult, web3, function (err, contracts) {
if (err) {
next(err)
}
next(null, compilationResult, contracts)
})
},
function determineTestContractsToRun (compilationResult, contracts, next) {
let contractsToTest = []
let contractsToTestDetails = []
for (let filename in compilationResult) {
if (filename.indexOf('_test.sol') < 0) {
continue
}
Object.keys(compilationResult[filename]).forEach(contractName => {
contractsToTestDetails.push(compilationResult[filename][contractName])
contractsToTest.push(contractName)
})
}
next(null, contractsToTest, contractsToTestDetails, contracts)
},
function runTests (contractsToTest, contractsToTestDetails, contracts, next) {
let totalPassing = 0
let totalFailing = 0
let totalTime = 0
let errors = []
var _testCallback = function (result) {
if (result.type === 'testFailure') {
errors.push(result)
}
testCallback(result)
}
var _resultsCallback = function (_err, result, cb) {
resultCallback(_err, result, () => {})
totalPassing += result.passingNum
totalFailing += result.failureNum
totalTime += result.timePassed
cb()
}
async.eachOfLimit(contractsToTest, 1, (contractName, index, cb) => {
TestRunner.runTest(contractName, contracts[contractName], contractsToTestDetails[index], { accounts }, _testCallback, (err, result) => {
if (err) {
return cb(err)
}
_resultsCallback(null, result, cb)
})
}, function (err, _results) {
if (err) {
return next(err)
}
let finalResults = {}
finalResults.totalPassing = totalPassing || 0
finalResults.totalFailing = totalFailing || 0
finalResults.totalTime = totalTime || 0
finalResults.errors = []
errors.forEach((error, _index) => {
finalResults.errors.push({context: error.context, value: error.value, message: error.errMsg})
})
next(null, finalResults)
})
}
], finalCallback)
}
module.exports = runTestSources

@ -1,149 +0,0 @@
var async = require('async')
var changeCase = require('change-case')
var Web3 = require('web3')
function getFunctionFullName (signature, methodIdentifiers) {
for (var method in methodIdentifiers) {
if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) {
return method
}
}
return null
}
function getOverridedSender (userdoc, signature, methodIdentifiers) {
let fullName = getFunctionFullName(signature, methodIdentifiers)
let match = /sender: account-+(\d)/g
let accountIndex = userdoc.methods[fullName] ? match.exec(userdoc.methods[fullName].notice) : null
return fullName && accountIndex ? accountIndex[1] : null
}
function getAvailableFunctions (jsonInterface) {
return jsonInterface.reverse().filter((x) => x.type === 'function').map((x) => x.name)
}
function getTestFunctions (jsonInterface) {
let specialFunctions = ['beforeAll', 'beforeEach', 'afterAll', 'afterEach']
return jsonInterface.filter((x) => specialFunctions.indexOf(x.name) < 0 && x.type === 'function')
}
function createRunList (jsonInterface) {
let availableFunctions = getAvailableFunctions(jsonInterface)
let testFunctions = getTestFunctions(jsonInterface)
let runList = []
if (availableFunctions.indexOf('beforeAll') >= 0) {
runList.push({name: 'beforeAll', type: 'internal', constant: false})
}
for (let func of testFunctions) {
if (availableFunctions.indexOf('beforeEach') >= 0) {
runList.push({name: 'beforeEach', type: 'internal', constant: false})
}
runList.push({name: func.name, signature: func.signature, type: 'test', constant: func.constant})
if (availableFunctions.indexOf('afterEach') >= 0) {
runList.push({name: 'afterEach', type: 'internal', constant: false})
}
}
if (availableFunctions.indexOf('afterAll') >= 0) {
runList.push({name: 'afterAll', type: 'internal', constant: false})
}
return runList
}
function runTest (testName, testObject, contractDetails, opts, testCallback, resultsCallback) {
let runList = createRunList(testObject._jsonInterface)
let passingNum = 0
let failureNum = 0
let timePassed = 0
let web3 = new Web3()
var userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-'
var isBrowser = !(typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1)
if (!isBrowser) {
let signale = require('signale')
signale.warn('DO NOT TRY TO ACCESS (IN YOUR SOLIDITY TEST) AN ACCOUNT GREATER THAN THE LENGTH OF THE FOLLOWING ARRAY (' + opts.accounts.length + ') :')
signale.warn(opts.accounts)
signale.warn('e.g: the following code won\'t work in the current context:')
signale.warn('TestsAccounts.getAccount(' + opts.accounts.length + ')')
}
testCallback({type: 'contract', value: testName, filename: testObject.filename})
async.eachOfLimit(runList, 1, function (func, index, next) {
let sender
if (func.signature) {
sender = getOverridedSender(contractDetails.userdoc, func.signature, contractDetails.evm.methodIdentifiers)
if (opts.accounts) {
sender = opts.accounts[sender]
}
}
let sendParams
if (sender) sendParams = { from: sender }
let method = testObject.methods[func.name].apply(testObject.methods[func.name], [])
let startTime = Date.now()
if (func.constant) {
method.call(sendParams).then((result) => {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
if (result) {
testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time, context: testName})
passingNum += 1
timePassed += time
} else {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: 'function returned false', context: testName})
failureNum += 1
}
next()
})
} else {
method.send(sendParams).on('receipt', function (receipt) {
try {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let testPassed = false
for (let i in receipt.events) {
let event = receipt.events[i]
if (event.raw.topics.indexOf(topic) >= 0) {
var testEvent = web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data)
if (!testEvent[0]) {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: testEvent[1], context: testName})
failureNum += 1
return next()
}
testPassed = true
}
}
if (testPassed) {
testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time, context: testName})
passingNum += 1
}
return next()
} catch (err) {
console.log('error!')
console.dir(err)
return next(err)
}
}).on('error', function (err) {
console.error(err)
next(err)
})
}
}, function (error) {
resultsCallback(error, {
passingNum: passingNum,
failureNum: failureNum,
timePassed: timePassed
})
})
}
module.exports = {
runTest: runTest
}

@ -1,198 +0,0 @@
const async = require('async')
const Web3 = require('web3')
const assert = require('assert')
let Compiler = require('../src/compiler.js')
let Deployer = require('../src/deployer.js')
let TestRunner = require('../src/testRunner.js')
const Provider = require('remix-simulator').Provider
function compileAndDeploy (filename, callback) {
let web3 = new Web3()
web3.setProvider(new Provider())
let compilationData
let accounts
async.waterfall([
function getAccountList (next) {
web3.eth.getAccounts((_err, _accounts) => {
accounts = _accounts
next(_err)
})
},
function compile (next) {
Compiler.compileFileOrFiles(filename, false, {accounts}, next)
},
function deployAllContracts (compilationResult, next) {
compilationData = compilationResult
Deployer.deployAll(compilationResult, web3, next)
}
], function (_err, contracts) {
callback(null, compilationData, contracts, accounts)
})
}
describe('testRunner', function () {
describe('#runTest', function() {
describe('test with beforeAll', function () {
let filename = 'tests/examples_1/simple_storage_test.sol'
let tests = [], 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 1 passing test', function () {
assert.equal(results.passingNum, 2)
})
it('should 1 failing test', function () {
assert.equal(results.failureNum, 2)
})
it('should returns 5 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest', filename: 'tests/examples_1/simple_storage_test.sol' },
{ type: 'testFailure', value: 'Should trigger one fail', time: 1, context: 'MyTest', errMsg: 'the test 1 fails' },
{ type: 'testPass', value: 'Should trigger one pass', time: 1, context: 'MyTest'},
{ type: 'testPass', value: 'Initial value should be100', time: 1, context: 'MyTest' },
{ type: 'testFailure', value: 'Initial value should be200', time: 1, context: 'MyTest', errMsg: 'function returned false' }
])
})
})
describe('test with beforeEach', function () {
let filename = 'tests/examples_2/simple_storage_test.sol'
let tests = [], 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 = [], 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 = [], 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 = [], 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)
})
})
})
})

@ -0,0 +1,203 @@
import async = require('async')
import Web3 = require('web3')
import assert = require('assert')
let Compiler = require('../src/compiler.js')
let Deployer = require('../src/deployer.js')
let TestRunner = require('../src/testRunner.ts')
const Provider = require('remix-simulator').Provider
interface Results {
passingNum: number,
failureNum: number,
}
function compileAndDeploy (filename, callback) {
let web3 = new Web3()
web3.setProvider(new Provider())
let compilationData
let accounts
async.waterfall([
function getAccountList (next) {
web3.eth.getAccounts((_err, _accounts) => {
accounts = _accounts
next(_err)
})
},
function compile (next) {
Compiler.compileFileOrFiles(filename, false, {accounts}, next)
},
function deployAllContracts (compilationResult, next) {
compilationData = compilationResult
Deployer.deployAll(compilationResult, web3, next)
}
], function (_err, contracts) {
callback(null, compilationData, contracts, accounts)
})
}
describe('testRunner', function () {
describe('#runTest', function() {
describe('test with beforeAll', function () {
let filename = 'tests/examples_1/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 1 passing test', function () {
assert.equal(results.passingNum, 2)
})
it('should 1 failing test', function () {
assert.equal(results.failureNum, 2)
})
it('should returns 5 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest', filename: 'tests/examples_1/simple_storage_test.sol' },
{ type: 'testFailure', value: 'Should trigger one fail', time: 1, context: 'MyTest', errMsg: 'the test 1 fails' },
{ type: 'testPass', value: 'Should trigger one pass', time: 1, context: 'MyTest'},
{ type: 'testPass', value: 'Initial value should be100', time: 1, context: 'MyTest' },
{ type: 'testFailure', value: 'Initial value should be200', time: 1, context: 'MyTest', errMsg: 'function returned false' }
])
})
})
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)
})
})
})
})

@ -1,4 +1,5 @@
{
"include": ["src"],
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
@ -16,7 +17,10 @@
"paths": { "remix-tests": ["./"] }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"typeRoots": ["node_modules/@types"], /* List of folders to include type definitions from. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"types": [
"mocha",
"node"
],
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
}

Loading…
Cancel
Save