use of com.hedera.mirror.common.domain.token.Token in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onToken.
@Test
void onToken() {
Token token1 = getToken(EntityId.of("0.0.3", TOKEN), EntityId.of("0.0.5", ACCOUNT), 1L, 1L);
Token token2 = getToken(EntityId.of("0.0.7", TOKEN), EntityId.of("0.0.11", ACCOUNT), 2L, 2L);
// when
sqlEntityListener.onToken(token1);
sqlEntityListener.onToken(token2);
completeFileAndCommit();
// then
assertThat(tokenRepository.findAll()).containsExactlyInAnyOrder(token1, token2);
}
use of com.hedera.mirror.common.domain.token.Token in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onTokenAccountSpanningRecordFiles.
@Test
void onTokenAccountSpanningRecordFiles() {
List<TokenAccount> expected = new ArrayList<>();
EntityId tokenId1 = EntityId.of("0.0.3", TOKEN);
EntityId accountId1 = EntityId.of("0.0.7", ACCOUNT);
// given token in db
Token token = getToken(tokenId1, EntityId.of("0.0.500", ACCOUNT), 1L, 1L);
tokenRepository.save(token);
// given association in a previous record file
TokenAccount associate = getTokenAccount(tokenId1, accountId1, 5L, 5L, true, false, null, null);
sqlEntityListener.onTokenAccount(associate);
expected.add(getTokenAccount(tokenId1, accountId1, 5L, 5L, true, false, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.REVOKED));
completeFileAndCommit();
// when in the next record file we have freeze, kycGrant, dissociate, associate, kycGrant
TokenAccount freeze = getTokenAccount(tokenId1, accountId1, null, 10L, null, null, TokenFreezeStatusEnum.FROZEN, null);
sqlEntityListener.onTokenAccount(freeze);
expected.add(getTokenAccount(tokenId1, accountId1, 5L, 10L, true, false, TokenFreezeStatusEnum.FROZEN, TokenKycStatusEnum.REVOKED));
TokenAccount kycGrant = getTokenAccount(tokenId1, accountId1, null, 12L, null, null, null, TokenKycStatusEnum.GRANTED);
sqlEntityListener.onTokenAccount(kycGrant);
expected.add(getTokenAccount(tokenId1, accountId1, 5L, 12L, true, false, TokenFreezeStatusEnum.FROZEN, TokenKycStatusEnum.GRANTED));
TokenAccount dissociate = getTokenAccount(tokenId1, accountId1, null, 15L, false, null, null, null);
sqlEntityListener.onTokenAccount(dissociate);
expected.add(getTokenAccount(tokenId1, accountId1, 5L, 15L, false, false, TokenFreezeStatusEnum.FROZEN, TokenKycStatusEnum.GRANTED));
associate = getTokenAccount(tokenId1, accountId1, 20L, 20L, true, true, null, null);
sqlEntityListener.onTokenAccount(associate);
expected.add(getTokenAccount(tokenId1, accountId1, 20L, 20L, true, true, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.REVOKED));
kycGrant = getTokenAccount(tokenId1, accountId1, null, 22L, null, null, null, TokenKycStatusEnum.GRANTED);
sqlEntityListener.onTokenAccount(kycGrant);
expected.add(getTokenAccount(tokenId1, accountId1, 20L, 22L, true, true, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.GRANTED));
completeFileAndCommit();
// then
assertThat(tokenAccountRepository.findAll()).containsExactlyInAnyOrderElementsOf(expected);
}
use of com.hedera.mirror.common.domain.token.Token in project hedera-mirror-node by hashgraph.
the class TokenRepositoryTest method nullCharacter.
@Test
void nullCharacter() {
Token token = token(1);
token.setName("abc" + (char) 0);
token.setSymbol("abc" + (char) 0);
tokenRepository.save(token);
assertThat(tokenRepository.findById(token.getTokenId())).get().isEqualTo(token);
}
use of com.hedera.mirror.common.domain.token.Token in project hedera-mirror-node by hashgraph.
the class TokenRepositoryTest method save.
@Test
void save() {
Token token = tokenRepository.save(token(1));
assertThat(tokenRepository.findById(token.getTokenId())).get().isEqualTo(token);
}
use of com.hedera.mirror.common.domain.token.Token in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenUnpause.
private void insertTokenUnpause(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
long consensusTimestamp = recordItem.getConsensusTimestamp();
TokenUnpauseTransactionBody transactionBody = recordItem.getTransactionBody().getTokenUnpause();
Token token = Token.of(EntityId.of(transactionBody.getToken()));
token.setPauseStatus(TokenPauseStatusEnum.UNPAUSED);
updateToken(token, consensusTimestamp);
}
}
Aggregations