Search in sources :

Example 26 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class SqlEntityListenerTest method onTokenAccountMissingToken.

@Test
void onTokenAccountMissingToken() {
    EntityId tokenId1 = EntityId.of("0.0.3", TOKEN);
    EntityId accountId1 = EntityId.of("0.0.7", ACCOUNT);
    // given no token row in db
    // when
    TokenAccount associate = getTokenAccount(tokenId1, accountId1, 10L, 10L, true, false, null, null);
    sqlEntityListener.onTokenAccount(associate);
    TokenAccount kycGrant = getTokenAccount(tokenId1, accountId1, null, 15L, null, null, null, TokenKycStatusEnum.GRANTED);
    sqlEntityListener.onTokenAccount(kycGrant);
    completeFileAndCommit();
    // then
    assertThat(tokenAccountRepository.count()).isZero();
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class SqlEntityListenerTest method onTokenAccount.

@Test
void onTokenAccount() {
    EntityId tokenId1 = EntityId.of("0.0.3", TOKEN);
    EntityId tokenId2 = EntityId.of("0.0.5", TOKEN);
    // save token entities first
    Token token1 = getToken(tokenId1, EntityId.of("0.0.500", ACCOUNT), 1L, 1L);
    Token token2 = getToken(tokenId2, EntityId.of("0.0.110", ACCOUNT), 2L, 2L);
    sqlEntityListener.onToken(token1);
    sqlEntityListener.onToken(token2);
    completeFileAndCommit();
    EntityId accountId1 = EntityId.of("0.0.7", ACCOUNT);
    EntityId accountId2 = EntityId.of("0.0.11", ACCOUNT);
    TokenAccount tokenAccount1 = getTokenAccount(tokenId1, accountId1, 5L, 5L, true, false, TokenFreezeStatusEnum.NOT_APPLICABLE, TokenKycStatusEnum.NOT_APPLICABLE);
    TokenAccount tokenAccount2 = getTokenAccount(tokenId2, accountId2, 6L, 6L, true, false, TokenFreezeStatusEnum.NOT_APPLICABLE, TokenKycStatusEnum.NOT_APPLICABLE);
    // when
    sqlEntityListener.onTokenAccount(tokenAccount1);
    sqlEntityListener.onTokenAccount(tokenAccount1);
    sqlEntityListener.onTokenAccount(tokenAccount2);
    completeFileAndCommit();
    // then
    assertThat(tokenAccountRepository.findAll()).containsExactlyInAnyOrder(tokenAccount1, tokenAccount2);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) Token(com.hedera.mirror.common.domain.token.Token) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)27 EntityId (com.hedera.mirror.common.domain.entity.EntityId)18 Test (org.junit.jupiter.api.Test)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 Token (com.hedera.mirror.common.domain.token.Token)8 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)8 Transaction (com.hederahashgraph.api.proto.java.Transaction)2 ArrayList (java.util.ArrayList)2 ByteString (com.google.protobuf.ByteString)1 Entity (com.hedera.mirror.common.domain.entity.Entity)1 TokenAccountKey (com.hedera.mirror.common.domain.token.TokenAccountKey)1 TokenFreezeStatusEnum (com.hedera.mirror.common.domain.token.TokenFreezeStatusEnum)1 TokenId (com.hedera.mirror.common.domain.token.TokenId)1 TokenKycStatusEnum (com.hedera.mirror.common.domain.token.TokenKycStatusEnum)1 TokenPauseStatusEnum (com.hedera.mirror.common.domain.token.TokenPauseStatusEnum)1 TokenTransfer (com.hedera.mirror.common.domain.token.TokenTransfer)1 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 ContractFunctionResult (com.hederahashgraph.api.proto.java.ContractFunctionResult)1 TokenAssociateTransactionBody (com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody)1