Search in sources :

Example 11 with AccountBalanceFile

use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.

the class ErrataMigrationTest method onEndWithoutOffset.

@Test
void onEndWithoutOffset() {
    AccountBalanceFile accountBalanceFile = new AccountBalanceFile();
    accountBalanceFile.setConsensusTimestamp(1L);
    errataMigration.onEnd(accountBalanceFile);
    assertThat(accountBalanceFile.getTimeOffset()).isZero();
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 12 with AccountBalanceFile

use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.

the class ErrataMigrationTest method onEndNotMainnet.

@Test
void onEndNotMainnet() {
    mirrorProperties.setNetwork(MirrorProperties.HederaNetwork.TESTNET);
    AccountBalanceFile accountBalanceFile = new AccountBalanceFile();
    accountBalanceFile.setConsensusTimestamp(BAD_TIMESTAMP1);
    // Call to increase test coverage of no-op methods
    errataMigration.onStart();
    errataMigration.onError();
    errataMigration.onEnd(accountBalanceFile);
    assertThat(accountBalanceFile.getTimeOffset()).isZero();
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 13 with AccountBalanceFile

use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.

the class ErrataMigrationTest method onEndWithOffset.

@Test
void onEndWithOffset() {
    AccountBalanceFile accountBalanceFile = new AccountBalanceFile();
    accountBalanceFile.setConsensusTimestamp(BAD_TIMESTAMP1);
    // Call to increase test coverage of no-op methods
    errataMigration.onStart();
    errataMigration.onError();
    errataMigration.onEnd(accountBalanceFile);
    assertThat(accountBalanceFile.getTimeOffset()).isEqualTo(-1);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 14 with AccountBalanceFile

use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.

the class CsvBalanceFileReaderTest method readValidWhenFileHasLinesWithDifferentShardNum.

@Test
void readValidWhenFileHasLinesWithDifferentShardNum() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    FileUtils.writeLines(testFile, lines);
    long otherShard = mirrorProperties.getShard() + 1;
    FileUtils.writeStringToFile(testFile, String.format("\n%d,0,3,340\n%d,0,4,340\n", otherShard, otherShard), CsvBalanceFileReader.CHARSET, true);
    StreamFileData streamFileData = StreamFileData.from(testFile);
    AccountBalanceFile accountBalanceFile = balanceFileReader.read(streamFileData);
    assertAccountBalanceFile(accountBalanceFile);
    verifySuccess(testFile, accountBalanceFile, 2);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 15 with AccountBalanceFile

use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.

the class CsvBalanceFileReaderTest method readValidWhenFileHasTrailingEmptyLines.

@Test
void readValidWhenFileHasTrailingEmptyLines() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    FileUtils.writeLines(testFile, lines);
    FileUtils.writeStringToFile(testFile, "\n\n\n", CsvBalanceFileReader.CHARSET, true);
    StreamFileData streamFileData = StreamFileData.from(testFile);
    AccountBalanceFile accountBalanceFile = balanceFileReader.read(streamFileData);
    assertAccountBalanceFile(accountBalanceFile);
    verifySuccess(testFile, accountBalanceFile, 2);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Aggregations

AccountBalanceFile (com.hedera.mirror.common.domain.balance.AccountBalanceFile)23 Test (org.junit.jupiter.api.Test)18 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)9 AccountBalance (com.hedera.mirror.common.domain.balance.AccountBalance)8 StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)7 Instant (java.time.Instant)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)2 TokenBalance (com.hedera.mirror.common.domain.balance.TokenBalance)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)2 AllAccountBalances (com.hedera.services.stream.proto.AllAccountBalances)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Stopwatch (com.google.common.base.Stopwatch)1 CodedInputStream (com.google.protobuf.CodedInputStream)1 StreamType (com.hedera.mirror.common.domain.StreamType)1 EntityType (com.hedera.mirror.common.domain.entity.EntityType)1 DomainUtils (com.hedera.mirror.common.util.DomainUtils)1