use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenPause.
@Test
void tokenPause() {
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, true, INITIAL_SUPPLY);
Transaction transaction = tokenPauseTransaction(TOKEN_ID, true);
long pauseTimeStamp = 15L;
insertAndParseTransaction(pauseTimeStamp, transaction);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, pauseTimeStamp, SYMBOL, INITIAL_SUPPLY, TokenPauseStatusEnum.PAUSED);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenUnpause.
@Test
void tokenUnpause() {
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, true, INITIAL_SUPPLY);
Transaction transaction = tokenPauseTransaction(TOKEN_ID, true);
insertAndParseTransaction(15L, transaction);
transaction = tokenPauseTransaction(TOKEN_ID, false);
long unpauseTimeStamp = 20L;
insertAndParseTransaction(unpauseTimeStamp, transaction);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, unpauseTimeStamp, SYMBOL, INITIAL_SUPPLY, TokenPauseStatusEnum.UNPAUSED);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenUpdateWithMissingToken.
@Test
void tokenUpdateWithMissingToken() {
String newSymbol = "NEWSYMBOL";
Transaction transaction = tokenUpdateTransaction(TOKEN_ID, newSymbol, TOKEN_UPDATE_MEMO, keyFromString("updated-key"), AccountID.newBuilder().setAccountNum(2002).build(), PAYER2);
insertAndParseTransaction(10L, transaction);
// verify token was not created when missing
assertTokenInRepository(TOKEN_ID, false, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, SYMBOL, INITIAL_SUPPLY);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenTransfersMustHaveCorrectIsApprovalValue.
@Test
void tokenTransfersMustHaveCorrectIsApprovalValue() {
// given
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
TokenID tokenId2 = TokenID.newBuilder().setTokenNum(7).build();
createTokenEntity(tokenId2, FUNGIBLE_COMMON, "MIRROR", 10L, false, false, false);
AccountID accountId = AccountID.newBuilder().setAccountNum(1).build();
TokenTransferList transferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addTransfers(AccountAmount.newBuilder().setAccountID(PAYER).setAmount(-1000).build()).addTransfers(AccountAmount.newBuilder().setAccountID(PAYER2).setAmount(-100).build()).addTransfers(AccountAmount.newBuilder().setAccountID(accountId).setAmount(1000).build()).build();
TokenTransferList transferList2 = TokenTransferList.newBuilder().setToken(tokenId2).addTransfers(AccountAmount.newBuilder().setAccountID(PAYER).setAmount(333).build()).addTransfers(AccountAmount.newBuilder().setAccountID(accountId).setAmount(-333).build()).build();
List<TokenTransferList> transferLists = List.of(transferList1, transferList2);
// when
Transaction transaction = buildTransaction(builder -> {
TokenTransferList bodyTransferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addTransfers(AccountAmount.newBuilder().setAccountID(PAYER).setAmount(-600).setIsApproval(true).build()).addTransfers(AccountAmount.newBuilder().setAccountID(PAYER2).setAmount(-100).setIsApproval(true).build()).addTransfers(AccountAmount.newBuilder().setAccountID(accountId).setAmount(-333).build()).build();
builder.getCryptoTransferBuilder().addTokenTransfers(bodyTransferList1);
});
insertAndParseTransaction(TRANSFER_TIMESTAMP, transaction, builder -> {
builder.addAllTokenTransferLists(transferLists);
});
// then
assertTokenTransferInRepository(TOKEN_ID, PAYER, TRANSFER_TIMESTAMP, -1000, true);
assertTokenTransferInRepository(TOKEN_ID, PAYER2, TRANSFER_TIMESTAMP, -100, true);
assertTokenTransferInRepository(TOKEN_ID, accountId, TRANSFER_TIMESTAMP, 1000);
assertTokenTransferInRepository(tokenId2, PAYER, TRANSFER_TIMESTAMP, 333);
assertTokenTransferInRepository(tokenId2, accountId, TRANSFER_TIMESTAMP, -333);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenDissociateDeletedNonFungibleToken.
@Test
void tokenDissociateDeletedNonFungibleToken() {
// given
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
// mint
long mintTimestamp = 10L;
TokenTransferList mintTransfer = nftTransfer(TOKEN_ID, PAYER, DEFAULT_ACCOUNT_ID, SERIAL_NUMBER_LIST);
Transaction mintTransaction = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, SERIAL_NUMBER_LIST);
insertAndParseTransaction(mintTimestamp, mintTransaction, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(SERIAL_NUMBER_LIST.size()).addAllSerialNumbers(SERIAL_NUMBER_LIST);
builder.addTokenTransferLists(mintTransfer);
});
// transfer
long transferTimestamp = 15L;
TokenTransferList nftTransfer = nftTransfer(TOKEN_ID, PAYER2, PAYER, List.of(1L));
insertAndParseTransaction(transferTimestamp, tokenTransferTransaction(), builder -> builder.addTokenTransferLists(nftTransfer));
// delete
long tokenDeleteTimestamp = 20L;
Transaction deleteTransaction = tokenDeleteTransaction(TOKEN_ID);
insertAndParseTransaction(tokenDeleteTimestamp, deleteTransaction);
// when
// dissociate
Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
long dissociateTimeStamp = 25L;
TokenTransferList dissociateTransfer = tokenTransfer(TOKEN_ID, PAYER2, -1);
insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction, builder -> builder.addTokenTransferLists(dissociateTransfer));
// then
assertNftInRepository(TOKEN_ID, 1L, true, mintTimestamp, dissociateTimeStamp, PAYER2, true);
assertNftInRepository(TOKEN_ID, 2L, true, mintTimestamp, mintTimestamp, PAYER, false);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, dissociateTimeStamp, SYMBOL, 1);
assertThat(nftTransferRepository.findAll()).containsExactlyInAnyOrder(domainNftTransfer(mintTimestamp, PAYER, DEFAULT_ACCOUNT_ID, 1L, TOKEN_ID, PAYER), domainNftTransfer(mintTimestamp, PAYER, DEFAULT_ACCOUNT_ID, 2L, TOKEN_ID, PAYER), domainNftTransfer(transferTimestamp, PAYER2, PAYER, 1L, TOKEN_ID, PAYER), domainNftTransfer(dissociateTimeStamp, DEFAULT_ACCOUNT_ID, PAYER2, 1L, TOKEN_ID, PAYER));
assertThat(tokenTransferRepository.findAll()).isEmpty();
}
Aggregations