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