Search in sources :

Example 1 with ResponseCodeEnum

use of com.hedera.hashgraph.sdk.proto.ResponseCodeEnum in project hedera-sdk-java by hashgraph.

the class StatusTest method statusToResponseCode.

@Test
@DisplayName("Status can be constructed from any ResponseCode")
void statusToResponseCode() {
    for (ResponseCodeEnum code : ResponseCodeEnum.values()) {
        // this is what we're given if an unexpected value was decoded
        if (code == ResponseCodeEnum.UNRECOGNIZED) {
            continue;
        }
        Status status = Status.valueOf(code);
        assertThat(code.getNumber()).isEqualTo(status.code.getNumber());
    }
}
Also used : ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with ResponseCodeEnum

use of com.hedera.hashgraph.sdk.proto.ResponseCodeEnum in project hedera-mirror-node by hashgraph.

the class TransactionPublisherTest method publishRetrySameRequest.

@Test
@Timeout(3)
void publishRetrySameRequest() {
    ResponseCodeEnum errorResponseCode = ResponseCodeEnum.PLATFORM_NOT_ACTIVE;
    cryptoServiceStub.addTransactions(Mono.just(response(errorResponseCode)), Mono.just(response(errorResponseCode)));
    var request = request().build();
    transactionPublisher.publish(request).as(StepVerifier::create).expectErrorSatisfies(t -> assertThat(t).isInstanceOf(PublishException.class).hasMessageContaining("exceeded maximum attempts for request with last exception being").getRootCause().hasMessageContaining(errorResponseCode.toString())).verify(Duration.ofSeconds(2L));
    cryptoServiceStub.addTransactions(Mono.just(response(OK)));
    transactionPublisher.publish(request).as(StepVerifier::create).expectNextCount(1L).expectComplete().verify(Duration.ofSeconds(1L));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CryptoServiceGrpc(com.hedera.hashgraph.sdk.proto.CryptoServiceGrpc) NodeProperties(com.hedera.mirror.monitor.NodeProperties) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperatorProperties(com.hedera.mirror.monitor.OperatorProperties) OK(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.OK) TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) TimeoutException(java.util.concurrent.TimeoutException) InProcessServerBuilder(io.grpc.inprocess.InProcessServerBuilder) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) Query(com.hedera.hashgraph.sdk.proto.Query) Transaction(com.hedera.hashgraph.sdk.proto.Transaction) StreamObserver(io.grpc.stub.StreamObserver) ResponseHeader(com.hedera.hashgraph.sdk.proto.ResponseHeader) Response(com.hedera.hashgraph.sdk.proto.Response) Duration(java.time.Duration) Map(java.util.Map) TransactionReceipt(com.hedera.hashgraph.sdk.proto.TransactionReceipt) TransactionRecord(com.hedera.hashgraph.sdk.proto.TransactionRecord) Server(io.grpc.Server) ACCOUNT_DELETED(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.ACCOUNT_DELETED) SUCCESS(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.SUCCESS) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Set(java.util.Set) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) TransactionGetRecordResponse(com.hedera.hashgraph.sdk.proto.TransactionGetRecordResponse) Test(org.junit.jupiter.api.Test) TransactionGetReceiptResponse(com.hedera.hashgraph.sdk.proto.TransactionGetReceiptResponse) AfterEach(org.junit.jupiter.api.AfterEach) TransactionResponse(com.hedera.hashgraph.sdk.proto.TransactionResponse) Data(lombok.Data) Log4j2(lombok.extern.log4j.Log4j2) PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) Queue(java.util.Queue) Timeout(org.junit.jupiter.api.Timeout) MonitorProperties(com.hedera.mirror.monitor.MonitorProperties) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) StepVerifier(reactor.test.StepVerifier) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Example 3 with ResponseCodeEnum

use of com.hedera.hashgraph.sdk.proto.ResponseCodeEnum in project hedera-mirror-node by hashgraph.

the class TransactionPublisherTest method publishPreCheckError.

@Test
@Timeout(3)
void publishPreCheckError() {
    ResponseCodeEnum errorResponseCode = ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE;
    cryptoServiceStub.addTransactions(Mono.just(response(errorResponseCode)));
    transactionPublisher.publish(request().build()).as(StepVerifier::create).expectErrorSatisfies(t -> assertThat(t).isInstanceOf(PublishException.class).hasMessageContaining(errorResponseCode.toString())).verify(Duration.ofSeconds(1L));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CryptoServiceGrpc(com.hedera.hashgraph.sdk.proto.CryptoServiceGrpc) NodeProperties(com.hedera.mirror.monitor.NodeProperties) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperatorProperties(com.hedera.mirror.monitor.OperatorProperties) OK(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.OK) TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) TimeoutException(java.util.concurrent.TimeoutException) InProcessServerBuilder(io.grpc.inprocess.InProcessServerBuilder) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) Query(com.hedera.hashgraph.sdk.proto.Query) Transaction(com.hedera.hashgraph.sdk.proto.Transaction) StreamObserver(io.grpc.stub.StreamObserver) ResponseHeader(com.hedera.hashgraph.sdk.proto.ResponseHeader) Response(com.hedera.hashgraph.sdk.proto.Response) Duration(java.time.Duration) Map(java.util.Map) TransactionReceipt(com.hedera.hashgraph.sdk.proto.TransactionReceipt) TransactionRecord(com.hedera.hashgraph.sdk.proto.TransactionRecord) Server(io.grpc.Server) ACCOUNT_DELETED(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.ACCOUNT_DELETED) SUCCESS(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.SUCCESS) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Set(java.util.Set) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) TransactionGetRecordResponse(com.hedera.hashgraph.sdk.proto.TransactionGetRecordResponse) Test(org.junit.jupiter.api.Test) TransactionGetReceiptResponse(com.hedera.hashgraph.sdk.proto.TransactionGetReceiptResponse) AfterEach(org.junit.jupiter.api.AfterEach) TransactionResponse(com.hedera.hashgraph.sdk.proto.TransactionResponse) Data(lombok.Data) Log4j2(lombok.extern.log4j.Log4j2) PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) Queue(java.util.Queue) Timeout(org.junit.jupiter.api.Timeout) MonitorProperties(com.hedera.mirror.monitor.MonitorProperties) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) StepVerifier(reactor.test.StepVerifier) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Example 4 with ResponseCodeEnum

