use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenDissociate.
@Test
void tokenDissociate() {
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
long dissociateTimeStamp = 10L;
insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction);
EntityId tokenId = EntityId.of(TOKEN_ID);
EntityId accountId = EntityId.of(PAYER2);
TokenAccount expected = new TokenAccount(tokenId, accountId, dissociateTimeStamp);
expected.setCreatedTimestamp(ASSOCIATE_TIMESTAMP);
expected.setAssociated(false);
expected.setAutomaticAssociation(false);
expected.setFreezeStatus(TokenFreezeStatusEnum.NOT_APPLICABLE);
expected.setKycStatus(TokenKycStatusEnum.NOT_APPLICABLE);
assertThat(latestTokenAccount(TOKEN_ID, PAYER2)).get().isEqualTo(expected);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class TransactionSignatureTest method getRecordItem.
private RecordItem getRecordItem(TransactionType transactionType, ResponseCodeEnum responseCode, SignatureMap signatureMap) {
TransactionBody transactionBody = getTransactionBody(transactionType);
Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(signatureMap).build().toByteString()).build();
TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Utility.instantToTimestamp(Instant.ofEpochSecond(0, CONSENSUS_TIMESTAMP))).setReceipt(TransactionReceipt.newBuilder().setStatus(responseCode).build()).build();
return new RecordItem(transaction, transactionRecord);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testSendRetries.
@Test
void testSendRetries() throws Exception {
// when
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
pubSubProperties.setMaxSendAttempts(3);
// when
when(messageChannel.send(any())).thenThrow(MessageTimeoutException.class).thenThrow(MessageTimeoutException.class).thenReturn(true);
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 3);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessageWithNonFeeTransferAndNullEntityId.
@Test
void testPubSubMessageWithNonFeeTransferAndNullEntityId() throws Exception {
// given
List<AccountAmount> nonFeeTransfers = new ArrayList<>();
nonFeeTransfers.add(buildAccountAmount(10L, 100L));
nonFeeTransfers.add(buildAccountAmount(11L, 111L));
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().addAccountAmounts(nonFeeTransfers.get(0)).addAccountAmounts(nonFeeTransfers.get(1)).build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
var recordItem = new RecordItem(transaction, DEFAULT_RECORD);
when(nonFeeTransferExtractionStrategy.extractNonFeeTransfers(recordItem.getTransactionBody(), recordItem.getRecord())).thenReturn(cryptoTransfer.getTransfers().getAccountAmountsList());
// when
pubSubRecordItemListener.onItem(recordItem);
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isEqualTo(nonFeeTransfers);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testNetworkAddressBookUpdate.
@Test
void testNetworkAddressBookUpdate() throws Exception {
// given
byte[] fileContents = UPDATED.toByteArray();
var fileUpdate = FileUpdateTransactionBody.newBuilder().setFileID(ADDRESS_BOOK_FILE_ID).setContents(ByteString.copyFrom(fileContents)).build();
Transaction transaction = buildTransaction(builder -> builder.setFileUpdate(fileUpdate));
// when
doReturn(EntityId.of(ADDRESS_BOOK_FILE_ID)).when(transactionHandler).getEntity(any());
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
FileData fileData = new FileData(100L, fileContents, EntityId.of(ADDRESS_BOOK_FILE_ID), TransactionType.FILEUPDATE.getProtoId());
verify(addressBookService).update(fileData);
}
Aggregations