This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46d1a36
commit e24abe4
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
from trinity.plugins.eth2.beacon.slot_ticker import ( | ||
SlotTicker, | ||
NewSlotEvent, | ||
) | ||
import asyncio | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_slot_ticker_ticking(event_bus, event_loop): | ||
slot_ticker = SlotTicker( | ||
genesis_slot=0, | ||
genesis_time=0, | ||
chain=None, | ||
event_bus=event_bus, | ||
) | ||
|
||
def get_seconds_per_slot(): | ||
return 1 | ||
|
||
# mock get_seconds_per_slot | ||
slot_ticker.get_seconds_per_slot = get_seconds_per_slot | ||
|
||
asyncio.ensure_future(slot_ticker.run(), loop=event_loop) | ||
await slot_ticker.events.started.wait() | ||
try: | ||
new_slot_event = await asyncio.wait_for( | ||
event_bus.wait_for(NewSlotEvent), | ||
timeout=2, | ||
loop=event_loop, | ||
) | ||
except asyncio.TimeoutError: | ||
assert False, "Slot not ticking" | ||
assert new_slot_event.slot > 0 | ||
await slot_ticker.cancel() |