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