use of tech.pegasys.teku.api.response.v1.EventType in project teku by ConsenSys.
the class EventSubscriberTest method shouldSubscribeToMultipleEventsSuccessfully.
@Test
void shouldSubscribeToMultipleEventsSuccessfully() throws IOException {
EventSubscriber eventSubscriber = new EventSubscriber(allEventTypes.stream().map(EventType::name).collect(Collectors.toList()), sseClient, onCloseCallback, asyncRunner, MAX_PENDING_EVENTS);
for (EventType eventType : allEventTypes) {
eventSubscriber.onEvent(eventType, event("test"));
}
assertThat(asyncRunner.countDelayedActions()).isEqualTo(2);
asyncRunner.executeQueuedActions();
assertThat(outputStream.countEvents()).isEqualTo(allEventTypes.size());
assertThat(outputStream.countComments()).isEqualTo(1);
}
use of tech.pegasys.teku.api.response.v1.EventType in project teku by ConsenSys.
the class EventSubscriberTest method shouldNotSendEventsIfNotSubscribed.
@ParameterizedTest
@EnumSource(EventType.class)
void shouldNotSendEventsIfNotSubscribed(final EventType eventType) throws Exception {
EventSubscriber subscriber = new EventSubscriber(List.of(eventType.name()), sseClient, onCloseCallback, asyncRunner, MAX_PENDING_EVENTS);
for (EventType val : allEventTypes) {
if (val.compareTo(eventType) != 0) {
subscriber.onEvent(val, event("test"));
}
}
assertThat(asyncRunner.countDelayedActions()).isEqualTo(1);
asyncRunner.executeQueuedActions();
assertThat(outputStream.countEvents()).isEqualTo(0);
assertThat(outputStream.countComments()).isEqualTo(1);
}
Aggregations