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);
}
}
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;
}
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);
}
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);
}
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);
}
Aggregations