use of com.hedera.services.store.models.Id in project hedera-services by hashgraph.
the class FixedFeeSpecTest method finalizationWorksWithFungibleDenomAtCreation.
@Test
void finalizationWorksWithFungibleDenomAtCreation() {
given(token.isFungibleCommon()).willReturn(true);
given(tokenStore.loadTokenOrFailWith(new Id(0, 0, otherDenom.num()), INVALID_TOKEN_ID_IN_CUSTOM_FEES)).willReturn(token);
given(feeCollector.isAssociatedWith(otherDenom.asId())).willReturn(true);
final var otherDenomSubject = new FixedFeeSpec(123, otherDenom);
assertDoesNotThrow(() -> otherDenomSubject.validateAndFinalizeWith(token, feeCollector, tokenStore));
}
use of com.hedera.services.store.models.Id in project hedera-services by hashgraph.
the class FixedFeeSpecTest method validationRequiresAssociatedFeeCollector.
@Test
void validationRequiresAssociatedFeeCollector() {
given(tokenStore.loadTokenOrFailWith(new Id(0, 0, otherDenom.num()), INVALID_TOKEN_ID_IN_CUSTOM_FEES)).willReturn(token);
given(token.isFungibleCommon()).willReturn(true);
final var otherDenomSubject = new FixedFeeSpec(123, otherDenom);
assertFailsWith(() -> otherDenomSubject.validateWith(feeCollector, tokenStore), TOKEN_NOT_ASSOCIATED_TO_FEE_COLLECTOR);
}
use of com.hedera.services.store.models.Id in project hedera-services by hashgraph.
the class FixedFeeSpecTest method validationRequiresFungibleDenom.
@Test
void validationRequiresFungibleDenom() {
given(tokenStore.loadTokenOrFailWith(new Id(0, 0, otherDenom.num()), INVALID_TOKEN_ID_IN_CUSTOM_FEES)).willReturn(token);
final var otherDenomSubject = new FixedFeeSpec(123, otherDenom);
assertFailsWith(() -> otherDenomSubject.validateWith(feeCollector, tokenStore), CUSTOM_FEE_DENOMINATION_MUST_BE_FUNGIBLE_COMMON);
}
use of com.hedera.services.store.models.Id in project hedera-services by hashgraph.
the class ContractCallTransitionLogicTest method verifyExternaliseContractResultCall.
@Test
void verifyExternaliseContractResultCall() {
// setup:
givenValidTxnCtx();
// and:
given(accessor.getTxn()).willReturn(contractCallTxn);
given(txnCtx.accessor()).willReturn(accessor);
// and:
given(accountStore.loadAccount(senderAccount.getId())).willReturn(senderAccount);
given(accountStore.loadContract(new Id(target.getShardNum(), target.getRealmNum(), target.getContractNum()))).willReturn(contractAccount);
// and:
var results = TransactionProcessingResult.successful(null, 1234L, 0L, 124L, Bytes.EMPTY, contractAccount.getId().asEvmAddress(), Map.of());
given(evmTxProcessor.execute(senderAccount, contractAccount.getId().asEvmAddress(), gas, sent, Bytes.EMPTY, txnCtx.consensusTime())).willReturn(results);
given(worldState.persistProvisionalContractCreations()).willReturn(List.of(target));
// when:
subject.doStateTransition();
// then:
verify(recordService).externaliseEvmCallTransaction(any());
verify(worldState).persistProvisionalContractCreations();
verify(txnCtx).setTargetedContract(target);
}
use of com.hedera.services.store.models.Id in project hedera-services by hashgraph.
the class CryptoApproveAllowanceTransitionLogic method doStateTransition.
@Override
public void doStateTransition() {
/* --- Extract gRPC --- */
final TransactionBody cryptoApproveAllowanceTxn = txnCtx.accessor().getTxn();
final AccountID payer = cryptoApproveAllowanceTxn.getTransactionID().getAccountID();
final var op = cryptoApproveAllowanceTxn.getCryptoApproveAllowance();
entitiesChanged.clear();
/* --- Use models --- */
final Id payerId = Id.fromGrpcAccount(payer);
final var payerAccount = accountStore.loadAccount(payerId);
/* --- Do the business logic --- */
applyCryptoAllowances(op.getCryptoAllowancesList(), payerAccount);
applyFungibleTokenAllowances(op.getTokenAllowancesList(), payerAccount);
applyNftAllowances(op.getNftAllowancesList(), payerAccount);
/* --- Persist the payer account --- */
for (final var entry : entitiesChanged.entrySet()) {
accountStore.commitAccount(entry.getValue());
}
txnCtx.setStatus(SUCCESS);
}
Aggregations