use of com.hederahashgraph.api.proto.java.Duration in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method rejectsProlongedAutoRenewPeriod.
@Test
void rejectsProlongedAutoRenewPeriod() {
// setup:
Duration autoRenewPeriod = Duration.newBuilder().setSeconds(5_555_555L).build();
given(dynamicProperties.minAutoRenewDuration()).willReturn(1_000L);
given(dynamicProperties.maxAutoRenewDuration()).willReturn(1_000_000L);
// expect:
assertFalse(subject.isValidAutoRenewPeriod(autoRenewPeriod));
// and:
verify(dynamicProperties).minAutoRenewDuration();
verify(dynamicProperties).maxAutoRenewDuration();
}
use of com.hederahashgraph.api.proto.java.Duration in project hedera-services by hashgraph.
the class ContractUpdateTransitionLogicTest method givenValidTxnCtx.
private void givenValidTxnCtx(boolean useAutoRenew) {
Duration autoRenewDuration = Duration.newBuilder().setSeconds(customAutoRenewPeriod).build();
var op = TransactionBody.newBuilder().setTransactionID(ourTxnId()).setContractUpdateInstance(ContractUpdateTransactionBody.newBuilder().setMemo(memo).setContractID(target).setProxyAccountID(proxy));
if (useAutoRenew) {
op.getContractUpdateInstanceBuilder().setAutoRenewPeriod(autoRenewDuration);
op.getContractUpdateInstanceBuilder().setMemoWrapper(StringValue.newBuilder().setValue(memo));
}
contractUpdateTxn = op.build();
given(accessor.getTxn()).willReturn(contractUpdateTxn);
given(txnCtx.accessor()).willReturn(accessor);
given(contracts.get(EntityNum.fromContractId(target))).willReturn(contract);
}
use of com.hederahashgraph.api.proto.java.Duration in project hedera-services by hashgraph.
the class ContractUpdateTransitionLogicTest method withRubberstampingValidator.
private void withRubberstampingValidator() {
Duration autoRenewDuration = Duration.newBuilder().setSeconds(customAutoRenewPeriod).build();
given(validator.queryableContractStatus(EntityNum.fromContractId(target), contracts)).willReturn(OK);
given(validator.isValidAutoRenewPeriod(autoRenewDuration)).willReturn(true);
given(validator.memoCheck(memo)).willReturn(OK);
}
use of com.hederahashgraph.api.proto.java.Duration in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method rejectsBriefAutoRenewPeriod.
@Test
void rejectsBriefAutoRenewPeriod() {
// setup:
Duration autoRenewPeriod = Duration.newBuilder().setSeconds(55L).build();
given(dynamicProperties.minAutoRenewDuration()).willReturn(1_000L);
given(dynamicProperties.maxAutoRenewDuration()).willReturn(1_000_000L);
// expect:
assertFalse(subject.isValidAutoRenewPeriod(autoRenewPeriod));
// and:
verify(dynamicProperties).minAutoRenewDuration();
}
use of com.hederahashgraph.api.proto.java.Duration in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method acceptsReasonablePeriod.
@Test
void acceptsReasonablePeriod() {
// setup:
Duration autoRenewPeriod = Duration.newBuilder().setSeconds(500_000L).build();
given(dynamicProperties.minAutoRenewDuration()).willReturn(1_000L);
given(dynamicProperties.maxAutoRenewDuration()).willReturn(1_000_000L);
// expect:
assertTrue(subject.isValidAutoRenewPeriod(autoRenewPeriod));
// and:
verify(dynamicProperties).minAutoRenewDuration();
verify(dynamicProperties).maxAutoRenewDuration();
}