Unverified Commit 0dcd0957 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1277 from andremedeiros/fix-test-reporter

Update test runner to report accounts via callback
parents 80f1a9ac 5783e74f
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
"remix-lib": "0.4.12", "remix-lib": "0.4.12",
"remix-simulator": "0.1.9-alpha.5", "remix-simulator": "0.1.9-alpha.5",
"remix-solidity": "0.3.15", "remix-solidity": "0.3.15",
"signale": "^1.2.1",
"web3": "1.0.0-beta.36", "web3": "1.0.0-beta.36",
"winston": "^3.0.0" "winston": "^3.0.0"
}, },
......
...@@ -62,15 +62,13 @@ export function runTest (testName, testObject: any, contractDetails: any, opts: ...@@ -62,15 +62,13 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
let timePassed: number = 0 let timePassed: number = 0
let web3 = new Web3() let web3 = new Web3()
const userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-' const accts: TestResultInterface = {
const isBrowser = !(typeof (window) === 'undefined' || userAgent.indexOf(' electron/') > -1) type: 'accountList',
if (!isBrowser) { value: opts.accounts
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(undefined, accts);
const resp: TestResultInterface = { const resp: TestResultInterface = {
type: 'contract', type: 'contract',
value: testName, value: testName,
...@@ -93,7 +91,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts: ...@@ -93,7 +91,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
let startTime = Date.now() let startTime = Date.now()
if (func.constant) { if (func.constant) {
method.call(sendParams).then((result) => { method.call(sendParams).then((result) => {
let time = Math.ceil((Date.now() - startTime) / 1000.0) let time = (Date.now() - startTime) / 1000.0
if (result) { if (result) {
const resp: TestResultInterface = { const resp: TestResultInterface = {
type: 'testPass', type: 'testPass',
...@@ -120,7 +118,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts: ...@@ -120,7 +118,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
} else { } else {
method.send(sendParams).on('receipt', (receipt) => { method.send(sendParams).on('receipt', (receipt) => {
try { 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 topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let testPassed: boolean = false 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