use of com.hedera.hashgraph.sdk.proto.ResponseCodeEnum in project hedera-mirror-node by hashgraph.

the class TransactionPublisherTest method publishRetryError.

@Test
@Timeout(3)
void publishRetryError() {
    ResponseCodeEnum errorResponseCode = ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED;
    cryptoServiceStub.addTransactions(Mono.just(response(errorResponseCode)), Mono.just(response(errorResponseCode)));
    transactionPublisher.publish(request().build()).as(StepVerifier::create).expectErrorSatisfies(t -> assertThat(t).isInstanceOf(PublishException.class).hasMessageContaining("exceeded maximum attempts for request with last exception being").getRootCause().hasMessageContaining(errorResponseCode.toString())).verify(Duration.ofSeconds(2L));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CryptoServiceGrpc(com.hedera.hashgraph.sdk.proto.CryptoServiceGrpc) NodeProperties(com.hedera.mirror.monitor.NodeProperties) Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperatorProperties(com.hedera.mirror.monitor.OperatorProperties) OK(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.OK) TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) TimeoutException(java.util.concurrent.TimeoutException) InProcessServerBuilder(io.grpc.inprocess.InProcessServerBuilder) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) Query(com.hedera.hashgraph.sdk.proto.Query) Transaction(com.hedera.hashgraph.sdk.proto.Transaction) StreamObserver(io.grpc.stub.StreamObserver) ResponseHeader(com.hedera.hashgraph.sdk.proto.ResponseHeader) Response(com.hedera.hashgraph.sdk.proto.Response) Duration(java.time.Duration) Map(java.util.Map) TransactionReceipt(com.hedera.hashgraph.sdk.proto.TransactionReceipt) TransactionRecord(com.hedera.hashgraph.sdk.proto.TransactionRecord) Server(io.grpc.Server) ACCOUNT_DELETED(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.ACCOUNT_DELETED) SUCCESS(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.SUCCESS) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Set(java.util.Set) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) TransactionGetRecordResponse(com.hedera.hashgraph.sdk.proto.TransactionGetRecordResponse) Test(org.junit.jupiter.api.Test) TransactionGetReceiptResponse(com.hedera.hashgraph.sdk.proto.TransactionGetReceiptResponse) AfterEach(org.junit.jupiter.api.AfterEach) TransactionResponse(com.hedera.hashgraph.sdk.proto.TransactionResponse) Data(lombok.Data) Log4j2(lombok.extern.log4j.Log4j2) PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) Queue(java.util.Queue) Timeout(org.junit.jupiter.api.Timeout) MonitorProperties(com.hedera.mirror.monitor.MonitorProperties) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ResponseCodeEnum(com.hedera.hashgraph.sdk.proto.ResponseCodeEnum) StepVerifier(reactor.test.StepVerifier) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

ResponseCodeEnum (com.hedera.hashgraph.sdk.proto.ResponseCodeEnum)4 Test (org.junit.jupiter.api.Test)4 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)3 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)3 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)3 CryptoServiceGrpc (com.hedera.hashgraph.sdk.proto.CryptoServiceGrpc)3 Query (com.hedera.hashgraph.sdk.proto.Query)3 Response (com.hedera.hashgraph.sdk.proto.Response)3 ACCOUNT_DELETED (com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.ACCOUNT_DELETED)3 OK (com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.OK)3 SUCCESS (com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.SUCCESS)3 ResponseHeader (com.hedera.hashgraph.sdk.proto.ResponseHeader)3 Transaction (com.hedera.hashgraph.sdk.proto.Transaction)3 TransactionGetReceiptResponse (com.hedera.hashgraph.sdk.proto.TransactionGetReceiptResponse)3 TransactionGetRecordResponse (com.hedera.hashgraph.sdk.proto.TransactionGetRecordResponse)3 TransactionReceipt (com.hedera.hashgraph.sdk.proto.TransactionReceipt)3 TransactionRecord (com.hedera.hashgraph.sdk.proto.TransactionRecord)3 TransactionResponse (com.hedera.hashgraph.sdk.proto.TransactionResponse)3 MonitorProperties (com.hedera.mirror.monitor.MonitorProperties)3 NodeProperties (com.hedera.mirror.monitor.NodeProperties)3