Skip to content

Commit

Permalink
Add simple state transitions test.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed Feb 26, 2024
1 parent 5492042 commit 073ff2b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,44 @@ def test_follow(
assert len(state_observer.transitions) == 2
assert state_observer.transitions[0] == (machine._IDLE, machine._BUSY)
assert state_observer.transitions[1] == (machine._BUSY, machine._IDLE)


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

for i in range(3):
machine._cycle()
# no change in state
assert machine.current_state == machine._IDLE

atx = machine.queue_transaction(
params=eip1559_transaction,
signer=account,
)

# broadcast tx
machine._cycle()
assert machine.current_state == machine._BUSY
assert machine.busy

# pause
machine.pause()
machine._cycle()
assert machine.current_state == machine._PAUSED
assert machine._pause

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

# finalize tx
while machine.busy:
chain.mine(1)
machine._cycle()

assert atx.final is True

# transition to idle
machine._cycle()
assert machine.current_state == machine._IDLE

0 comments on commit 073ff2b

Please sign in to comment.