Search in sources :

Example 41 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method lookupAccountThrows.

@Test
void lookupAccountThrows() {
    AccountID accountId = AccountID.newBuilder().setRealmNum(1).build();
    assertThrows(InvalidDatasetException.class, () -> entityIdService.lookup(accountId));
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method lookupAccountNum.

@Test
void lookupAccountNum() {
    AccountID accountId = AccountID.newBuilder().setAccountNum(100).build();
    assertThat(entityIdService.lookup(accountId)).isEqualTo(EntityId.of(100, ACCOUNT));
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method lookupAccountWithEvmAddress.

@Test
void lookupAccountWithEvmAddress() {
    AccountID accountId = AccountID.newBuilder().setAlias(DomainUtils.fromBytes(PARSABLE_EVM_ADDRESS)).build();
    assertThat(entityIdService.lookup(accountId)).isEqualTo(EntityId.of(100, CONTRACT));
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method lookupAccounts.

@Test
void lookupAccounts() {
    AccountID nullAccountId = null;
    AccountID accountId = AccountID.newBuilder().setAccountNum(100).build();
    AccountID accountIdInvalid = AccountID.newBuilder().setRealmNum(1).build();
    Entity accountDeleted = domainBuilder.entity().customize(e -> e.deleted(true)).persist();
    EntityId entityId = entityIdService.lookup(nullAccountId, AccountID.getDefaultInstance(), getProtoAccountId(accountDeleted), accountIdInvalid, accountId);
    assertThat(entityId).isEqualTo(EntityId.of(accountId));
}
Also used : CsvSource(org.junit.jupiter.params.provider.CsvSource) DomainUtils(com.hedera.mirror.common.util.DomainUtils) Contract(com.hedera.mirror.common.domain.contract.Contract) EntityId(com.hedera.mirror.common.domain.entity.EntityId) ContractRepository(com.hedera.mirror.importer.repository.ContractRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Entity(com.hedera.mirror.common.domain.entity.Entity) CONTRACT(com.hedera.mirror.common.domain.entity.EntityType.CONTRACT) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ContractID(com.hederahashgraph.api.proto.java.ContractID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Assertions(org.junit.jupiter.api.Assertions) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) AccountID(com.hederahashgraph.api.proto.java.AccountID) InvalidDatasetException(com.hedera.mirror.importer.exception.InvalidDatasetException) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 45 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-mirror-node by hashgraph.

the class TokenUpdateTransactionHandlerTest method updateTreasury.

@Test
void updateTreasury() {
    AbstractEntity entity = getExpectedUpdatedEntity();
    AccountID previousAccountId = AccountID.newBuilder().setAccountNum(1L).build();
    AccountID newAccountId = AccountID.newBuilder().setAccountNum(2L).build();
    TokenID tokenID = TokenID.newBuilder().setTokenNum(3L).build();
    long consensusTimestamp = DomainUtils.timestampInNanosMax(MODIFIED_TIMESTAMP);
    TokenTransferList tokenTransferList = TokenTransferList.newBuilder().setToken(tokenID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(newAccountId).setSenderAccountID(previousAccountId).setSerialNumber(NftTransferId.WILDCARD_SERIAL_NUMBER).build()).build();
    TransactionRecord record = getDefaultTransactionRecord().addTokenTransferLists(tokenTransferList).build();
    RecordItem recordItem = getRecordItem(getDefaultTransactionBody().build(), record);
    when(entityIdService.lookup(AccountID.newBuilder().setAccountNum(DEFAULT_AUTO_RENEW_ACCOUNT_NUM).build())).thenReturn(EntityIdEndec.decode(DEFAULT_AUTO_RENEW_ACCOUNT_NUM, EntityType.ACCOUNT));
    Transaction transaction = new Transaction();
    transaction.setEntityId(entity.toEntityId());
    transactionHandler.updateTransaction(transaction, recordItem);
    TransactionBody body = recordItem.getTransactionBody();
    var payerAccount = EntityId.of(body.getTransactionID().getAccountID()).toEntity().getId();
    verify(nftRepository).updateTreasury(tokenID.getTokenNum(), previousAccountId.getAccountNum(), newAccountId.getAccountNum(), consensusTimestamp, payerAccount, false);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) AccountID(com.hederahashgraph.api.proto.java.AccountID) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) TokenID(com.hederahashgraph.api.proto.java.TokenID) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)71 Test (org.junit.jupiter.api.Test)24 List (java.util.List)21 ByteString (com.google.protobuf.ByteString)20 Assertions (org.junit.jupiter.api.Assertions)20 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)17 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)16 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)15 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)15 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)15 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)14 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)13 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)13 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)13 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)13 TxnVerbs.mintToken (com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken)13 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)12 QueryVerbs.getScheduleInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo)12