Fix failing debugger tests

pull/453/head
ioedeveloper 4 years ago
parent c4e5597252
commit 948bb7eee2
  1. 16
      apps/remix-ide-e2e/src/tests/debugger.test.ts
  2. 2
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx
  3. 52
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/step-detail.tsx
  4. 67
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx
  5. 20
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx

@ -42,8 +42,10 @@ module.exports = {
.waitForElementVisible('*[data-id="slider"]') .waitForElementVisible('*[data-id="slider"]')
.click('*[data-id="slider"]') .click('*[data-id="slider"]')
.setValue('*[data-id="slider"]', '50') .setValue('*[data-id="slider"]', '50')
.assert.containsText('*[data-id="solidityLocals"]', 'no locals') .pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n92') .click('*[data-id="dropdownPanelSolidityLocals"]')
.assert.containsText('*[data-id="solidityLocals"]', 'No data available')
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n91')
}, },
'Should step back and forward transaction': function (browser: NightwatchBrowser) { 'Should step back and forward transaction': function (browser: NightwatchBrowser) {
@ -51,12 +53,12 @@ module.exports = {
.waitForElementPresent('*[data-id="buttonNavigatorIntoBack"]') .waitForElementPresent('*[data-id="buttonNavigatorIntoBack"]')
.scrollAndClick('*[data-id="buttonNavigatorIntoBack"]') .scrollAndClick('*[data-id="buttonNavigatorIntoBack"]')
.pause(2000) .pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n91') .assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n90')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n91') .assert.containsText('*[data-id="stepdetail"]', 'execution step:\n90')
.click('*[data-id="buttonNavigatorIntoForward"]') .click('*[data-id="buttonNavigatorIntoForward"]')
.pause(2000) .pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n92') .assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n91')
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n92') .assert.containsText('*[data-id="stepdetail"]', 'execution step:\n91')
}, },
'Should jump through breakpoints': function (browser: NightwatchBrowser) { 'Should jump through breakpoints': function (browser: NightwatchBrowser) {
@ -188,7 +190,7 @@ const sources = [
'browser/blah.sol': { 'browser/blah.sol': {
content: ` content: `
pragma solidity >=0.7.0 <0.8.0; pragma solidity >=0.7.0 <0.8.0;
contract Kickstarter { contract Kickstarter {
enum State { Started, Completed } enum State { Started, Completed }

@ -141,7 +141,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => {
<div className="border rounded px-1 mt-1 bg-light"> <div className="border rounded px-1 mt-1 bg-light">
<div className="py-0 px-1 title"> <div className="py-0 px-1 title">
<div className={state.toggleDropdown ? 'icon fas fa-caret-down' : 'icon fas fa-caret-right'} onClick={handleToggle}></div> <div className={state.toggleDropdown ? 'icon fas fa-caret-down' : 'icon fas fa-caret-right'} onClick={handleToggle}></div>
<div className="name" onClick={handleToggle}>{dropdownName}</div><span className="nameDetail" onClick={handleToggle}>{ header }</span> <div className="name" data-id={`dropdownPanel${dropdownName.split(' ').join('')}`} onClick={handleToggle}>{dropdownName}</div><span className="nameDetail" onClick={handleToggle}>{ header }</span>
<CopyToClipboard content={state.copiableContent} /> <CopyToClipboard content={state.copiableContent} />
</div> </div>
<div className='dropdownpanel' style={{ display: state.toggleDropdown ? 'block' : 'none' }}> <div className='dropdownpanel' style={{ display: state.toggleDropdown ? 'block' : 'none' }}>

@ -1,56 +1,10 @@
import React, { useState, useEffect } from 'react' import React from 'react'
import DropdownPanel from './dropdown-panel' import DropdownPanel from './dropdown-panel'
export interface StepDetailProps { export const StepDetail = ({ stepDetail }) => {
stepDetail: {
key: string,
value: string,
reset: boolean
}
}
export const StepDetail = (props: StepDetailProps) => {
const { stepDetail } = props
const [detail, setDetail] = useState({
'vm trace step': '-',
'execution step': '-',
'add memory': '',
'gas': '',
'remaining gas': '-',
'loaded address': '-'
})
useEffect(() => {
updateField(stepDetail.key, stepDetail.value, stepDetail.reset)
}, [stepDetail])
const updateField = (key, value, reset) => {
if (!key) return
if (reset) {
setDetail(() => {
return {
'vm trace step': '-',
'execution step': '-',
'add memory': '',
'gas': '',
'remaining gas': '-',
'loaded address': '-'
}
})
} else {
setDetail(prevDetail => {
return {
...prevDetail,
[key]: value
}
})
}
}
return ( return (
<div id='stepdetail' data-id="stepdetail"> <div id='stepdetail' data-id="stepdetail">
<DropdownPanel dropdownName='Step details' calldata={detail || {}} /> <DropdownPanel dropdownName='Step details' calldata={stepDetail || {}} />
</div> </div>
) )
} }

@ -13,9 +13,12 @@ export const VmDebuggerHead = ({ vmDebuggerLogic, ready }) => {
}) })
const [functionPanel, setFunctionPanel] = useState(null) const [functionPanel, setFunctionPanel] = useState(null)
const [stepDetail, setStepDetail] = useState({ const [stepDetail, setStepDetail] = useState({
key: null, 'vm trace step': '-',
value: null, 'execution step': '-',
reset: false 'add memory': '',
'gas': '',
'remaining gas': '-',
'loaded address': '-'
}) })
const [solidityState, setSolidityState] = useState({ const [solidityState, setSolidityState] = useState({
calldata: null, calldata: null,
@ -29,10 +32,14 @@ export const VmDebuggerHead = ({ vmDebuggerLogic, ready }) => {
useEffect(() => { useEffect(() => {
if (vmDebuggerLogic) { if (vmDebuggerLogic) {
vmDebuggerLogic.event.register('codeManagerChanged', (code, address, index) => { vmDebuggerLogic.event.register('codeManagerChanged', (code, address, index) => {
setAsm({ code, address, index }) setAsm(() => {
return { code, address, index }
})
}) })
vmDebuggerLogic.event.register('traceUnloaded', () => { vmDebuggerLogic.event.register('traceUnloaded', () => {
setAsm({ code: [], address: '', index: -1 }) setAsm(() => {
return { code: [], address: '', index: -1 }
})
}) })
vmDebuggerLogic.event.register('functionsStackUpdate', (stack) => { vmDebuggerLogic.event.register('functionsStackUpdate', (stack) => {
if (stack === null) return if (stack === null) return
@ -43,43 +50,67 @@ export const VmDebuggerHead = ({ vmDebuggerLogic, ready }) => {
functions.push(functionDefinitionName + '(' + func.inputs.join(', ') + ')') functions.push(functionDefinitionName + '(' + func.inputs.join(', ') + ')')
} }
setFunctionPanel(functions) setFunctionPanel(() => functions)
}) })
vmDebuggerLogic.event.register('traceUnloaded', () => { vmDebuggerLogic.event.register('traceUnloaded', () => {
setStepDetail({ key: null, value: null, reset: true }) setStepDetail(() => {
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' }
})
}) })
vmDebuggerLogic.event.register('newTraceLoaded', () => { vmDebuggerLogic.event.register('newTraceLoaded', () => {
setStepDetail({ key: null, value: null, reset: true }) setStepDetail(() => {
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' }
})
}) })
vmDebuggerLogic.event.register('traceCurrentStepUpdate', (error, step) => { vmDebuggerLogic.event.register('traceCurrentStepUpdate', (error, step) => {
setStepDetail({ key: 'execution step', value: (error ? '-' : step), reset: false }) setStepDetail(prevState => {
return { ...prevState, 'execution step': (error ? '-' : step) }
})
}) })
vmDebuggerLogic.event.register('traceMemExpandUpdate', (error, addmem) => { vmDebuggerLogic.event.register('traceMemExpandUpdate', (error, addmem) => {
setStepDetail({ key: 'add memory', value: (error ? '-' : addmem), reset: false }) setStepDetail(prevState => {
return { ...prevState, 'add memory': (error ? '-' : addmem) }
})
}) })
vmDebuggerLogic.event.register('traceStepCostUpdate', (error, gas) => { vmDebuggerLogic.event.register('traceStepCostUpdate', (error, gas) => {
setStepDetail({ key: 'gas', value: (error ? '-' : gas), reset: false }) setStepDetail(prevState => {
return { ...prevState, 'gas': (error ? '-' : gas) }
})
}) })
vmDebuggerLogic.event.register('traceCurrentCalledAddressAtUpdate', (error, address) => { vmDebuggerLogic.event.register('traceCurrentCalledAddressAtUpdate', (error, address) => {
setStepDetail({ key: 'loaded address', value: (error ? '-' : address), reset: false }) setStepDetail(prevState => {
return { ...prevState, 'loaded address': (error ? '-' : address) }
})
}) })
vmDebuggerLogic.event.register('traceRemainingGasUpdate', (error, remainingGas) => { vmDebuggerLogic.event.register('traceRemainingGasUpdate', (error, remainingGas) => {
setStepDetail({ key: 'remaining gas', value: (error ? '-' : remainingGas), reset: false }) setStepDetail(prevState => {
return { ...prevState, 'remaining gas': (error ? '-' : remainingGas) }
})
}) })
vmDebuggerLogic.event.register('indexUpdate', (index) => { vmDebuggerLogic.event.register('indexUpdate', (index) => {
setStepDetail({ key: 'vm trace step', value: index, reset: false }) setStepDetail(prevState => {
return { ...prevState, 'vm trace step': index }
})
}) })
vmDebuggerLogic.event.register('solidityState', (calldata) => { vmDebuggerLogic.event.register('solidityState', (calldata) => {
setSolidityState({ ...solidityState, calldata }) setSolidityState(() => {
return { ...solidityState, calldata }
})
}) })
vmDebuggerLogic.event.register('solidityStateMessage', (message) => { vmDebuggerLogic.event.register('solidityStateMessage', (message) => {
setSolidityState({ ...solidityState, message }) setSolidityState(() => {
return { ...solidityState, message }
})
}) })
vmDebuggerLogic.event.register('solidityLocals', (calldata) => { vmDebuggerLogic.event.register('solidityLocals', (calldata) => {
setSolidityLocals({ ...solidityLocals, calldata }) setSolidityLocals(() => {
return { ...solidityLocals, calldata }
})
}) })
vmDebuggerLogic.event.register('solidityLocalsMessage', (message) => { vmDebuggerLogic.event.register('solidityLocalsMessage', (message) => {
setSolidityLocals({ ...solidityLocals, message }) setSolidityLocals(() => {
return { ...solidityLocals, message }
})
}) })
ready() ready()
} }

@ -22,28 +22,32 @@ export const VmDebugger = ({ vmDebuggerLogic, ready }) => {
useEffect(() => { useEffect(() => {
if (vmDebuggerLogic) { if (vmDebuggerLogic) {
vmDebuggerLogic.event.register('traceManagerCallDataUpdate', (calldata) => { vmDebuggerLogic.event.register('traceManagerCallDataUpdate', (calldata) => {
setCalldataPanel(calldata) setCalldataPanel(() => calldata)
}) })
vmDebuggerLogic.event.register('traceManagerMemoryUpdate', (calldata) => { vmDebuggerLogic.event.register('traceManagerMemoryUpdate', (calldata) => {
setMemoryPanel(calldata) setMemoryPanel(() => calldata)
}) })
vmDebuggerLogic.event.register('traceManagerCallStackUpdate', (calldata) => { vmDebuggerLogic.event.register('traceManagerCallStackUpdate', (calldata) => {
setCallStackPanel(calldata) setCallStackPanel(() => calldata)
}) })
vmDebuggerLogic.event.register('traceManagerStackUpdate', (calldata) => { vmDebuggerLogic.event.register('traceManagerStackUpdate', (calldata) => {
setStackPanel(calldata) setStackPanel(() => calldata)
}) })
vmDebuggerLogic.event.register('traceManagerStorageUpdate', (calldata, header) => { vmDebuggerLogic.event.register('traceManagerStorageUpdate', (calldata, header) => {
setStoragePanel({ calldata, header }) setStoragePanel(() => {
return { calldata, header }
})
}) })
vmDebuggerLogic.event.register('traceReturnValueUpdate', (calldata) => { vmDebuggerLogic.event.register('traceReturnValueUpdate', (calldata) => {
setReturnValuesPanel(calldata) setReturnValuesPanel(() => calldata)
}) })
vmDebuggerLogic.event.register('traceAddressesUpdate', (calldata) => { vmDebuggerLogic.event.register('traceAddressesUpdate', (calldata) => {
setFullStoragesChangesPanel({}) setFullStoragesChangesPanel(() => {
return {}
})
}) })
vmDebuggerLogic.event.register('traceStorageUpdate', (calldata) => { vmDebuggerLogic.event.register('traceStorageUpdate', (calldata) => {
setFullStoragesChangesPanel(calldata) setFullStoragesChangesPanel(() => calldata)
}) })
ready() ready()
} }

Loading…
Cancel
Save