fixed empty hhLogs array in result

pull/1664/head
Admin 3 years ago committed by Aniket
parent f74c647a56
commit 5c0ca32d3a
  1. 13
      libs/remix-tests/src/testRunner.ts

@ -251,7 +251,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
method.call(sendParams).then(async (result) => { method.call(sendParams).then(async (result) => {
const time = (Date.now() - startTime) / 1000.0 const time = (Date.now() - startTime) / 1000.0
let tagTxHash let tagTxHash
let hhLogs
if (web3.eth && web3.eth.getHashFromTagBySimulator) tagTxHash = await web3.eth.getHashFromTagBySimulator(tagTimestamp) if (web3.eth && web3.eth.getHashFromTagBySimulator) tagTxHash = await web3.eth.getHashFromTagBySimulator(tagTimestamp)
if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(tagTxHash) if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(tagTxHash)
if (result) { if (result) {
@ -262,7 +261,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
time: time, time: time,
context: testName context: testName
} }
if (hhLogs) resp.hhLogs = hhLogs if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
testCallback(undefined, resp) testCallback(undefined, resp)
passingNum += 1 passingNum += 1
timePassed += time timePassed += time
@ -275,7 +274,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
errMsg: 'function returned false', errMsg: 'function returned false',
context: testName context: testName
} }
if (hhLogs) resp.hhLogs = hhLogs if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
testCallback(undefined, resp) testCallback(undefined, resp)
failureNum += 1 failureNum += 1
timePassed += time timePassed += time
@ -325,7 +324,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
location, location,
web3 web3
} }
if (hhLogs) resp.hhLogs = hhLogs if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
testCallback(undefined, resp) testCallback(undefined, resp)
failureNum += 1 failureNum += 1
timePassed += time timePassed += time
@ -344,11 +343,11 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
time: time, time: time,
context: testName context: testName
} }
if (hhLogs) resp.hhLogs = hhLogs if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
testCallback(undefined, resp) testCallback(undefined, resp)
passingNum += 1 passingNum += 1
timePassed += time timePassed += time
} else if (hhLogs) { } else if (hhLogs && hhLogs.length) {
const resp: TestResultInterface = { const resp: TestResultInterface = {
type: 'logOnly', type: 'logOnly',
value: changeCase.sentenceCase(func.name), value: changeCase.sentenceCase(func.name),
@ -380,7 +379,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
if (err.message.includes('Transaction has been reverted by the EVM')) { if (err.message.includes('Transaction has been reverted by the EVM')) {
const txHash = JSON.parse(err.message.replace('Transaction has been reverted by the EVM:', '')).transactionHash const txHash = JSON.parse(err.message.replace('Transaction has been reverted by the EVM:', '')).transactionHash
if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(txHash) if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(txHash)
if (hhLogs) resp.hhLogs = hhLogs if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
} }
testCallback(undefined, resp) testCallback(undefined, resp)
failureNum += 1 failureNum += 1

Loading…
Cancel
Save