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