Skip to content

Commit

Permalink
add pytest-pdb hook
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jun 13, 2023
1 parent 4835825 commit ca31d2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def __init__(self):
def get_gas_price(self):
return self._gas_price or 0

def _restore_journal_state_from_computation(self, computation):
def _restore_journal_state_from_computation(self, computation=None):
computation = computation or self._computation
db = self.vm.state._account_db
(
(
Expand Down Expand Up @@ -577,6 +578,8 @@ def deploy_code(
self.vm.state, msg, tx_ctx
)

self._computation = c

if c.is_error:
raise c.error

Expand Down Expand Up @@ -625,7 +628,9 @@ class FakeMessage(Message): # Message object with settable attrs
msg._contract = contract # type: ignore
origin = sender # XXX: consider making this parametrizable
tx_ctx = BaseTransactionContext(origin=origin, gas_price=self.get_gas_price())
return self.vm.state.computation_class.apply_message(self.vm.state, msg, tx_ctx)
ret = self.vm.state.computation_class.apply_message(self.vm.state, msg, tx_ctx)
self._computation = ret
return ret

# function to time travel
def time_travel(
Expand Down
2 changes: 2 additions & 0 deletions boa/test/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def _toggle_profiling(enabled: bool = False) -> Generator:
else:
yield

def pytest_enter_pdb(config, pdb):
boa.env._restore_journal_state_from_computation()

def pytest_sessionfinish(session, exitstatus):
if boa.env._cached_call_profiles:
Expand Down

0 comments on commit ca31d2e

Please sign in to comment.