use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.
the class CsvBalanceFileReaderTest method supportsInvalidWhenExceedsLineSize.
@Test
void supportsInvalidWhenExceedsLineSize() {
String versionPrefix = balanceFileReader.getVersionHeaderPrefix();
String prefix = " ".repeat(CsvBalanceFileReader.BUFFER_SIZE + 1);
StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), prefix + versionPrefix);
assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.
the class ProtoBalanceFileReaderTest method getExpectedAccountBalanceFile.
private AccountBalanceFile getExpectedAccountBalanceFile(StreamFileData streamFileData) {
Instant instant = Instant.parse(TIMESTAMP.replace("_", ":"));
long consensusTimestamp = DomainUtils.convertToNanosMax(instant);
long accountNum = 2000;
long hbarBalance = 3000;
long tokenNum = 5000;
long tokenBalance = 6000;
List<AccountBalance> accountBalances = IntStream.range(0, 10).mapToObj(i -> {
EntityId accountId = EntityId.of(0, 0, accountNum + i, EntityType.ACCOUNT);
List<TokenBalance> tokenBalances = IntStream.range(0, 5).mapToObj(j -> {
EntityId tokenId = EntityId.of(0, 0, tokenNum + i * 5 + j, EntityType.TOKEN);
return new TokenBalance(tokenBalance + i * 5 + j, new TokenBalance.Id(consensusTimestamp, accountId, tokenId));
}).collect(Collectors.toList());
return new AccountBalance(hbarBalance + i, tokenBalances, new AccountBalance.Id(consensusTimestamp, accountId));
}).collect(Collectors.toList());
return AccountBalanceFile.builder().bytes(streamFileData.getBytes()).consensusTimestamp(consensusTimestamp).fileHash("67c2fd054621366dd5a37b6ee36a51bc590361379d539fdac2265af08cb8097729218c7d9ff1f1e354c85b820c5b8cf8").items(Flux.fromIterable(accountBalances)).name(streamFileData.getFilename()).build();
}
use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.
the class ProtoBalanceFileReaderTest method emptyProtobuf.
@Test
void emptyProtobuf() {
AllAccountBalances allAccountBalances = AllAccountBalances.newBuilder().build();
byte[] bytes = allAccountBalances.toByteArray();
StreamFileData streamFileData = StreamFileData.from(TIMESTAMP + "_Balances.pb", bytes);
assertThrows(InvalidStreamFileException.class, () -> protoBalanceFileReader.read(streamFileData));
}
use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.
the class ProtoBalanceFileReaderTest method unknownFields.
@Test
void unknownFields() {
UnknownFieldSet.Field field = UnknownFieldSet.Field.newBuilder().addFixed32(11).build();
AllAccountBalances allAccountBalances = AllAccountBalances.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(1L).build()).mergeUnknownFields(UnknownFieldSet.newBuilder().addField(23, field).build()).addAllAccounts(SingleAccountBalances.newBuilder().build()).build();
byte[] bytes = allAccountBalances.toByteArray();
StreamFileData streamFileData = StreamFileData.from(TIMESTAMP + "_Balances.pb", bytes);
AccountBalanceFile accountBalanceFile = protoBalanceFileReader.read(streamFileData);
assertThat(accountBalanceFile).isNotNull();
assertThat(accountBalanceFile.getItems().count().block()).isEqualTo(1L);
}
use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.
the class EventFileReaderV3Test method readInvalidFileWithIncompletePrevHash.
@Test
void readInvalidFileWithIncompletePrevHash() {
byte[] incompletePrevHash = new byte[EventFileReaderV3.EVENT_PREV_HASH_LENGTH - 2];
StreamFileData invalidFile = createEventFile(EventFileReaderV3.EVENT_STREAM_FILE_VERSION_3, EventFileReaderV3.EVENT_TYPE_PREV_HASH, incompletePrevHash, null);
assertThrows(InvalidEventFileException.class, () -> eventFileReader.read(invalidFile));
}
Aggregations