Search in sources :

Example 36 with AccountID

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

the class CryptoCreateTransactionHandlerTest method updateTransactionStakedAccountId.

@Test
void updateTransactionStakedAccountId() {
    // given
    final AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
    var recordItem = recordItemBuilder.cryptoCreate().transactionBody(b -> b.setDeclineReward(false).setStakedAccountId(accountId)).build();
    // when
    transactionHandler.updateTransaction(transaction(recordItem), recordItem);
    // then
    verify(entityListener).onEntity(entities.capture());
    assertThat(entities.getValue()).isNotNull().returns(false, Entity::isDeclineReward).returns(accountId.getAccountNum(), Entity::getStakedAccountId).returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Entity::getStakePeriodStart);
}
Also used : CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Captor(org.mockito.Captor) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verify(org.mockito.Mockito.verify) TransactionReceipt(com.hederahashgraph.api.proto.java.TransactionReceipt) Entity(com.hedera.mirror.common.domain.entity.Entity) Test(org.junit.jupiter.api.Test) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) List(java.util.List) UtilityTest(com.hedera.mirror.importer.util.UtilityTest) ArgumentCaptor(org.mockito.ArgumentCaptor) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Message(com.google.protobuf.Message) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountID(com.hederahashgraph.api.proto.java.AccountID) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) Utility(com.hedera.mirror.importer.util.Utility) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test) UtilityTest(com.hedera.mirror.importer.util.UtilityTest)

Example 37 with AccountID

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

the class CryptoUpdateTransactionHandlerTest method updateTransactionStakedAccountId.

@Test
void updateTransactionStakedAccountId() {
    AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
    RecordItem withStakedNodeIdSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setStakedAccountId(accountId)).build();
    setupForCrytoUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Entity::getStakedAccountId).returns(false, Entity::isDeclineReward).returns(-1L, Entity::getStakedNodeId).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Entity::getStakePeriodStart));
}
Also used : CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) BoolValue(com.google.protobuf.BoolValue) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Range(com.google.common.collect.Range) Mockito.times(org.mockito.Mockito.times) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Assertions(org.junit.jupiter.api.Assertions) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountID(com.hederahashgraph.api.proto.java.AccountID) Utility(com.hedera.mirror.importer.util.Utility) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Example 38 with AccountID

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

the class UtilityTest method getTransactionID.

@Test
@DisplayName("get TransactionId")
void getTransactionID() {
    AccountID payerAccountId = AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(2).build();
    TransactionID transactionId = Utility.getTransactionId(payerAccountId);
    assertThat(transactionId).isNotEqualTo(TransactionID.getDefaultInstance());
    AccountID testAccountId = transactionId.getAccountID();
    assertAll(// row counts
    () -> assertEquals(payerAccountId.getShardNum(), testAccountId.getShardNum()), () -> assertEquals(payerAccountId.getRealmNum(), testAccountId.getRealmNum()), () -> assertEquals(payerAccountId.getAccountNum(), testAccountId.getAccountNum()));
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 39 with AccountID

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

the class HistoricalAccountInfoMigrationTest method emptyValues.

@Test
void emptyValues() {
    AccountID accountId = AccountID.newBuilder().setAccountNum(ACCOUNT_ID1).build();
    AccountInfo.Builder accountInfo = accountInfo().clear().setAccountID(accountId);
    assertThat(historicalAccountInfoMigration.process(accountInfo.build())).isTrue();
    assertThat(entityRepository.findById(ACCOUNT_ID1)).get().returns(null, from(Entity::getAutoRenewPeriod)).returns(false, from(Entity::getDeleted)).returns(null, from(Entity::getPublicKey)).returns(null, from(Entity::getExpirationTimestamp)).returns(null, from(Entity::getKey)).returns("", from(Entity::getMemo)).returns(null, from(Entity::getProxyAccountId));
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) AccountInfo(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 40 with AccountID

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

the class EntityIdServiceImplTest method lookupAccountsReturnsFirst.

@Test
void lookupAccountsReturnsFirst() {
    AccountID accountId1 = AccountID.newBuilder().setAccountNum(100).build();
    AccountID accountId2 = AccountID.newBuilder().setAccountNum(101).build();
    EntityId entityId = entityIdService.lookup(accountId1, accountId2);
    assertThat(entityId).isEqualTo(EntityId.of(accountId1));
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) 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)

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