Search in sources :

Example 1 with SignaturePair

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

the class EntityRecordItemListenerScheduleTest method scheduleSignDuplicateEd25519Signatures.

@Test
void scheduleSignDuplicateEd25519Signatures() {
    SignatureMap signatureMap = getSigMap(3, true);
    SignaturePair first = signatureMap.getSigPair(0);
    SignaturePair third = signatureMap.getSigPair(2);
    SignatureMap signatureMapWithDuplicate = signatureMap.toBuilder().addSigPair(first).addSigPair(third).build();
    insertScheduleSign(SIGN_TIMESTAMP, signatureMapWithDuplicate, SCHEDULE_ID);
    // verify lack of schedule data and transaction
    assertTransactionSignatureInRepository(toTransactionSignatureList(SIGN_TIMESTAMP, SCHEDULE_ID, signatureMap));
    assertThat(transactionRepository.count()).isEqualTo(1);
}
Also used : SignaturePair(com.hederahashgraph.api.proto.java.SignaturePair) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with SignaturePair

use of com.hederahashgraph.api.proto.java.SignaturePair in project hedera-services by hashgraph.

the class PojoSigMapPubKeyToSigBytesTest method rejectsNonUniqueSigBytes.

@Test
void rejectsNonUniqueSigBytes() {
    // given:
    String str = "TEST_STRING";
    byte[] pubKey = str.getBytes(StandardCharsets.UTF_8);
    SignaturePair sigPair = SignaturePair.newBuilder().setPubKeyPrefix(ByteString.copyFromUtf8(str)).build();
    SignatureMap sigMap = SignatureMap.newBuilder().addSigPair(sigPair).addSigPair(sigPair).build();
    PojoSigMapPubKeyToSigBytes sigMapPubKeyToSigBytes = new PojoSigMapPubKeyToSigBytes(sigMap);
    // expect:
    KeyPrefixMismatchException exception = assertThrows(KeyPrefixMismatchException.class, () -> {
        sigMapPubKeyToSigBytes.sigBytesFor(pubKey);
    });
    assertEquals("Source signature map with prefix 544553545f535452494e47 is ambiguous for given public key! " + "(544553545f535452494e47)", exception.getMessage());
}
Also used : KeyPrefixMismatchException(com.hedera.services.legacy.exception.KeyPrefixMismatchException) SignaturePair(com.hederahashgraph.api.proto.java.SignaturePair) ByteString(com.google.protobuf.ByteString) SignatureMap(com.hederahashgraph.api.proto.java.SignatureMap) Test(org.junit.jupiter.api.Test)

Aggregations

SignatureMap (com.hederahashgraph.api.proto.java.SignatureMap)2 SignaturePair (com.hederahashgraph.api.proto.java.SignaturePair)2 Test (org.junit.jupiter.api.Test)2 ByteString (com.google.protobuf.ByteString)1 KeyPrefixMismatchException (com.hedera.services.legacy.exception.KeyPrefixMismatchException)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1