Search in sources :

Example 46 with Query

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

the class HapiGetAccountRecords method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) {
    Query query = getRecordsQuery(spec, payment, false);
    response = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls).getAccountRecords(query);
    List<TransactionRecord> records = response.getCryptoGetAccountRecords().getRecordsList();
    if (verboseLoggingOn) {
        if (customLog.isPresent()) {
            customLog.get().accept(log, records);
        } else {
            log.info(records);
        }
    }
    if (snapshotDirPath.isPresent()) {
        saveSnapshots(spec, records);
    }
    if (expectationsDirPath.isPresent()) {
        checkExpectations(spec, records);
    }
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) CryptoGetAccountRecordsQuery(com.hederahashgraph.api.proto.java.CryptoGetAccountRecordsQuery) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 47 with Query

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

the class ContractCallLocalAnswerTest method noCopyPasteErrors.

@Test
void noCopyPasteErrors() throws Throwable {
    // given:
    Query query = validQuery(COST_ANSWER, fee);
    // when:
    Response response = subject.responseGiven(query, view, INSUFFICIENT_TX_FEE, fee);
    // then:
    assertEquals(HederaFunctionality.ContractCallLocal, subject.canonicalFunction());
    assertEquals(paymentTxn, subject.extractPaymentFrom(query).get().getSignedTxnWrapper());
    assertTrue(subject.needsAnswerOnlyCost(query));
    assertFalse(subject.requiresNodePayment(query));
    assertEquals(INSUFFICIENT_TX_FEE, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ContractCallLocalResponse(com.hederahashgraph.api.proto.java.ContractCallLocalResponse) Query(com.hederahashgraph.api.proto.java.Query) ContractCallLocalQuery(com.hederahashgraph.api.proto.java.ContractCallLocalQuery) Test(org.junit.jupiter.api.Test)

Example 48 with Query

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

the class ContractCallLocalAnswerTest method respectsMetaValidity.

@Test
void respectsMetaValidity() throws Throwable {
    // given:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
    // then:
    var opResponse = response.getContractCallLocal();
    assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ContractCallLocalResponse(com.hederahashgraph.api.proto.java.ContractCallLocalResponse) Query(com.hederahashgraph.api.proto.java.Query) ContractCallLocalQuery(com.hederahashgraph.api.proto.java.ContractCallLocalQuery) Test(org.junit.jupiter.api.Test)

Example 49 with Query

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

the class GetBySolidityIdAnswerTest method assertSolidityIDHeadersWhenResponseTypeIsMissing.

@Test
void assertSolidityIDHeadersWhenResponseTypeIsMissing() {
    Query query = Query.newBuilder().setGetBySolidityID(getBySolidityIDQueryBuilder.build()).build();
    var result = solidityIdAnswer.responseGiven(query, null, null, 0);
    assertEquals(ResponseCodeEnum.NOT_SUPPORTED, result.getGetBySolidityID().getHeader().getNodeTransactionPrecheckCode());
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) GetBySolidityIDQuery(com.hederahashgraph.api.proto.java.GetBySolidityIDQuery) Test(org.junit.jupiter.api.Test)

Example 50 with Query

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

the class GetBySolidityIdAnswerTest method assertSolidityIDHeadersWhenResponseTypeIsCostAnswer.

@Test
void assertSolidityIDHeadersWhenResponseTypeIsCostAnswer() {
    var header = QueryHeader.newBuilder().setResponseType(ResponseType.COST_ANSWER).build();
    var getSolidityIdQuery = getBySolidityIDQueryBuilder.setHeader(header).build();
    Query query = Query.newBuilder().setGetBySolidityID(getSolidityIdQuery).build();
    var result = solidityIdAnswer.responseGiven(query, null, null, 0);
    assertEquals(ResponseCodeEnum.NOT_SUPPORTED, result.getGetBySolidityID().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ResponseType.COST_ANSWER, result.getGetBySolidityID().getHeader().getResponseType());
    assertEquals(0L, result.getGetBySolidityID().getHeader().getCost());
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) GetBySolidityIDQuery(com.hederahashgraph.api.proto.java.GetBySolidityIDQuery) Test(org.junit.jupiter.api.Test)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)152 Test (org.junit.jupiter.api.Test)108 Response (com.hederahashgraph.api.proto.java.Response)95 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)24 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)13 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)13 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)11 ByteString (com.google.protobuf.ByteString)10 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)10 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)10 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)10 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)9 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)9 FileGetInfoQuery (com.hederahashgraph.api.proto.java.FileGetInfoQuery)8 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)8 HashMap (java.util.HashMap)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetBytecodeQuery (com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)7 FileGetContentsQuery (com.hederahashgraph.api.proto.java.FileGetContentsQuery)7 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)7