Search in sources :

Example 21 with FeeObject

use of com.hederahashgraph.fee.FeeObject in project hedera-services by hashgraph.

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForBurnToken.

@Test
void gasRequirementReturnsCorrectValueForBurnToken() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_BURN_TOKEN);
    given(decoder.decodeBurn(any())).willReturn(fungibleBurn);
    given(syntheticTxnFactory.createBurn(any())).willReturn(TransactionBody.newBuilder().setTokenBurn(TokenBurnTransactionBody.newBuilder()));
    given(feeCalculator.computeFee(any(), any(), any(), any())).willReturn(new FeeObject(TEST_NODE_FEE, TEST_NETWORK_FEE, TEST_SERVICE_FEE));
    given(feeCalculator.estimatedGasPriceInTinybars(any(), any())).willReturn(DEFAULT_GAS_PRICE);
    subject.prepareFields(messageFrame);
    subject.prepareComputation(input, а -> а);
    subject.computeGasRequirement(TEST_CONSENSUS_TIME);
    // then
    assertEquals(Gas.of(EXPECTED_GAS_PRICE), subject.gasRequirement(input));
}
Also used : FeeObject(com.hederahashgraph.fee.FeeObject) Test(org.junit.jupiter.api.Test)

Example 22 with FeeObject

use of com.hederahashgraph.fee.FeeObject in project hedera-services by hashgraph.

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForTransferSingleToken.

@Test
void gasRequirementReturnsCorrectValueForTransferSingleToken() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_TRANSFER_TOKEN);
    given(syntheticTxnFactory.createCryptoTransfer(any())).willReturn(TransactionBody.newBuilder().setCryptoTransfer(CryptoTransferTransactionBody.newBuilder()));
    given(feeCalculator.computeFee(any(), any(), any(), any())).willReturn(new FeeObject(TEST_NODE_FEE, TEST_NETWORK_FEE, TEST_SERVICE_FEE));
    given(feeCalculator.estimatedGasPriceInTinybars(any(), any())).willReturn(DEFAULT_GAS_PRICE);
    subject.prepareFields(messageFrame);
    subject.prepareComputation(input, а -> а);
    subject.computeGasRequirement(TEST_CONSENSUS_TIME);
    // then
    assertEquals(Gas.of(EXPECTED_GAS_PRICE), subject.gasRequirement(input));
}
Also used : FeeObject(com.hederahashgraph.fee.FeeObject) Test(org.junit.jupiter.api.Test)

Example 23 with FeeObject

use of com.hederahashgraph.fee.FeeObject in project hedera-services by hashgraph.

the class RecordCreationSuite method submittingNodeStillPaidIfServiceFeesOmitted.

private HapiApiSpec submittingNodeStillPaidIfServiceFeesOmitted() {
    final String comfortingMemo = "This is ok, it's fine, it's whatever.";
    final AtomicReference<FeeObject> feeObs = new AtomicReference<>();
    return defaultHapiSpec("submittingNodeStillPaidIfServiceFeesOmitted").given(cryptoTransfer(tinyBarsFromTo(GENESIS, "0.0.3", ONE_HBAR)).payingWith(GENESIS), cryptoCreate("payer"), cryptoTransfer(tinyBarsFromTo(GENESIS, FUNDING, 1L)).memo(comfortingMemo).exposingFeesTo(feeObs).payingWith("payer")).when(balanceSnapshot("before", "0.0.3"), balanceSnapshot("fundingBefore", "0.0.98"), sourcing(() -> cryptoTransfer(tinyBarsFromTo(GENESIS, FUNDING, 1L)).memo(comfortingMemo).fee(feeObs.get().getNetworkFee() + feeObs.get().getNodeFee()).payingWith("payer").via("txnId").hasKnownStatus(INSUFFICIENT_TX_FEE))).then(sourcing(() -> getAccountBalance("0.0.3").hasTinyBars(changeFromSnapshot("before", +feeObs.get().getNodeFee()))), sourcing(() -> getAccountBalance("0.0.98").hasTinyBars(changeFromSnapshot("fundingBefore", +feeObs.get().getNetworkFee()))), sourcing(() -> getTxnRecord("txnId").assertingNothingAboutHashes().hasPriority(recordWith().transfers(includingDeduction("payer", feeObs.get().getNetworkFee() + feeObs.get().getNodeFee())).status(INSUFFICIENT_TX_FEE)).logged()));
}
Also used : FeeObject(com.hederahashgraph.fee.FeeObject) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString)

Aggregations

FeeObject (com.hederahashgraph.fee.FeeObject)23 Test (org.junit.jupiter.api.Test)19 FeeBuilder.getFeeObject (com.hederahashgraph.fee.FeeBuilder.getFeeObject)7 SigValueObj (com.hederahashgraph.fee.SigValueObj)4 ByteString (com.google.protobuf.ByteString)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)1