Search in sources :

Example 76 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem 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);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 77 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class TransactionSignatureTest method transactionSignatureDefault.

@ParameterizedTest
@MethodSource("provideDefaultTransactionSignatures")
void transactionSignatureDefault(TransactionType transactionType) {
    RecordItem recordItem = getRecordItem(transactionType, SUCCESS);
    entityRecordItemListener.onItem(recordItem);
    assertTransactionSignatures(defaultTransactionSignatures);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 78 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class TransactionSignatureTest method transactionSignatureDisabled.

@ParameterizedTest
@EnumSource(value = TransactionType.class, names = "UNKNOWN", mode = EXCLUDE)
void transactionSignatureDisabled(TransactionType transactionType) {
    transactionSignatures.clear();
    transactionSignatures.addAll(EnumSet.complementOf(EnumSet.of(transactionType)));
    RecordItem recordItem = getRecordItem(transactionType, SUCCESS);
    entityRecordItemListener.onItem(recordItem);
    assertTransactionSignatures(Collections.emptyList());
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class RecordFileParserTest method endDate.

@ParameterizedTest(name = "endDate with offset {0}ns")
@CsvSource({ "-1", "0", "1" })
void endDate(long offset) {
    // given
    RecordFile recordFile = (RecordFile) getStreamFile();
    RecordItem firstItem = recordFile.getItems().blockFirst();
    long end = recordFile.getConsensusStart() + offset;
    DateRangeFilter filter = new DateRangeFilter(Instant.EPOCH, Instant.ofEpochSecond(0, end));
    doReturn(filter).when(mirrorDateRangePropertiesProcessor).getDateRangeFilter(parserProperties.getStreamType());
    // when
    parser.parse(recordFile);
    // then
    verify(recordStreamFileListener).onStart();
    if (offset >= 0) {
        verify(recordItemListener).onItem(firstItem);
    }
    verify(recordStreamFileListener).onEnd(recordFile);
    assertPostParseStreamFile(recordFile, true);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 80 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class RecordFileParserTest method startDate.

@ParameterizedTest(name = "startDate with offset {0}ns")
@CsvSource({ "-1", "0", "1" })
void startDate(long offset) {
    // given
    RecordFile recordFile = (RecordFile) getStreamFile();
    RecordItem firstItem = recordFile.getItems().blockFirst();
    long start = recordFile.getConsensusStart() + offset;
    DateRangeFilter filter = new DateRangeFilter(Instant.ofEpochSecond(0, start), null);
    doReturn(filter).when(mirrorDateRangePropertiesProcessor).getDateRangeFilter(parserProperties.getStreamType());
    // when
    parser.parse(recordFile);
    // then
    verify(recordStreamFileListener).onStart();
    if (offset < 0) {
        verify(recordItemListener).onItem(firstItem);
    }
    verify(recordStreamFileListener).onEnd(recordFile);
    assertPostParseStreamFile(recordFile, true);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)182 Test (org.junit.jupiter.api.Test)131 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)131 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)108 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)95 Transaction (com.hederahashgraph.api.proto.java.Transaction)94 EntityId (com.hedera.mirror.common.domain.entity.EntityId)42 DomainUtils (com.hedera.mirror.common.util.DomainUtils)36 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)36 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)36 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)34 EnumSource (org.junit.jupiter.params.provider.EnumSource)34 Entity (com.hedera.mirror.common.domain.entity.Entity)31 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)31 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)29 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)29 AccountID (com.hederahashgraph.api.proto.java.AccountID)28 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)28 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)28 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28