Use DebugComputation with tests.

This commit is contained in:
Jacques Wagener 2018-10-15 20:35:22 +02:00
parent ea7f5f8887
commit 1a6bffccdb
No known key found for this signature in database
GPG Key ID: C294D1025DA0E923
3 changed files with 15 additions and 8 deletions

View File

@ -15,6 +15,10 @@ from vdb.vdb import (
set_evm_opcode_debugger,
VyperDebugCmd
)
from vdb.eth_tester_debug_backend import (
PyEVMDebugBackend,
set_debug_info
)
from vdb.source_map import (
produce_source_map
)
@ -22,7 +26,7 @@ from vdb.source_map import (
@pytest.fixture(scope="module")
def tester():
t = EthereumTester()
t = EthereumTester(backend=PyEVMDebugBackend())
return t
@ -46,10 +50,9 @@ def _get_contract(w3, source_code, *args, **kwargs):
stdout = kwargs['stdout'] if 'stdout' in kwargs else None
source_map = produce_source_map(source_code)
set_evm_opcode_debugger(
source_code=source_code, source_map=source_map, stdin=stdin, stdout=stdout
)
set_debug_info(source_code, source_map, stdin, stdout)
import vdb
setattr(vdb.debug_computation.DebugComputation, 'enable_debug', True)
value = kwargs.pop('value', 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.

View File

@ -11,6 +11,8 @@ class DebugComputation(ByzantiumComputation):
enable_debug = False
source_code = None
source_map = None
stdin = None
stdout = None
@classmethod
def run_debugger(self, computation, line_no):
@ -19,8 +21,8 @@ class DebugComputation(ByzantiumComputation):
line_no=line_no,
source_code=self.source_code,
source_map=self.source_map,
stdin=None,
stdout=None
stdin=self.stdin,
stdout=self.stdout
).cmdloop()
return line_no

View File

@ -52,6 +52,8 @@ class PyEVMDebugBackend(PyEVMBackend):
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_map', source_map)
setattr(DebugComputation, 'stdin', stdin)
setattr(DebugComputation, 'stdout', stdout)