fix debugging call in test

pull/4108/head
yann300 1 year ago
parent c741f576c0
commit 91964707c3
  1. 16
      libs/remix-simulator/src/methods/transactions.ts
  2. 7
      libs/remix-simulator/src/provider.ts
  3. 2
      libs/remix-tests/src/testRunner.ts

@ -25,6 +25,7 @@ export class Transactions {
txRunnerVMInstance
txRunnerInstance
TX_INDEX = '0x0' // currently there's always only 1 tx per block, so the transaction index will always be 0x0
comingCallId
constructor (vmContext) {
this.vmContext = vmContext
@ -73,7 +74,8 @@ export class Transactions {
eth_getExecutionResultFromSimulator: this.eth_getExecutionResultFromSimulator.bind(this),
eth_getHHLogsForTx: this.eth_getHHLogsForTx.bind(this),
eth_getHashFromTagBySimulator: this.eth_getHashFromTagBySimulator.bind(this),
eth_callBySimulator: this.eth_callBySimulator.bind(this)
eth_callBySimulator: this.eth_callBySimulator.bind(this),
eth_registerCallId: this.eth_registerCallId.bind(this)
}
}
@ -195,6 +197,11 @@ export class Transactions {
})
}
eth_registerCallId (payload, cb) {
this.comingCallId = payload.params[0]
cb()
}
eth_call (payload, cb) {
// from might be lowercased address (web3)
if (payload.params && payload.params.length > 0 && payload.params[0].from) {
@ -221,7 +228,12 @@ export class Transactions {
returnValue: returnValue
}
// calls are not supposed to return a transaction hash. we do this for keeping track of it and allowing debugging calls.
this.tags[tag] = result.transactionHash
// either the tag is specified as a timestamp in a tx or the caller should call registerCallId before calling the call.
if (tag) this.tags[tag] = result.transactionHash
else if (this.comingCallId) {
this.tags[this.comingCallId] = result.transactionHash
this.comingCallId = null
}
this.vmContext.trackExecResult(hash, execResult)
return cb(null, returnValue)
}

@ -168,4 +168,11 @@ class Web3TestPlugin extends Web3PluginBase {
params: [payload]
})
}
public registerCallId(id) {
return this.requestManager.send({
method: 'eth_registerCallId',
params: [id]
})
}
}

@ -250,7 +250,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
if (func.constant) {
sendParams = {}
const tagTimestamp = 'remix_tests_tag' + Date.now()
sendParams.timestamp = tagTimestamp
if (web3.testPlugin && web3.testPlugin.registerCallId) web3.testPlugin.registerCallId(tagTimestamp)
method.call(sendParams).then(async (result) => {
const time = (Date.now() - startTime) / 1000.0
let tagTxHash

Loading…
Cancel
Save