Search in sources :

Example 11 with SignatureMap

use of com.hederahashgraph.api.proto.java.SignatureMap in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerScheduleTest method scheduleSign.

@Test
void scheduleSign() {
    insertScheduleCreateTransaction(CREATE_TIMESTAMP, null, SCHEDULE_ID);
    // sign
    SignatureMap signatureMap = getSigMap(3, true);
    insertScheduleSign(SIGN_TIMESTAMP, signatureMap, SCHEDULE_ID);
    // verify entity count
    assertEquals(1, entityRepository.count());
    // verify schedule
    assertThat(scheduleRepository.count()).isOne();
    assertScheduleInRepository(SCHEDULE_ID, CREATE_TIMESTAMP, PAYER, null);
    // verify schedule signatures
    List<TransactionSignature> expectedTransactionSignatureList = new ArrayList<>(defaultSignatureList);
    expectedTransactionSignatureList.addAll(toTransactionSignatureList(SIGN_TIMESTAMP, SCHEDULE_ID, signatureMap));
    assertTransactionSignatureInRepository(expectedTransactionSignatureList);
    // verify transaction
    assertTransactionInRepository(SIGN_TIMESTAMP, false, SUCCESS);
}
Also used : 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 12 with SignatureMap

use of com.hederahashgraph.api.proto.java.SignatureMap in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerScheduleTest method getSigMap.

private SignatureMap getSigMap(int signatureCount, boolean isEd25519) {
    SignatureMap.Builder builder = SignatureMap.newBuilder();
    String salt = RandomStringUtils.randomAlphabetic(5);
    for (int i = 0; i < signatureCount; i++) {
        SignaturePair.Builder signaturePairBuilder = SignaturePair.newBuilder();
        signaturePairBuilder.setPubKeyPrefix(ByteString.copyFromUtf8("PubKeyPrefix-" + i + salt));
        ByteString byteString = ByteString.copyFromUtf8("Ed25519-" + i + salt);
        if (isEd25519) {
            signaturePairBuilder.setEd25519(byteString);
        } else {
            signaturePairBuilder.setRSA3072(byteString);
        }
        builder.addSigPair(signaturePairBuilder.build());
    }
    return builder.build();
}
Also used : SignaturePair(com.hederahashgraph.api.proto.java.SignaturePair) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap)

Aggregations

SignatureMap (com.hederahashgraph.api.proto.java.SignatureMap)12 Test (org.junit.jupiter.api.Test)8 ByteString (com.google.protobuf.ByteString)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 TransactionSignature (com.hedera.mirror.common.domain.transaction.TransactionSignature)4 SignaturePair (com.hederahashgraph.api.proto.java.SignaturePair)4 ArrayList (java.util.ArrayList)3 Entity (com.hedera.mirror.common.domain.entity.Entity)2 BaseTransactionMeta (com.hedera.services.usage.BaseTransactionMeta)2 SigUsage (com.hedera.services.usage.SigUsage)2 UsageAccumulator (com.hedera.services.usage.state.UsageAccumulator)2 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)1 InvalidDatasetException (com.hedera.mirror.importer.exception.InvalidDatasetException)1 KeyPrefixMismatchException (com.hedera.services.legacy.exception.KeyPrefixMismatchException)1 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)1 Transaction (com.hederahashgraph.api.proto.java.Transaction)1