use of com.hederahashgraph.api.proto.java.SignatureMap 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);
}
use of com.hederahashgraph.api.proto.java.SignatureMap in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerScheduleTest method unsupportedSignature.
@Test
void unsupportedSignature() {
SignatureMap signatureMap = SignatureMap.newBuilder().addSigPair(SignaturePair.newBuilder().build()).build();
assertThatThrownBy(() -> insertScheduleSign(SIGN_TIMESTAMP, signatureMap, SCHEDULE_ID)).isInstanceOf(InvalidDatasetException.class).hasMessageContaining("Unsupported signature");
// verify
assertThat(transactionRepository.count()).isZero();
assertThat(transactionSignatureRepository.count()).isZero();
}
use of com.hederahashgraph.api.proto.java.SignatureMap 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);
}
use of com.hederahashgraph.api.proto.java.SignatureMap 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);
}
use of com.hederahashgraph.api.proto.java.SignatureMap 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);
}
Aggregations