Skip to content

Commit

Permalink
Add test that calls pause while already paused, and resume when not p…
Browse files Browse the repository at this point in the history
…aused; all is still fine.
  • Loading branch information
derekpierre committed Feb 28, 2024
1 parent 03b49dd commit 31267f5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_follow(
machine.stop()


def test_simple_state_transitions(chain, machine, clock, eip1559_transaction, account):
def test_simple_state_transitions(chain, machine, eip1559_transaction, account):
assert machine.current_state == machine._IDLE

for i in range(3):
Expand All @@ -257,13 +257,18 @@ def test_simple_state_transitions(chain, machine, clock, eip1559_transaction, ac
machine.pause()
machine._cycle()
assert machine.current_state == machine._PAUSED
assert machine._pause
assert machine.paused

# calling pause has no effect if already paused
assert machine.paused
for i in range(3):
machine.pause()

# resume after pausing
machine.resume()
machine._cycle()
assert machine.current_state == machine._IDLE
assert not machine._pause
assert not machine.paused
assert not machine.busy

atx = machine.queue_transaction(
Expand All @@ -280,13 +285,13 @@ def test_simple_state_transitions(chain, machine, clock, eip1559_transaction, ac
machine.pause()
machine._cycle()
assert machine.current_state == machine._PAUSED
assert machine._pause
assert machine.paused

# resume after pausing
machine.resume()
machine._cycle()
assert machine.current_state == machine._BUSY
assert not machine._pause
assert not machine.paused

# finalize tx
while machine.busy:
Expand All @@ -298,3 +303,9 @@ def test_simple_state_transitions(chain, machine, clock, eip1559_transaction, ac
# transition to idle
machine._cycle()
assert machine.current_state == machine._IDLE

# resume has no effect if not paused
assert not machine.paused
for i in range(3):
machine.resume()
assert machine.current_state == machine._IDLE

0 comments on commit 31267f5

Please sign in to comment.