Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
test slot ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihChengLiang committed Apr 9, 2019
1 parent 46d1a36 commit e24abe4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/plugins/eth2/beacon/test_slot_ticker.py
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()

0 comments on commit e24abe4

Please sign in to comment.