Search in sources :

Example 1 with TransactionGetReceiptResponse

use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method shortCircuitsToAnswerOnly.

@Test
void shortCircuitsToAnswerOnly() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId, ResponseType.COST_ANSWER);
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, opResponse.getHeader().getResponseType());
    assertEquals(receipt.toGrpc(), opResponse.getReceipt());
    assertTrue(opResponse.getDuplicateTransactionReceiptsList().isEmpty());
    verify(recordCache, never()).getDuplicateReceipts(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Example 2 with TransactionGetReceiptResponse

use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method returnsChildrenIfRequested.

@Test
void returnsChildrenIfRequested() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId, ANSWER_ONLY, false, true);
    var childReceipts = List.of(duplicateReceipt.toGrpc(), unclassifiableReceipt.toGrpc());
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
    given(recordCache.getChildReceipts(validTxnId)).willReturn(childReceipts);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, opResponse.getHeader().getResponseType());
    assertEquals(receipt.toGrpc(), opResponse.getReceipt());
    assertEquals(childReceipts, opResponse.getChildTransactionReceiptsList());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Example 3 with TransactionGetReceiptResponse

use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method rejectsQueryForMissingReceipt.

@Test
void rejectsQueryForMissingReceipt() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId);
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(null);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertEquals(RECEIPT_NOT_FOUND, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionGetReceiptResponse

use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method returnsDuplicatesIfRequested.

@Test
void returnsDuplicatesIfRequested() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId, ANSWER_ONLY, true);
    var duplicateReceipts = List.of(duplicateReceipt.toGrpc(), unclassifiableReceipt.toGrpc());
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
    given(recordCache.getDuplicateReceipts(validTxnId)).willReturn(duplicateReceipts);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, opResponse.getHeader().getResponseType());
    assertEquals(receipt.toGrpc(), opResponse.getReceipt());
    assertEquals(duplicateReceipts, opResponse.getDuplicateTransactionReceiptsList());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Example 5 with TransactionGetReceiptResponse

use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method respectsMetaValidity.

@Test
void respectsMetaValidity() {
    // given:
    Query sensibleQuery = queryWith(validTxnId);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
    // and:
    verify(recordCache, never()).isReceiptPresent(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)5 Response (com.hederahashgraph.api.proto.java.Response)5 TransactionGetReceiptQuery (com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery)5 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)5 Test (org.junit.jupiter.api.Test)5