Search in sources :

Example 16 with FileData

use of com.hedera.mirror.common.domain.file.FileData in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method assertFileData.

private void assertFileData(ByteString expected, Timestamp consensusTimestamp) {
    FileData actualFileData = fileDataRepository.findById(DomainUtils.timeStampInNanos(consensusTimestamp)).get();
    assertArrayEquals(expected.toByteArray(), actualFileData.getFileData());
}
Also used : FileData(com.hedera.mirror.common.domain.file.FileData)

Example 17 with FileData

use of com.hedera.mirror.common.domain.file.FileData in project hedera-mirror-node by hashgraph.

the class PubSubRecordItemListenerTest method testNetworkAddressBookAppend.

@Test
void testNetworkAddressBookAppend() throws Exception {
    // given
    byte[] fileContents = new byte[] { 0b0, 0b1, 0b10 };
    Transaction transaction = buildTransaction(builder -> {
        builder.setFileAppend(FileAppendTransactionBody.newBuilder().setFileID(ADDRESS_BOOK_FILE_ID).setContents(ByteString.copyFrom(fileContents)).build());
    });
    // when
    EntityId entityId = EntityId.of(ADDRESS_BOOK_FILE_ID);
    doReturn(entityId).when(transactionHandler).getEntity(any());
    pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
    // then
    FileData fileData = new FileData(100L, fileContents, entityId, TransactionType.FILEAPPEND.getProtoId());
    verify(addressBookService).update(fileData);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) FileData(com.hedera.mirror.common.domain.file.FileData) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Aggregations

FileData (com.hedera.mirror.common.domain.file.FileData)17 EntityId (com.hedera.mirror.common.domain.entity.EntityId)5 Test (org.junit.jupiter.api.Test)4 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)2 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)2 InvalidDatasetException (com.hedera.mirror.importer.exception.InvalidDatasetException)2 NodeAddressBook (com.hederahashgraph.api.proto.java.NodeAddressBook)2 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)2 Transaction (com.hederahashgraph.api.proto.java.Transaction)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 TransactionType (com.hedera.mirror.common.domain.transaction.TransactionType)1 InvalidEntityException (com.hedera.mirror.common.exception.InvalidEntityException)1 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)1 ImporterException (com.hedera.mirror.importer.exception.ImporterException)1 ParserException (com.hedera.mirror.importer.exception.ParserException)1 PubSubMessage (com.hedera.mirror.importer.parser.domain.PubSubMessage)1 TransactionHandler (com.hedera.mirror.importer.parser.record.transactionhandler.TransactionHandler)1 FileID (com.hederahashgraph.api.proto.java.FileID)1 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)1