use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-services by hashgraph.
the class SigOpsRegressionTest method otherPartySigsAreActive.
static boolean otherPartySigsAreActive(PlatformTxnAccessor accessor, SigRequirements keyOrder, SigningOrderResultFactory<ResponseCodeEnum> summaryFactory, KeyActivationCharacteristics characteristics) {
TransactionBody txn = accessor.getTxn();
Function<byte[], TransactionSignature> sigsFn = HederaKeyActivation.pkToSigMapFrom(accessor.getPlatformTxn().getSignatures());
final var othersResult = keyOrder.keysForOtherParties(txn, summaryFactory);
for (JKey otherKey : othersResult.getOrderedKeys()) {
if (!HederaKeyActivation.isActive(otherKey, sigsFn, HederaKeyActivation.ONLY_IF_SIG_IS_VALID, characteristics)) {
return false;
}
}
return true;
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method recognizesExpiredCondition.
@Test
void recognizesExpiredCondition() {
SignedTxnAccessor accessor = mock(SignedTxnAccessor.class);
// given:
long validDuration = 1_000L;
Instant validStart = Instant.ofEpochSecond(1_234_567L);
Instant consensusTime = Instant.ofEpochSecond(validStart.getEpochSecond() + validDuration + 1);
// and:
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(validStart.getEpochSecond())).build();
TransactionBody txn = TransactionBody.newBuilder().setTransactionID(txnId).setTransactionValidDuration(Duration.newBuilder().setSeconds(validDuration)).build();
// and:
given(accessor.getTxn()).willReturn(txn);
given(accessor.getTxnId()).willReturn(txnId);
// when:
ResponseCodeEnum status = subject.chronologyStatus(accessor, consensusTime);
// then:
assertEquals(TRANSACTION_EXPIRED, status);
// and:
assertEquals(TRANSACTION_EXPIRED, subject.chronologyStatusForTxn(validStart, validDuration, consensusTime));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-services by hashgraph.
the class FeeCalculator method metricsFor.
private FeeData metricsFor(Transaction txn, int numPayerSigs, ActivityMetrics metricsCalculator) throws Throwable {
SigValueObj sigUsage = sigUsageGiven(txn, numPayerSigs);
TransactionBody body = CommonUtils.extractTransactionBody(txn);
return metricsCalculator.compute(body, sigUsage);
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractDeleteToExisting.
@ParameterizedTest
@EnumSource(ContractIdType.class)
void contractDeleteToExisting(ContractIdType contractIdType) {
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, true, true);
Transaction transaction = contractDeleteTransaction(setupResult.protoContractId);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.DELETE);
RecordItem recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
Contract dbContractEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(setupResult.contract.toEntityId()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(dbContractEntity).isNotNull().returns(true, Contract::getDeleted).returns(recordItem.getConsensusTimestamp(), Contract::getTimestampLower).returns(EntityId.of(PAYER), Contract::getObtainerId).usingRecursiveComparison().ignoringFields("deleted", "obtainerId", "timestampRange").isEqualTo(setupResult.contract));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class RecordFileParserTest method recordItem.
private RecordItem recordItem(long timestamp) {
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().build();
TransactionBody transactionBody = TransactionBody.newBuilder().setCryptoTransfer(cryptoTransfer).build();
SignedTransaction signedTransaction = SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(SignatureMap.newBuilder().build()).build();
Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(signedTransaction.toByteString()).build();
TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setNanos((int) timestamp)).build();
return new RecordItem(transaction, transactionRecord);
}
Aggregations