Search in sources :

Example 86 with Transaction

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

the class EntityRecordItemListenerTokenTest method tokenMint.

@Test
void tokenMint() {
    createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
    long amount = 1000;
    long mintTimestamp = 10L;
    TokenTransferList tokenTransfer = tokenTransfer(TOKEN_ID, PAYER, amount);
    Transaction transaction = tokenSupplyTransaction(TOKEN_ID, FUNGIBLE_COMMON, true, amount, null);
    insertAndParseTransaction(mintTimestamp, transaction, builder -> {
        builder.getReceiptBuilder().setNewTotalSupply(INITIAL_SUPPLY + amount);
        builder.addTokenTransferLists(tokenTransfer);
    });
    // Verify
    assertThat(tokenTransferRepository.count()).isEqualTo(2L);
    assertTokenTransferInRepository(TOKEN_ID, PAYER, CREATE_TIMESTAMP, INITIAL_SUPPLY);
    assertTokenTransferInRepository(TOKEN_ID, PAYER, mintTimestamp, amount);
    assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, mintTimestamp, SYMBOL, INITIAL_SUPPLY + amount);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 87 with Transaction

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

the class EntityRecordItemListenerTokenTest method tokenBurn.

@Test
void tokenBurn() {
    // given
    createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
    long amount = -1000;
    long burnTimestamp = 10L;
    TokenTransferList tokenTransfer = tokenTransfer(TOKEN_ID, PAYER, amount);
    Transaction transaction = tokenSupplyTransaction(TOKEN_ID, FUNGIBLE_COMMON, false, amount, null);
    // when
    insertAndParseTransaction(burnTimestamp, transaction, builder -> {
        builder.getReceiptBuilder().setNewTotalSupply(INITIAL_SUPPLY - amount);
        builder.addTokenTransferLists(tokenTransfer);
    });
    // then
    assertThat(tokenTransferRepository.count()).isEqualTo(2L);
    assertTokenTransferInRepository(TOKEN_ID, PAYER, CREATE_TIMESTAMP, INITIAL_SUPPLY);
    assertTokenTransferInRepository(TOKEN_ID, PAYER, burnTimestamp, amount);
    assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, burnTimestamp, SYMBOL, INITIAL_SUPPLY - amount);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 88 with Transaction

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

the class EntityRecordItemListenerTokenTest method createAndAssociateToken.

private void createAndAssociateToken(TokenID tokenID, TokenType tokenType, String symbol, long createTimestamp, long associateTimestamp, AccountID accountID, boolean setFreezeKey, boolean setKycKey, boolean setPauseKey, long initialSupply) {
    createTokenEntity(tokenID, tokenType, symbol, createTimestamp, setFreezeKey, setKycKey, setPauseKey);
    assertTokenInRepository(tokenID, true, createTimestamp, createTimestamp, symbol, initialSupply, setPauseKey ? TokenPauseStatusEnum.UNPAUSED : TokenPauseStatusEnum.NOT_APPLICABLE);
    Transaction associateTransaction = tokenAssociate(List.of(tokenID), accountID);
    insertAndParseTransaction(associateTimestamp, associateTransaction);
    assertTokenAccountInRepository(tokenID, accountID, associateTimestamp, associateTimestamp, true, setFreezeKey ? TokenFreezeStatusEnum.UNFROZEN : TokenFreezeStatusEnum.NOT_APPLICABLE, setKycKey ? TokenKycStatusEnum.REVOKED : TokenKycStatusEnum.NOT_APPLICABLE);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction)

Example 89 with Transaction

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

the class EntityRecordItemListenerTokenTest method tokenAssociatePrecompile.

@Test
void tokenAssociatePrecompile() {
    createTokenEntity(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, true, true, true);
    Transaction associateTransaction = tokenAssociate(List.of(TOKEN_ID), PAYER2);
    AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
    insertAndParseTransaction(ASSOCIATE_TIMESTAMP, associateTransaction, builder -> {
        buildContractFunctionResult(builder.getContractCallResultBuilder());
        contractFunctionResultAtomic.set(builder.getContractCallResult());
    });
    assertTokenAccountInRepository(TOKEN_ID, PAYER2, ASSOCIATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, true, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.REVOKED);
    assertContractResult(ASSOCIATE_TIMESTAMP, contractFunctionResultAtomic.get());
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 90 with Transaction

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

the class EntityRecordItemListenerTokenTest method tokenAccountUnfreeze.

@Test
void tokenAccountUnfreeze() {
    // create token with freeze default
    createTokenEntity(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, true, false, false);
    // associate account
    Transaction associateTransaction = tokenAssociate(List.of(TOKEN_ID), PAYER2);
    insertAndParseTransaction(ASSOCIATE_TIMESTAMP, associateTransaction);
    Transaction freezeTransaction = tokenFreezeTransaction(TOKEN_ID, true);
    long freezeTimeStamp = 10L;
    insertAndParseTransaction(freezeTimeStamp, freezeTransaction);
    // unfreeze
    Transaction unfreezeTransaction = tokenFreezeTransaction(TOKEN_ID, false);
    long unfreezeTimeStamp = 444;
    insertAndParseTransaction(unfreezeTimeStamp, unfreezeTransaction);
    assertTokenAccountInRepository(TOKEN_ID, PAYER2, ASSOCIATE_TIMESTAMP, unfreezeTimeStamp, true, TokenFreezeStatusEnum.UNFROZEN, TokenKycStatusEnum.NOT_APPLICABLE);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Transaction (com.hederahashgraph.api.proto.java.Transaction)174 Test (org.junit.jupiter.api.Test)128 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)108 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)93 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)91 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)84 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)63 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)28 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)25 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)25 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)25 Entity (com.hedera.mirror.common.domain.entity.Entity)22 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)21 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)18 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)17 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)17