Search in sources :

Example 1 with LogsSubscription

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription in project besu by hyperledger.

the class SubscriptionBuilderTest method shouldThrownIllegalArgumentExceptionWhenMappingWrongSubscriptionType.

@Test
@SuppressWarnings("ReturnValueIgnored")
public void shouldThrownIllegalArgumentExceptionWhenMappingWrongSubscriptionType() {
    final Function<Subscription, LogsSubscription> function = subscriptionBuilder.mapToSubscriptionClass(LogsSubscription.class);
    final NewBlockHeadersSubscription subscription = new NewBlockHeadersSubscription(1L, CONNECTION_ID, true);
    final Throwable thrown = catchThrowable(() -> function.apply(subscription));
    assertThat(thrown).hasNoCause().isInstanceOf(IllegalArgumentException.class).hasMessage("NewBlockHeadersSubscription instance can't be mapped to type LogsSubscription");
}
Also used : NewBlockHeadersSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) SyncingSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscription) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) NewBlockHeadersSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) Test(org.junit.Test)

Example 2 with LogsSubscription

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription in project besu by hyperledger.

the class SubscriptionBuilderTest method shouldReturnSubscriptionWhenMappingNewPendingTransactionsSubscription.

@Test
public void shouldReturnSubscriptionWhenMappingNewPendingTransactionsSubscription() {
    final Function<Subscription, Subscription> function = subscriptionBuilder.mapToSubscriptionClass(Subscription.class);
    final Subscription logsSubscription = new Subscription(1L, CONNECTION_ID, SubscriptionType.NEW_PENDING_TRANSACTIONS, Boolean.FALSE);
    assertThat(function.apply(logsSubscription)).isInstanceOf(Subscription.class);
}
Also used : SyncingSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscription) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) NewBlockHeadersSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) Test(org.junit.Test)

Example 3 with LogsSubscription

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription in project besu by hyperledger.

the class SubscriptionBuilderTest method shouldBuildLogsSubscriptionWhenSubscribeRequestTypeIsLogs.

@Test
public void shouldBuildLogsSubscriptionWhenSubscribeRequestTypeIsLogs() {
    final FilterParameter filterParameter = filterParameter();
    final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.LOGS, filterParameter, null, CONNECTION_ID);
    final LogsSubscription expectedSubscription = new LogsSubscription(1L, CONNECTION_ID, filterParameter);
    final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest);
    assertThat(builtSubscription).usingRecursiveComparison().isEqualTo(expectedSubscription);
}
Also used : SubscribeRequest(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.SubscribeRequest) PrivateSubscribeRequest(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateSubscribeRequest) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) SyncingSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscription) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) NewBlockHeadersSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) FilterParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter) Test(org.junit.Test)

Example 4 with LogsSubscription

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription in project besu by hyperledger.

the class SubscriptionBuilderTest method shouldReturnLogsSubscriptionWhenMappingLogsSubscription.

@Test
public void shouldReturnLogsSubscriptionWhenMappingLogsSubscription() {
    final Function<Subscription, LogsSubscription> function = subscriptionBuilder.mapToSubscriptionClass(LogsSubscription.class);
    final Subscription subscription = new LogsSubscription(1L, CONNECTION_ID, filterParameter());
    assertThat(function.apply(subscription)).isInstanceOf(LogsSubscription.class);
}
Also used : LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) SyncingSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscription) LogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription) NewBlockHeadersSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) Test(org.junit.Test)

Aggregations

NewBlockHeadersSubscription (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscription)4 LogsSubscription (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.LogsSubscription)4 PrivateLogsSubscription (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription)4 SyncingSubscription (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscription)4 Test (org.junit.Test)4 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 FilterParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter)1 PrivateSubscribeRequest (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateSubscribeRequest)1 SubscribeRequest (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.SubscribeRequest)1