Search in sources :

Example 1 with Timestamp

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

the class RequestBuilderTest method assertGetContractUpdateRequest.

@Test
void assertGetContractUpdateRequest() throws InvalidProtocolBufferException {
    var proxyAccountID = AccountID.newBuilder().setAccountNum(1010L).setRealmNum(0).setShardNum(0).build();
    Timestamp expirationTime = Timestamp.newBuilder().setSeconds(124_56L).build();
    var transaction = RequestBuilder.getContractUpdateRequest(accountId, nodeId, transactionFee, startTime, transactionDuration, generateRecord, memo, contractId, autoRenew, validED25519Key, proxyAccountID, expirationTime, contractMemo);
    var tb = TransactionBody.parseFrom(transaction.getBodyBytes());
    assertEquals(nodeId, tb.getNodeAccountID());
    assertEquals(proxyAccountID, tb.getContractUpdateInstance().getProxyAccountID());
    assertEquals(accountId, tb.getTransactionID().getAccountID());
    assertEquals(transactionFee, tb.getTransactionFee());
    assertEquals(startTime, tb.getTransactionID().getTransactionValidStart());
    assertEquals(generateRecord, tb.getGenerateRecord());
    assertEquals(memo, tb.getMemo());
    assertEquals(contractId, tb.getContractUpdateInstance().getContractID());
    assertEquals(autoRenew, tb.getContractUpdateInstance().getAutoRenewPeriod());
    assertEquals(validED25519Key, tb.getContractUpdateInstance().getAdminKey());
    assertEquals(expirationTime, tb.getContractUpdateInstance().getExpirationTime());
    assertEquals(contractMemo, tb.getContractUpdateInstance().getMemo());
}
Also used : Timestamp(com.hederahashgraph.api.proto.java.Timestamp) Test(org.junit.jupiter.api.Test)

Example 2 with Timestamp

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

the class BasicFcfsUsagePricesTest method returnsDefaultUsagePricesForUnsupported.

@Test
void returnsDefaultUsagePricesForUnsupported() {
    // setup:
    MockAppender mockAppender = new MockAppender();
    var log = (org.apache.logging.log4j.core.Logger) LogManager.getLogger(BasicFcfsUsagePrices.class);
    log.addAppender(mockAppender);
    Level levelForReset = log.getLevel();
    log.setLevel(Level.DEBUG);
    // given:
    subject.loadPriceSchedules();
    Timestamp at = Timestamp.newBuilder().setSeconds(currentExpiry - 1).build();
    // when:
    Map<SubType, FeeData> actual = subject.pricesGiven(UNRECOGNIZED, at);
    // then:
    assertEquals(DEFAULT_RESOURCE_PRICES, actual);
    assertEquals(1, mockAppender.size());
    assertEquals("DEBUG - Default usage price will be used, no specific usage prices available for function " + "UNRECOGNIZED" + " @ 1970-01-15T06:56:06Z!", mockAppender.get(0));
    // tearDown:
    log.setLevel(levelForReset);
    log.removeAppender(mockAppender);
    mockAppender.clear();
}
Also used : MockAppender(com.hedera.test.mocks.MockAppender) SubType(com.hederahashgraph.api.proto.java.SubType) Level(org.apache.logging.log4j.Level) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) FeeData(com.hederahashgraph.api.proto.java.FeeData) Test(org.junit.jupiter.api.Test)

Example 3 with Timestamp

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

the class HapiTxnOp method measureConsensusLatency.

private void measureConsensusLatency(HapiApiSpec spec) throws Throwable {
    if (acceptAnyStatus) {
        acceptAnyStatus = false;
        acceptAnyKnownStatus = true;
        actualStatus = resolvedStatusOfSubmission(spec);
    }
    if (recordOfSubmission == null) {
        lookupSubmissionRecord(spec);
    }
    Timestamp stamp = recordOfSubmission.getConsensusTimestamp();
    long consensusTime = stamp.getSeconds() * 1_000L + stamp.getNanos() / 1_000_000L;
    stats.setConsensusLatency(consensusTime - submitTime);
}
Also used : Timestamp(com.hederahashgraph.api.proto.java.Timestamp)

