Commit 0dbd08ed authored by Andre Medeiros's avatar Andre Medeiros

Update test runner to report accounts via callback

This lets the library user decide how that integration works (whether they want to report the accounts or not.) Also, report time more precisely instead of rounding up. Refactored the tests and removed a dependency.
parent 516fd3f0
......@@ -45,7 +45,6 @@
"remix-lib": "0.4.9",
"remix-simulator": "0.1.9-alpha.2",
"remix-solidity": "0.3.12",
"signale": "^1.2.1",
"web3": "1.0.0-beta.36",
"winston": "^3.0.0"
},
......
......@@ -62,15 +62,13 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
let timePassed: number = 0
let web3 = new Web3()
const userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-'
const 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 + ')')
const accts: TestResultInterface = {
type: 'accountList',
value: opts.accounts
}
testCallback(undefined, accts);
const resp: TestResultInterface = {
type: 'contract',
value: testName,
......@@ -93,7 +91,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
let startTime = Date.now()
if (func.constant) {
method.call(sendParams).then((result) => {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
let time = (Date.now() - startTime) / 1000.0
if (result) {
const resp: TestResultInterface = {
type: 'testPass',
......@@ -120,7 +118,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
} else {
method.send(sendParams).on('receipt', (receipt) => {
try {
let time: number = Math.ceil((Date.now() - startTime) / 1000.0)
let time: number = (Date.now() - startTime) / 1000.0
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let testPassed: boolean = false
......
This diff is collapsed.
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