Search in sources :

Example 1 with InvalidTransactionException

use of com.hedera.services.exceptions.InvalidTransactionException in project hedera-services by hashgraph.

the class TypedTokenStoreTest method failsLoadingTokenWithDetachedAutoRenewAccount.

@Test
void failsLoadingTokenWithDetachedAutoRenewAccount() {
    given(accountStore.loadAccount(autoRenewId)).willThrow(new InvalidTransactionException(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL));
    givenToken(merkleTokenId, merkleToken);
    assertTokenLoadFailsWith(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 2 with InvalidTransactionException

use of com.hedera.services.exceptions.InvalidTransactionException in project hedera-services by hashgraph.

the class BurnPrecompilesTest method nftBurnFailurePathWorks.

@Test
void nftBurnFailurePathWorks() {
    givenNonfungibleFrameContext();
    given(sigsVerifier.hasActiveSupplyKey(nonFungibleTokenAddr, recipientAddr, contractAddr, recipientAddr, aliases)).willThrow(new InvalidTransactionException(INVALID_SIGNATURE));
    given(feeCalculator.estimatedGasPriceInTinybars(HederaFunctionality.ContractCall, timestamp)).willReturn(1L);
    given(mockSynthBodyBuilder.build()).willReturn(TransactionBody.newBuilder().build());
    given(mockSynthBodyBuilder.setTransactionID(any(TransactionID.class))).willReturn(mockSynthBodyBuilder);
    given(feeCalculator.computeFee(any(), any(), any(), any())).willReturn(mockFeeObject);
    given(mockFeeObject.getServiceFee()).willReturn(1L);
    given(creator.createUnsuccessfulSyntheticRecord(INVALID_SIGNATURE)).willReturn(mockRecordBuilder);
    given(encoder.encodeBurnFailure(INVALID_SIGNATURE)).willReturn(invalidSigResult);
    subject.prepareFields(frame);
    subject.prepareComputation(pretendArguments, а -> а);
    subject.computeGasRequirement(TEST_CONSENSUS_TIME);
    final var result = subject.computeInternal(frame);
    assertEquals(invalidSigResult, result);
    verify(worldUpdater).manageInProgressRecord(recordsHistorian, mockRecordBuilder, mockSynthBodyBuilder);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test)

Example 3 with InvalidTransactionException

use of com.hedera.services.exceptions.InvalidTransactionException in project hedera-services by hashgraph.

the class DissociatePrecompilesTest method dissociateTokenFailurePathWorks.

@Test
void dissociateTokenFailurePathWorks() {
    givenFrameContext();
    given(pretendArguments.getInt(0)).willReturn(ABI_ID_DISSOCIATE_TOKEN);
    given(sigsVerifier.hasActiveKey(accountAddr, contractAddr, contractAddr, senderAddr, aliases)).willThrow(new InvalidTransactionException(INVALID_SIGNATURE));
    given(creator.createUnsuccessfulSyntheticRecord(INVALID_SIGNATURE)).willReturn(mockRecordBuilder);
    given(decoder.decodeDissociate(eq(pretendArguments), any())).willReturn(dissociateToken);
    given(feeCalculator.estimatedGasPriceInTinybars(HederaFunctionality.ContractCall, timestamp)).willReturn(1L);
    given(mockSynthBodyBuilder.build()).willReturn(TransactionBody.newBuilder().build());
    given(mockSynthBodyBuilder.setTransactionID(any(TransactionID.class))).willReturn(mockSynthBodyBuilder);
    given(feeCalculator.computeFee(any(), any(), any(), any())).willReturn(mockFeeObject);
    given(mockFeeObject.getServiceFee()).willReturn(1L);
    given(syntheticTxnFactory.createDissociate(dissociateToken)).willReturn(mockSynthBodyBuilder);
    // when:
    subject.prepareFields(frame);
    subject.prepareComputation(pretendArguments, a -> a);
    subject.computeGasRequirement(TEST_CONSENSUS_TIME);
    final var result = subject.computeInternal(frame);
    // then:
    assertEquals(invalidSigResult, result);
    verify(worldUpdater).manageInProgressRecord(recordsHistorian, mockRecordBuilder, mockSynthBodyBuilder);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test)

Example 4 with InvalidTransactionException

use of com.hedera.services.exceptions.InvalidTransactionException in project hedera-services by hashgraph.

the class TokenFreezeTransitionLogicTest method capturesInvalidFreeze.

@Test
void capturesInvalidFreeze() {
    givenValidTxnCtx();
    // and:
    doThrow(new InvalidTransactionException(TOKEN_HAS_NO_FREEZE_KEY)).when(tokenRelationship).changeFrozenState(true);
    // verify:
    assertFailsWith(() -> subject.doStateTransition(), TOKEN_HAS_NO_FREEZE_KEY);
    verify(tokenStore, never()).commitTokenRelationships(List.of(tokenRelationship));
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 5 with InvalidTransactionException

use of com.hedera.services.exceptions.InvalidTransactionException in project hedera-services by hashgraph.

the class TokenUnfreezeTransitionLogicTest method capturesInvalidUnfreeze.

@Test
void capturesInvalidUnfreeze() {
    givenValidTxnCtx();
    // and:
    doThrow(new InvalidTransactionException(TOKEN_HAS_NO_FREEZE_KEY)).when(tokenRelationship).changeFrozenState(false);
    // verify:
    assertFailsWith(() -> subject.doStateTransition(), TOKEN_HAS_NO_FREEZE_KEY);
    verify(tokenStore, never()).commitTokenRelationships(List.of(tokenRelationship));
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Aggregations

InvalidTransactionException (com.hedera.services.exceptions.InvalidTransactionException)26 Test (org.junit.jupiter.api.Test)24 TransactionID (com.hederahashgraph.api.proto.java.TransactionID)4 JContractIDKey (com.hedera.services.legacy.core.jproto.JContractIDKey)1 JEd25519Key (com.hedera.services.legacy.core.jproto.JEd25519Key)1 HederaWorldState (com.hedera.services.store.contracts.HederaWorldState)1 HederaWorldUpdater (com.hedera.services.store.contracts.HederaWorldUpdater)1 Key (com.hederahashgraph.api.proto.java.Key)1 ArrayDeque (java.util.ArrayDeque)1 Map (java.util.Map)1 Bytes (org.apache.tuweni.bytes.Bytes)1 Address (org.hyperledger.besu.datatypes.Address)1 Wei (org.hyperledger.besu.datatypes.Wei)1 Gas (org.hyperledger.besu.evm.Gas)1 MutableAccount (org.hyperledger.besu.evm.account.MutableAccount)1 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)1