Example 4 with Timestamp

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

the class HapiContractUpdate method feeFor.

@Override
protected long feeFor(HapiApiSpec spec, Transaction txn, int numPayerKeys) throws Throwable {
    Timestamp newExpiry = TxnFactory.expiryGiven(newExpirySecs.orElse(spec.setup().defaultExpirationSecs()));
    Timestamp oldExpiry = TxnUtils.currContractExpiry(contract, spec);
    final Timestamp expiry = TxnUtils.inConsensusOrder(oldExpiry, newExpiry) ? newExpiry : oldExpiry;
    FeeCalculator.ActivityMetrics metricsCalc = (txBody, sigUsage) -> scFees.getContractUpdateTxFeeMatrices(txBody, expiry, sigUsage);
    return spec.fees().forActivityBasedOp(HederaFunctionality.ContractUpdate, metricsCalc, txn, numPayerKeys);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) StringValue(com.google.protobuf.StringValue) HEXED_EVM_ADDRESS_LEN(com.hedera.services.bdd.spec.transactions.contract.HapiContractCall.HEXED_EVM_ADDRESS_LEN) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) Duration(com.hederahashgraph.api.proto.java.Duration) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ContractID(com.hederahashgraph.api.proto.java.ContractID) OptionalLong(java.util.OptionalLong) TxnFactory(com.hedera.services.bdd.spec.transactions.TxnFactory) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) CommonUtils(com.swirlds.common.CommonUtils) DEPRECATED_CID_ADMIN_KEY(com.hedera.services.bdd.spec.transactions.contract.HapiContractCreate.DEPRECATED_CID_ADMIN_KEY) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) Timestamp(com.hederahashgraph.api.proto.java.Timestamp)

Example 5 with Timestamp

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

the class TokenUpdateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.

@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
    recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
    var alias = DomainUtils.fromBytes(domainBuilder.key());
    var recordItem = recordItemBuilder.tokenUpdate().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
    var tokenId = EntityId.of(recordItem.getTransactionBody().getTokenUpdate().getToken());
    var timestamp = recordItem.getConsensusTimestamp();
    var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(tokenId)).get();
    when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
    transactionHandler.updateTransaction(transaction, recordItem);
    assertTokenUpdate(timestamp, tokenId, Assertions::assertNull);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EnumSource(org.junit.jupiter.params.provider.EnumSource) Duration(com.hederahashgraph.api.proto.java.Duration) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) NftRepository(com.hedera.mirror.importer.repository.NftRepository) DomainUtils(com.hedera.mirror.common.util.DomainUtils) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Range(com.google.common.collect.Range) Mockito.when(org.mockito.Mockito.when) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) Assertions(org.junit.jupiter.api.Assertions) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) Assertions(org.junit.jupiter.api.Assertions) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Timestamp (com.hederahashgraph.api.proto.java.Timestamp)26 Test (org.junit.jupiter.api.Test)12 Instant (java.time.Instant)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 EntityId (com.hedera.mirror.common.domain.entity.EntityId)5 DomainUtils (com.hedera.mirror.common.util.DomainUtils)5 Consumer (java.util.function.Consumer)5 Range (com.google.common.collect.Range)4 Entity (com.hedera.mirror.common.domain.entity.Entity)4 EntityType (com.hedera.mirror.common.domain.entity.EntityType)4 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)4 NftTransferId (com.hedera.mirror.common.domain.token.NftTransferId)4 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)4 AccountID (com.hederahashgraph.api.proto.java.AccountID)4 Duration (com.hederahashgraph.api.proto.java.Duration)4 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)4 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)4 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)4 AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)3 EntityIdEndec (com.hedera.mirror.common.domain.entity.EntityIdEndec)3