Skip to content

Commit

Permalink
Respond to RFCs from #31.
Browse files Browse the repository at this point in the history
Co-authored-by: Manuel Montenegro <[email protected]>
  • Loading branch information
derekpierre and manumonti committed Apr 15, 2024
1 parent 53123ef commit cf7f91d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
8 changes: 4 additions & 4 deletions atxm/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _stop(self):

def _wake(self) -> None:
"""Runs the looping call immediately."""
log.info("[wake] running looping call now.")
self.log.info("[wake] running looping call now.")
if self._task.running:
# TODO instead of stopping/starting, can you set interval to 0
# and call reset to have looping call immediately?
Expand All @@ -232,7 +232,7 @@ def _wake(self) -> None:

def _sleep(self) -> None:
if self._task.running:
log.info("[sleep] sleeping")
self.log.info("[sleep] sleeping")
self._stop()

#
Expand All @@ -243,7 +243,7 @@ def __handle_active_transaction(self) -> None:
"""
Handles the currently tracked pending transaction.
The 4 possible outcomes for the pending ("active") transaction in one cycle:
The 3 possible outcomes for the pending ("active") transaction in one cycle:
1. paused
2. finalized (successful or reverted)
Expand Down Expand Up @@ -515,7 +515,7 @@ def queue_transaction(

def remove_queued_transaction(self, tx: FutureTx):
"""
Removes a queued transaction; useful when an exisitng queued transaction has broadcast
Removes a queued transaction; useful when an existing queued transaction has broadcast
failures, or a queued transaction is no longer necessary.
Returns true if transaction was present and removed, false otherwise.
Expand Down
12 changes: 2 additions & 10 deletions tests/test_faults.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,11 @@ def _verify_tx_faulted(machine, atx, fault_hook, expected_fault: Fault):
assert atx.final is False


@pytest.mark.usefixtures("disable_auto_mining")
@pytest.mark.usefixtures("disable_auto_mining", "mock_wake_sleep")
def test_strategy_fault(
w3,
machine,
clock,
eip1559_transaction,
account,
interval,
mock_wake_sleep,
mocker,
):
faulty_strategy = mocker.Mock(spec=AsyncTxStrategy)
Expand All @@ -79,15 +75,11 @@ def test_strategy_fault(
assert atx.error == faulty_message


@pytest.mark.usefixtures("disable_auto_mining")
@pytest.mark.usefixtures("disable_auto_mining", "mock_wake_sleep")
def test_timeout_strategy_fault(
w3,
machine,
clock,
eip1559_transaction,
account,
interval,
mock_wake_sleep,
mocker,
):
atx, fault_hook = _broadcast_tx(machine, eip1559_transaction, account, mocker)
Expand Down
10 changes: 2 additions & 8 deletions tests/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def test_broadcast(

@pytest_twisted.inlineCallbacks
def test_broadcast_insufficient_funds(
clock,
w3,
machine,
legacy_transaction,
Expand Down Expand Up @@ -428,7 +427,6 @@ def test_broadcast_insufficient_funds(

@pytest_twisted.inlineCallbacks
def test_broadcast_insufficient_funds_eth_tester(
clock,
w3,
machine,
eip1559_transaction,
Expand Down Expand Up @@ -1101,17 +1099,15 @@ def test_use_strategies_that_dont_make_updates(


@pytest_twisted.inlineCallbacks
@pytest.mark.usefixtures("disable_auto_mining")
@pytest.mark.usefixtures("disable_auto_mining", "mock_wake_sleep")
def test_insufficient_funds_after_strategy_update_eth_tester(
ethereum_tester,
w3,
machine,
state_observer,
clock,
eip1559_transaction,
account,
mocker,
mock_wake_sleep,
):
strategy_updated_params = dict(eip1559_transaction)
account_balance = w3.eth.get_balance(account.address)
Expand Down Expand Up @@ -1173,17 +1169,15 @@ def test_insufficient_funds_after_strategy_update_eth_tester(


@pytest_twisted.inlineCallbacks
@pytest.mark.usefixtures("disable_auto_mining")
@pytest.mark.usefixtures("disable_auto_mining", "mock_wake_sleep")
def test_insufficient_funds_after_strategy_update(
ethereum_tester,
w3,
machine,
state_observer,
clock,
eip1559_transaction,
account,
mocker,
mock_wake_sleep,
):
strategy_1 = mocker.Mock(spec=AsyncTxStrategy)
strategy_1.name = "no_change_but_still_returns_non_none"
Expand Down

0 comments on commit cf7f91d

Please sign in to comment.