use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-mirror-node by hashgraph.
the class UtilityTest method instantToTimestamp.
@ParameterizedTest(name = "with seconds {0} and nanos {1}")
@CsvSource({ "1569936354, 901", "0, 901", "1569936354, 0", "0,0" })
void instantToTimestamp(long seconds, int nanos) {
Instant instant = Instant.ofEpochSecond(seconds).plusNanos(nanos);
Timestamp test = Utility.instantToTimestamp(instant);
assertAll(() -> assertEquals(instant.getEpochSecond(), test.getSeconds()), () -> assertEquals(instant.getNano(), test.getNanos()));
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class SmartContractFeeBuilder method getContractUpdateStorageBytesSec.
private long getContractUpdateStorageBytesSec(TransactionBody txBody, Timestamp contractExpiryTime) {
long storageSize = 0;
ContractUpdateTransactionBody contractUpdateTxBody = txBody.getContractUpdateInstance();
if (contractUpdateTxBody.hasAdminKey()) {
storageSize += getAccountKeyStorageSize(contractUpdateTxBody.getAdminKey());
}
if (contractUpdateTxBody.getMemo() != null) {
storageSize += contractUpdateTxBody.getMemoBytes().size();
}
Instant expirationTime = RequestBuilder.convertProtoTimeStamp(contractExpiryTime);
Timestamp txValidStartTimestamp = txBody.getTransactionID().getTransactionValidStart();
Instant txValidStartTime = RequestBuilder.convertProtoTimeStamp(txValidStartTimestamp);
Duration duration = Duration.between(txValidStartTime, expirationTime);
long seconds = Math.min(duration.getSeconds(), MAX_ENTITY_LIFETIME);
storageSize = storageSize * seconds;
return storageSize;
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class RequestBuilderTest method assertGetFileUpdateBuilder.
@Test
void assertGetFileUpdateBuilder() throws InvalidProtocolBufferException {
Timestamp fileExpiration = Timestamp.newBuilder().setSeconds(123_456L).build();
var transaction = RequestBuilder.getFileUpdateBuilder(accountId.getAccountNum(), accountId.getRealmNum(), accountId.getShardNum(), nodeId.getAccountNum(), nodeId.getRealmNum(), nodeId.getShardNum(), transactionFee, startTime, fileExpiration, transactionDuration, generateRecord, memo, hash, fileID, keyList);
var tb = TransactionBody.parseFrom(transaction.getBodyBytes());
assertEquals(memo, tb.getMemo());
assertEquals(generateRecord, tb.getGenerateRecord());
assertEquals(transactionFee, tb.getTransactionFee());
assertEquals(startTime, tb.getTransactionID().getTransactionValidStart());
assertEquals(transactionDuration, tb.getTransactionValidDuration());
assertEquals(transactionFee, tb.getTransactionFee());
assertEquals(hash, tb.getFileUpdate().getContents());
assertEquals(fileID, tb.getFileUpdate().getFileID());
assertEquals(keyList, tb.getFileUpdate().getKeys());
assertEquals(fileExpiration, tb.getFileUpdate().getExpirationTime());
assertEquals(nodeId.getAccountNum(), tb.getNodeAccountID().getAccountNum());
assertEquals(nodeId.getRealmNum(), tb.getNodeAccountID().getRealmNum());
assertEquals(nodeId.getShardNum(), tb.getNodeAccountID().getShardNum());
assertEquals(accountId.getAccountNum(), tb.getTransactionID().getAccountID().getAccountNum());
assertEquals(accountId.getRealmNum(), tb.getTransactionID().getAccountID().getRealmNum());
assertEquals(accountId.getShardNum(), tb.getTransactionID().getAccountID().getShardNum());
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class RequestBuilderTest method assertGetFileCreateBuilder.
@Test
void assertGetFileCreateBuilder() throws InvalidProtocolBufferException {
Timestamp fileExpiration = Timestamp.newBuilder().setSeconds(123_456L).build();
List<Key> keyList = List.of(validED25519Key);
var transaction = RequestBuilder.getFileCreateBuilder(accountId.getAccountNum(), accountId.getRealmNum(), accountId.getShardNum(), nodeId.getAccountNum(), nodeId.getRealmNum(), nodeId.getShardNum(), transactionFee, startTime, transactionDuration, generateRecord, memo, hash, fileExpiration, keyList);
var tb = TransactionBody.parseFrom(transaction.getBodyBytes());
assertEquals(memo, tb.getMemo());
assertEquals(generateRecord, tb.getGenerateRecord());
assertEquals(transactionFee, tb.getTransactionFee());
assertEquals(startTime, tb.getTransactionID().getTransactionValidStart());
assertEquals(transactionDuration, tb.getTransactionValidDuration());
assertEquals(transactionFee, tb.getTransactionFee());
assertEquals(hash, tb.getFileCreate().getContents());
assertEquals(fileExpiration, tb.getFileCreate().getExpirationTime());
assertEquals(nodeId.getAccountNum(), tb.getNodeAccountID().getAccountNum());
assertEquals(nodeId.getRealmNum(), tb.getNodeAccountID().getRealmNum());
assertEquals(nodeId.getShardNum(), tb.getNodeAccountID().getShardNum());
assertEquals(accountId.getAccountNum(), tb.getTransactionID().getAccountID().getAccountNum());
assertEquals(accountId.getRealmNum(), tb.getTransactionID().getAccountID().getRealmNum());
assertEquals(accountId.getShardNum(), tb.getTransactionID().getAccountID().getShardNum());
}
use of com.hederahashgraph.api.proto.java.Timestamp in project hedera-services by hashgraph.
the class BasicFcfsUsagePricesTest method getsTransferUsagePricesAtCurrent.
@Test
void getsTransferUsagePricesAtCurrent() {
// given:
subject.loadPriceSchedules();
Timestamp at = Timestamp.newBuilder().setSeconds(currentExpiry - 1).build();
// when:
Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
// then:
assertEquals(currentContractCallPrices, actual);
}
Aggregations