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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations