Search in sources :

Example 1 with Duration

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();
}
Also used : Duration(com.hederahashgraph.api.proto.java.Duration) Test(org.junit.jupiter.api.Test)

Example 2 with Duration

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);
}
Also used : Duration(com.hederahashgraph.api.proto.java.Duration)

Example 3 with Duration

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);
}
Also used : Duration(com.hederahashgraph.api.proto.java.Duration)

Example 4 with Duration

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();
}
Also used : Duration(com.hederahashgraph.api.proto.java.Duration) Test(org.junit.jupiter.api.Test)

Example 5 with Duration

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();
}
Also used : Duration(com.hederahashgraph.api.proto.java.Duration) Test(org.junit.jupiter.api.Test)

Aggregations

Duration (com.hederahashgraph.api.proto.java.Duration)5 Test (org.junit.jupiter.api.Test)3