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