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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations