Search in sources :

Example 31 with ResponseCodeEnum

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

the class HapiGetReceipt method assertExpectationsGiven.

@Override
protected void assertExpectationsGiven(HapiApiSpec spec) {
    var receipt = response.getTransactionGetReceipt().getReceipt();
    if (expectedPriorityStatus.isPresent()) {
        ResponseCodeEnum actualStatus = receipt.getStatus();
        assertEquals(expectedPriorityStatus.get(), actualStatus);
    }
    if (expectedDuplicateStatuses.isPresent()) {
        var duplicates = response.getTransactionGetReceipt().getDuplicateTransactionReceiptsList().stream().map(TransactionReceipt::getStatus).toArray(n -> new ResponseCodeEnum[n]);
        Assertions.assertArrayEquals(expectedDuplicateStatuses.get(), duplicates);
    }
    if (expectedScheduledTxnId.isPresent()) {
        var expected = spec.registry().getTxnId(expectedScheduledTxnId.get());
        var actual = response.getTransactionGetReceipt().getReceipt().getScheduledTransactionID();
        assertEquals(expected, actual, "Wrong scheduled transaction id!");
    }
    if (expectedSchedule.isPresent()) {
        var schedule = TxnUtils.asScheduleId(expectedSchedule.get(), spec);
        assertEquals(schedule, receipt.getScheduleID(), "Wrong/missing schedule id!");
    }
    if (hasChildAutoAccountCreations.isPresent()) {
        int count = hasChildAutoAccountCreations.get();
        for (var childReceipt : childReceipts) {
            if (childReceipt.hasAccountID()) {
                count--;
            }
        }
        assertEquals(0, count);
    }
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum)

Example 32 with ResponseCodeEnum

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

the class Rationalization method execute.

private void execute() {
    ResponseCodeEnum otherFailure = null;
    final var payerStatus = expandIn(realPayerSigs, sigReqs::keysForPayer);
    if (payerStatus != OK) {
        txnAccessor.setSigMeta(RationalizedSigMeta.noneAvailable());
        finalStatus = payerStatus;
        return;
    }
    reqPayerSig = lastOrderResult.getPayerKey();
    final var otherPartiesStatus = expandIn(realOtherPartySigs, sigReqs::keysForOtherParties);
    if (otherPartiesStatus != OK) {
        otherFailure = otherPartiesStatus;
    } else {
        reqOthersSigs = lastOrderResult.getOrderedKeys();
        if (pkToSigFn.hasAtLeastOneUnusedSigWithFullPrefix()) {
            pkToSigFn.forEachUnusedSigWithFullPrefix((type, pubKey, sig) -> realOtherPartySigs.add(bodySigningFactory.signAppropriately(type, pubKey, sig)));
        }
    }
    final var rationalizedPayerSigs = rationalize(realPayerSigs, 0);
    final var rationalizedOtherPartySigs = rationalize(realOtherPartySigs, realPayerSigs.size());
    if (rationalizedPayerSigs == realPayerSigs || rationalizedOtherPartySigs == realOtherPartySigs) {
        txnSigs = new ArrayList<>();
        txnSigs.addAll(rationalizedPayerSigs);
        txnSigs.addAll(rationalizedOtherPartySigs);
        verifiedSync = true;
    }
    makeRationalizedMetaAccessible();
    finalStatus = (otherFailure != null) ? otherFailure : OK;
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum)

Example 33 with ResponseCodeEnum

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

the class FeeChargingPolicyTest method requiresAbleToPayServiceWhenTriggeredTxn.

@Test
void requiresAbleToPayServiceWhenTriggeredTxn() {
    given(narratedCharging.isPayerWillingToCoverServiceFee()).willReturn(true);
    given(narratedCharging.canPayerAffordServiceFee()).willReturn(false);
    // when:
    ResponseCodeEnum outcome = subject.applyForTriggered(fees);
    // then:
    verify(narratedCharging).setFees(fees);
    verify(narratedCharging, never()).chargePayerServiceFee();
    // and:
    assertEquals(INSUFFICIENT_PAYER_BALANCE, outcome);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Test(org.junit.jupiter.api.Test)

Example 34 with ResponseCodeEnum

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

the class FeeChargingPolicyTest method chargesDiscountedFeesAsExpectedForDuplicate.

@Test
void chargesDiscountedFeesAsExpectedForDuplicate() {
    // setup:
    ArgumentCaptor<FeeObject> captor = ArgumentCaptor.forClass(FeeObject.class);
    givenPayerWillingAndAbleForAllFees();
    // when:
    ResponseCodeEnum outcome = subject.applyForDuplicate(fees);
    // then:
    verify(narratedCharging).setFees(captor.capture());
    // and:
    assertEquals(feesForDuplicateTxn.getNodeFee(), captor.getValue().getNodeFee());
    assertEquals(feesForDuplicateTxn.getNetworkFee(), captor.getValue().getNetworkFee());
    assertEquals(feesForDuplicateTxn.getServiceFee(), captor.getValue().getServiceFee());
    // and:
    verify(narratedCharging).chargePayerAllFees();
    // and:
    assertEquals(OK, outcome);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) FeeObject(com.hederahashgraph.fee.FeeObject) Test(org.junit.jupiter.api.Test)

Example 35 with ResponseCodeEnum

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

the class FeeChargingPolicyTest method chargesNodePenaltyForPayerUnwillingToPayNetwork.

@Test
void chargesNodePenaltyForPayerUnwillingToPayNetwork() {
    given(narratedCharging.isPayerWillingToCoverNetworkFee()).willReturn(false);
    // when:
    ResponseCodeEnum outcome = subject.apply(fees);
    // then:
    verify(narratedCharging).setFees(fees);
    verify(narratedCharging).chargeSubmittingNodeUpToNetworkFee();
    // and:
    assertEquals(INSUFFICIENT_TX_FEE, outcome);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Test(org.junit.jupiter.api.Test)

Aggregations

ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)52 Test (org.junit.jupiter.api.Test)38 Query (com.hederahashgraph.api.proto.java.Query)24 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)8 AccountID (com.hederahashgraph.api.proto.java.AccountID)6 Response (com.hederahashgraph.api.proto.java.Response)6 CryptoGetAccountBalanceResponse (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceResponse)4 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)4 SignedTxnAccessor (com.hedera.services.utils.SignedTxnAccessor)3 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)3 ContractID (com.hederahashgraph.api.proto.java.ContractID)3 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)3 AliasManager (com.hedera.services.ledger.accounts.AliasManager)2 HfsSigMetaLookup (com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup)2 EntityNum (com.hedera.services.utils.EntityNum)2 TopicID (com.hederahashgraph.api.proto.java.TopicID)2 TransactionID (com.hederahashgraph.api.proto.java.TransactionID)2 Instant (java.time.Instant)2 ByteString (com.google.protobuf.ByteString)1 EntityNumbers (com.hedera.services.config.EntityNumbers)1