Search in sources :

Example 6 with InvalidTransactionException

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

the class TokenUnpauseTransitionLogicTest method capturesInvalidPause.

@Test
void capturesInvalidPause() {
    givenValidTxnCtx();
    doThrow(new InvalidTransactionException(TOKEN_HAS_NO_PAUSE_KEY)).when(token).changePauseStatus(false);
    assertFailsWith(() -> subject.doStateTransition(), TOKEN_HAS_NO_PAUSE_KEY);
    verify(tokenStore, never()).commitToken(token);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 7 with InvalidTransactionException

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

the class CallLocalExecutorTest method catchesInvalidTransactionException.

@Test
void catchesInvalidTransactionException() {
    // setup:
    given(accountStore.loadAccount(any())).willThrow(new InvalidTransactionException(INVALID_ACCOUNT_ID));
    // when:
    final var result = CallLocalExecutor.execute(accountStore, evmTxProcessor, query, aliasManager);
    assertEquals(failedResponse(INVALID_ACCOUNT_ID), result);
    // and:
    verifyNoInteractions(evmTxProcessor);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 8 with InvalidTransactionException

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

the class TransitionRunnerTest method reclaimsIdsOnFailedTransaction.

@Test
void reclaimsIdsOnFailedTransaction() {
    given(accessor.getFunction()).willReturn(TokenCreate);
    given(accessor.getTxn()).willReturn(mockBody);
    given(lookup.lookupFor(TokenCreate, mockBody)).willReturn(Optional.of(logic));
    given(logic.validateSemantics(accessor)).willReturn(OK);
    doThrow(new InvalidTransactionException(FAIL_INVALID)).when(logic).doStateTransition();
    subject.tryTransition(accessor);
    verify(txnCtx).setStatus(FAIL_INVALID);
    verify(ids).reclaimProvisionalIds();
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 9 with InvalidTransactionException

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

the class TransitionRunnerTest method catchesInvalidTxnExceptionAndSetsStatus.

@Test
void catchesInvalidTxnExceptionAndSetsStatus() {
    given(accessor.getFunction()).willReturn(TokenMint);
    given(accessor.getTxn()).willReturn(mockBody);
    given(lookup.lookupFor(TokenMint, mockBody)).willReturn(Optional.of(logic));
    given(logic.validateSemantics(accessor)).willReturn(OK);
    willThrow(new InvalidTransactionException(INVALID_TOKEN_MINT_AMOUNT)).given(logic).doStateTransition();
    // when:
    var result = subject.tryTransition(accessor);
    // then:
    verify(txnCtx).setStatus(INVALID_TOKEN_MINT_AMOUNT);
    verify(ids).reclaimProvisionalIds();
    assertTrue(result);
}
Also used : InvalidTransactionException(com.hedera.services.exceptions.InvalidTransactionException) Test(org.junit.jupiter.api.Test)

Example 10 with InvalidTransactionException

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

the class TopicCreateTransitionLogicTest method detachedAutoRenewAccountId.

@Test
void detachedAutoRenewAccountId() {
    givenTransactionWithDetachedAutoRenewAccountId();
    given(validator.memoCheck(anyString())).willReturn(OK);
    given(transactionContext.accessor()).willReturn(accessor);
    given(accessor.getTxn()).willReturn(transactionBody);
    given(validator.isValidAutoRenewPeriod(Duration.newBuilder().setSeconds(VALID_AUTORENEW_PERIOD_SECONDS).build())).willReturn(true);
    given(accountStore.loadAccountOrFailWith(any(), any())).willThrow(new InvalidTransactionException(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL));
    assertFailsWith(() -> subject.doStateTransition(), ACCOUNT_EXPIRED_AND_PENDING_REMOVAL);
    assertTrue(topics.isEmpty());
}
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