Use DebugComputation with tests.
This commit is contained in:
parent
ea7f5f8887
commit
1a6bffccdb
|
@ -15,6 +15,10 @@ from vdb.vdb import (
|
||||||
set_evm_opcode_debugger,
|
set_evm_opcode_debugger,
|
||||||
VyperDebugCmd
|
VyperDebugCmd
|
||||||
)
|
)
|
||||||
|
from vdb.eth_tester_debug_backend import (
|
||||||
|
PyEVMDebugBackend,
|
||||||
|
set_debug_info
|
||||||
|
)
|
||||||
from vdb.source_map import (
|
from vdb.source_map import (
|
||||||
produce_source_map
|
produce_source_map
|
||||||
)
|
)
|
||||||
|
@ -22,7 +26,7 @@ from vdb.source_map import (
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def tester():
|
def tester():
|
||||||
t = EthereumTester()
|
t = EthereumTester(backend=PyEVMDebugBackend())
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,10 +50,9 @@ def _get_contract(w3, source_code, *args, **kwargs):
|
||||||
stdout = kwargs['stdout'] if 'stdout' in kwargs else None
|
stdout = kwargs['stdout'] if 'stdout' in kwargs else None
|
||||||
|
|
||||||
source_map = produce_source_map(source_code)
|
source_map = produce_source_map(source_code)
|
||||||
set_evm_opcode_debugger(
|
set_debug_info(source_code, source_map, stdin, stdout)
|
||||||
source_code=source_code, source_map=source_map, stdin=stdin, stdout=stdout
|
import vdb
|
||||||
)
|
setattr(vdb.debug_computation.DebugComputation, 'enable_debug', True)
|
||||||
|
|
||||||
value = kwargs.pop('value', 0)
|
value = kwargs.pop('value', 0)
|
||||||
value_in_eth = kwargs.pop('value_in_eth', 0)
|
value_in_eth = kwargs.pop('value_in_eth', 0)
|
||||||
value = value_in_eth * 10**18 if value_in_eth else value # Handle deploying with an eth value.
|
value = value_in_eth * 10**18 if value_in_eth else value # Handle deploying with an eth value.
|
||||||
|
|
|
@ -11,6 +11,8 @@ class DebugComputation(ByzantiumComputation):
|
||||||
enable_debug = False
|
enable_debug = False
|
||||||
source_code = None
|
source_code = None
|
||||||
source_map = None
|
source_map = None
|
||||||
|
stdin = None
|
||||||
|
stdout = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_debugger(self, computation, line_no):
|
def run_debugger(self, computation, line_no):
|
||||||
|
@ -19,8 +21,8 @@ class DebugComputation(ByzantiumComputation):
|
||||||
line_no=line_no,
|
line_no=line_no,
|
||||||
source_code=self.source_code,
|
source_code=self.source_code,
|
||||||
source_map=self.source_map,
|
source_map=self.source_map,
|
||||||
stdin=None,
|
stdin=self.stdin,
|
||||||
stdout=None
|
stdout=self.stdout
|
||||||
).cmdloop()
|
).cmdloop()
|
||||||
return line_no
|
return line_no
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ class PyEVMDebugBackend(PyEVMBackend):
|
||||||
self.account_keys, self.chain = _setup_tester_chain()
|
self.account_keys, self.chain = _setup_tester_chain()
|
||||||
|
|
||||||
|
|
||||||
def set_debug_info(source_code, source_map):
|
def set_debug_info(source_code, source_map, stdin=None, stdout=None):
|
||||||
setattr(DebugComputation, 'source_code', source_code)
|
setattr(DebugComputation, 'source_code', source_code)
|
||||||
setattr(DebugComputation, 'source_map', source_map)
|
setattr(DebugComputation, 'source_map', source_map)
|
||||||
|
setattr(DebugComputation, 'stdin', stdin)
|
||||||
|
setattr(DebugComputation, 'stdout', stdout)
|
||||||
|
|
Loading…
Reference in New Issue