Search in sources :

Example 1 with FeeObject

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

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForAssociateTokens.

@Test
void gasRequirementReturnsCorrectValueForAssociateTokens() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_ASSOCIATE_TOKENS);
    given(decoder.decodeMultipleAssociations(any(), any())).willReturn(associateOp);
    final var builder = TokenAssociateTransactionBody.newBuilder();
    builder.setAccount(multiDissociateOp.accountId());
    builder.addAllTokens(multiDissociateOp.tokenIds());
    given(syntheticTxnFactory.createAssociate(any())).willReturn(TransactionBody.newBuilder().setTokenAssociate(builder));
    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 2 with FeeObject

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

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForDissociateTokens.

@Test
void gasRequirementReturnsCorrectValueForDissociateTokens() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_DISSOCIATE_TOKENS);
    given(decoder.decodeMultipleDissociations(any(), any())).willReturn(multiDissociateOp);
    final var builder = TokenDissociateTransactionBody.newBuilder();
    builder.setAccount(multiDissociateOp.accountId());
    builder.addAllTokens(multiDissociateOp.tokenIds());
    given(syntheticTxnFactory.createDissociate(any())).willReturn(TransactionBody.newBuilder().setTokenDissociate(builder));
    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 3 with FeeObject

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

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForMintToken.

@Test
void gasRequirementReturnsCorrectValueForMintToken() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_MINT_TOKEN);
    given(decoder.decodeMint(any())).willReturn(fungibleMint);
    given(syntheticTxnFactory.createMint(any())).willReturn(TransactionBody.newBuilder().setTokenMint(TokenMintTransactionBody.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 4 with FeeObject

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

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForSingleCryptoTransfer.

@Test
void gasRequirementReturnsCorrectValueForSingleCryptoTransfer() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_CRYPTO_TRANSFER);
    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 5 with FeeObject

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

the class HTSPrecompiledContractTest method gasRequirementReturnsCorrectValueForTransferNft.

@Test
void gasRequirementReturnsCorrectValueForTransferNft() {
    // given
    givenFrameContext();
    given(input.getInt(0)).willReturn(ABI_ID_TRANSFER_NFT);
    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)

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