use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class BasicFcfsUsagePricesTest method getsTransferUsagePricesPastCurrentBeforeNextExpiry.
@Test
void getsTransferUsagePricesPastCurrentBeforeNextExpiry() throws Exception {
// given:
subject.loadPriceSchedules();
Timestamp at = Timestamp.newBuilder().setSeconds(nextExpiry - 1).build();
// when:
Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
// then:
assertEquals(nextContractCallPrices, actual);
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class FeeCalcUtilsTest method returnsAccountExpiryIfAvail.
@Test
void returnsAccountExpiryIfAvail() {
// setup:
final var account = mock(MerkleAccount.class);
final MerkleMap<EntityNum, MerkleAccount> accounts = mock(MerkleMap.class);
Timestamp expected = Timestamp.newBuilder().setSeconds(Long.MAX_VALUE).build();
given(account.getExpiry()).willReturn(Long.MAX_VALUE);
given(accounts.get(key)).willReturn(account);
assertEquals(expected, lookupAccountExpiry(key, accounts));
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class PrecompilePricingUtilsTest method calculatesMinimumPrice.
@Test
void calculatesMinimumPrice() throws IOException {
Timestamp timestamp = Timestamp.newBuilder().setSeconds(123456789).build();
given(exchange.rate(timestamp)).willReturn(exchangeRate);
given(assetLoader.loadCanonicalPrices()).willReturn(Map.of(HederaFunctionality.TokenAssociateToAccount, Map.of(SubType.DEFAULT, BigDecimal.valueOf(COST))));
given(exchangeRate.getCentEquiv()).willReturn(CENTS_RATE);
given(exchangeRate.getHbarEquiv()).willReturn(HBAR_RATE);
PrecompilePricingUtils subject = new PrecompilePricingUtils(assetLoader, exchange);
long price = subject.getMinimumPriceInTinybars(PrecompilePricingUtils.GasCostType.ASSOCIATE, timestamp);
assertEquals(USD_TO_TINYCENTS.multiply(BigDecimal.valueOf(COST * HBAR_RATE / CENTS_RATE)).longValue(), price);
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class TestHelper method getDefaultCurrentTimestampUTC.
/**
* Gets the current UTC timestamp with default winding back seconds.
*/
public static synchronized Timestamp getDefaultCurrentTimestampUTC() {
Timestamp rv = ProtoCommonUtils.getCurrentTimestampUTC(DEFAULT_WIND_SEC);
if (rv.getNanos() == lastNano) {
try {
Thread.sleep(0, 1);
} catch (InterruptedException e) {
}
rv = ProtoCommonUtils.getCurrentTimestampUTC(DEFAULT_WIND_SEC);
lastNano = rv.getNanos();
}
return rv;
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class ContractUpdateResourceUsage method usageGiven.
@Override
public FeeData usageGiven(TransactionBody txn, SigValueObj sigUsage, StateView view) throws InvalidTxBodyException {
try {
final var id = fromContractId(txn.getContractUpdateInstance().getContractID());
Timestamp expiry = lookupAccountExpiry(id, view.accounts());
return usageEstimator.getContractUpdateTxFeeMatrices(txn, expiry, sigUsage);
} catch (Exception e) {
log.debug("Unable to deduce ContractUpdate usage for {}, using defaults", txn.getTransactionID(), e);
return FeeData.getDefaultInstance();
}
}
Aggregations