Search in sources :

Example 1 with TransactionSignature

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

the class SqlEntityListenerTest method onScheduleSignature.

@Test
void onScheduleSignature() {
    TransactionSignature transactionSignature1 = domainBuilder.transactionSignature().get();
    TransactionSignature transactionSignature2 = domainBuilder.transactionSignature().get();
    TransactionSignature transactionSignature3 = domainBuilder.transactionSignature().get();
    // when
    sqlEntityListener.onTransactionSignature(transactionSignature1);
    sqlEntityListener.onTransactionSignature(transactionSignature2);
    sqlEntityListener.onTransactionSignature(transactionSignature3);
    completeFileAndCommit();
    // then
    assertThat(transactionSignatureRepository.findAll()).containsExactlyInAnyOrder(transactionSignature1, transactionSignature2, transactionSignature3);
}
Also used : TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with TransactionSignature

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

the class EntityRecordItemListenerScheduleTest method scheduleSignTwoBatches.

@Test
void scheduleSignTwoBatches() {
    insertScheduleCreateTransaction(CREATE_TIMESTAMP, null, SCHEDULE_ID);
    // first sign
    SignatureMap firstSignatureMap = getSigMap(2, true);
    insertScheduleSign(SIGN_TIMESTAMP, firstSignatureMap, SCHEDULE_ID);
    // verify schedule signatures
    List<TransactionSignature> expectedTransactionSignatureList = new ArrayList<>(defaultSignatureList);
    expectedTransactionSignatureList.addAll(toTransactionSignatureList(SIGN_TIMESTAMP, SCHEDULE_ID, firstSignatureMap));
    assertTransactionSignatureInRepository(expectedTransactionSignatureList);
    // second sign
    long timestamp = SIGN_TIMESTAMP + 10;
    SignatureMap secondSignatureMap = getSigMap(3, true);
    insertScheduleSign(timestamp, secondSignatureMap, SCHEDULE_ID);
    expectedTransactionSignatureList.addAll(toTransactionSignatureList(timestamp, SCHEDULE_ID, secondSignatureMap));
    assertTransactionSignatureInRepository(expectedTransactionSignatureList);
    // verify entity count
    Entity expected = createEntity(EntityId.of(SCHEDULE_ID), SCHEDULE_REF_KEY, null, null, false, null, SCHEDULE_CREATE_MEMO, null, CREATE_TIMESTAMP, CREATE_TIMESTAMP);
    assertEquals(1, entityRepository.count());
    assertEntity(expected);
    // verify schedule
    assertThat(scheduleRepository.count()).isOne();
    assertScheduleInRepository(SCHEDULE_ID, CREATE_TIMESTAMP, PAYER, null);
    // verify transaction
    assertTransactionInRepository(SIGN_TIMESTAMP, false, SUCCESS);
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) ArrayList(java.util.ArrayList) TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with TransactionSignature

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

the class EntityRecordItemListenerScheduleTest method scheduleExecute.

void scheduleExecute(ResponseCodeEnum responseCodeEnum) {
    insertScheduleCreateTransaction(CREATE_TIMESTAMP, null, SCHEDULE_ID);
    // sign
    SignatureMap signatureMap = getSigMap(3, true);
    insertScheduleSign(SIGN_TIMESTAMP, signatureMap, SCHEDULE_ID);
    // scheduled transaction
    insertScheduledTransaction(EXECUTE_TIMESTAMP, SCHEDULE_ID, responseCodeEnum);
    // verify entity count
    Entity expected = createEntity(EntityId.of(SCHEDULE_ID), SCHEDULE_REF_KEY, null, null, false, null, SCHEDULE_CREATE_MEMO, null, CREATE_TIMESTAMP, CREATE_TIMESTAMP);
    assertEquals(1, entityRepository.count());
    assertEntity(expected);
    // verify schedule
    assertScheduleInRepository(SCHEDULE_ID, CREATE_TIMESTAMP, PAYER, EXECUTE_TIMESTAMP);
    // verify schedule signatures
    List<TransactionSignature> expectedTransactionList = new ArrayList<>(defaultSignatureList);
    expectedTransactionList.addAll(toTransactionSignatureList(SIGN_TIMESTAMP, SCHEDULE_ID, signatureMap));
    assertTransactionSignatureInRepository(expectedTransactionList);
    // verify transaction
    assertTransactionInRepository(EXECUTE_TIMESTAMP, true, responseCodeEnum);
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) ArrayList(java.util.ArrayList) TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap)

Example 4 with TransactionSignature

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

the class EntityRecordItemListenerScheduleTest method unknownSignatureType.

@Test
void unknownSignatureType() {
    int unknownType = 999;
    ByteString sig = ByteString.copyFromUtf8("123");
    UnknownFieldSet.Field unknownField = UnknownFieldSet.Field.newBuilder().addLengthDelimited(sig).build();
    SignatureMap.Builder signatureMap = SignatureMap.newBuilder().addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setContract(sig).build()).addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setECDSA384(sig).build()).addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setECDSASecp256K1(sig).build()).addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setEd25519(sig).build()).addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setRSA3072(sig).build()).addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(byteString(8)).setUnknownFields(UnknownFieldSet.newBuilder().addField(unknownType, unknownField).build()).build());
    insertScheduleSign(SIGN_TIMESTAMP, signatureMap.build(), SCHEDULE_ID);
    // verify
    assertThat(transactionRepository.count()).isEqualTo(1);
    assertThat(transactionSignatureRepository.findAll()).isNotNull().hasSize(signatureMap.getSigPairCount()).allSatisfy(t -> assertThat(t).returns(sig.toByteArray(), TransactionSignature::getSignature).extracting(TransactionSignature::getPublicKeyPrefix).isNotNull()).extracting(TransactionSignature::getType).containsExactlyInAnyOrder(SignaturePair.SignatureCase.CONTRACT.getNumber(), SignaturePair.SignatureCase.ECDSA_384.getNumber(), SignaturePair.SignatureCase.ECDSA_SECP256K1.getNumber(), SignaturePair.SignatureCase.ED25519.getNumber(), SignaturePair.SignatureCase.RSA_3072.getNumber(), unknownType);
}
Also used : ByteString(com.google.protobuf.ByteString) TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) UnknownFieldSet(com.google.protobuf.UnknownFieldSet) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with TransactionSignature

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

the class TransactionSignatureRepositoryTest method save.

@Test
void save() {
    TransactionSignature transactionSignature = domainBuilder.transactionSignature().persist();
    assertThat(transactionSignatureRepository.findById(transactionSignature.getId())).get().isEqualTo(transactionSignature);
}
Also used : TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionSignature (com.hedera.mirror.common.domain.transaction.TransactionSignature)8 Test (org.junit.jupiter.api.Test)5 SignatureMap (com.hederahashgraph.api.proto.java.SignatureMap)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ArrayList (java.util.ArrayList)3 ByteString (com.google.protobuf.ByteString)2 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)2 Entity (com.hedera.mirror.common.domain.entity.Entity)2 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)1 TransactionType (com.hedera.mirror.common.domain.transaction.TransactionType)1 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)1 InvalidDatasetException (com.hedera.mirror.importer.exception.InvalidDatasetException)1 CommonParserProperties (com.hedera.mirror.importer.parser.CommonParserProperties)1 RecordParserProperties (com.hedera.mirror.importer.parser.record.RecordParserProperties)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1