get hash from receipt

pull/3252/head
Aniket-Engg 2 years ago committed by Aniket
parent 26f1f08e67
commit fbe6075d0c
  1. 12
      libs/remix-tests/src/testRunner.ts

@ -379,6 +379,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
}).on('error', async (err) => { }).on('error', async (err) => {
const time: number = (Date.now() - startTime) / 1000.0 const time: number = (Date.now() - startTime) / 1000.0
let errMsg = err.message let errMsg = err.message
let txHash
if (err.reason) errMsg = `transaction reverted with the reason: ${err.reason}` if (err.reason) errMsg = `transaction reverted with the reason: ${err.reason}`
const resp: TestResultInterface = { const resp: TestResultInterface = {
type: 'testFailure', type: 'testFailure',
@ -389,12 +390,13 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
context: testName, context: testName,
web3 web3
} }
if (err.message.includes('Transaction has been reverted by the EVM')) { if (err.receipt) txHash = err.receipt.transactionHash
const txHash = JSON.parse(err.message.replace('Transaction has been reverted by the EVM:', '')).transactionHash else if (err.message.includes('Transaction has been reverted by the EVM')) {
if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(txHash) txHash = JSON.parse(err.message.replace('Transaction has been reverted by the EVM:', '')).transactionHash
if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
resp.debugTxHash = txHash
} }
if (web3.eth && web3.eth.getHHLogsForTx && txHash) hhLogs = await web3.eth.getHHLogsForTx(txHash)
if (hhLogs && hhLogs.length) resp.hhLogs = hhLogs
resp.debugTxHash = txHash
testCallback(undefined, resp) testCallback(undefined, resp)
failureNum += 1 failureNum += 1
timePassed += time timePassed += time

Loading…
Cancel
Save