use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ScheduleDeleteResourceUsageTest method returnsDefaultIfInfoMissing.
@Test
void returnsDefaultIfInfoMissing() throws Exception {
// setup:
long start = 1_234_567L;
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(start)).build();
given(scheduleDeleteTxn.getTransactionID()).willReturn(txnId);
given(view.infoForSchedule(target)).willReturn(Optional.empty());
given(scheduleOpsUsage.scheduleDeleteUsage(scheduleDeleteTxn, sigUsage, start + 1800)).willReturn(expected);
// expect:
assertEquals(expected, subject.usageGiven(scheduleDeleteTxn, obj, view));
// and:
verify(view).infoForSchedule(target);
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method acceptsOk.
@Test
void acceptsOk() {
SignedTxnAccessor accessor = mock(SignedTxnAccessor.class);
// given:
long validDuration = 1_000L;
Instant consensusTime = Instant.ofEpochSecond(1_234_567L);
Instant validStart = Instant.ofEpochSecond(consensusTime.minusSeconds(validDuration - 1).getEpochSecond());
// and:
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(validStart.getEpochSecond())).build();
TransactionBody txn = TransactionBody.newBuilder().setTransactionID(txnId).setTransactionValidDuration(Duration.newBuilder().setSeconds(validDuration)).build();
// and:
given(accessor.getTxn()).willReturn(txn);
given(accessor.getTxnId()).willReturn(txnId);
// when:
ResponseCodeEnum status = subject.chronologyStatus(accessor, consensusTime);
// then:
assertEquals(OK, status);
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ContextOptionValidatorTest method recognizesFutureValidStartStart.
@Test
void recognizesFutureValidStartStart() {
SignedTxnAccessor accessor = mock(SignedTxnAccessor.class);
// given:
long validDuration = 1_000L;
Instant consensusTime = Instant.ofEpochSecond(1_234_567L);
Instant validStart = Instant.ofEpochSecond(consensusTime.plusSeconds(1L).getEpochSecond());
// and:
TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(validStart.getEpochSecond())).build();
TransactionBody txn = TransactionBody.newBuilder().setTransactionID(txnId).setTransactionValidDuration(Duration.newBuilder().setSeconds(validDuration)).build();
// and:
given(accessor.getTxn()).willReturn(txn);
given(accessor.getTxnId()).willReturn(txnId);
// when:
ResponseCodeEnum status = subject.chronologyStatus(accessor, consensusTime);
// then:
assertEquals(INVALID_TRANSACTION_START, status);
// and:
assertEquals(INVALID_TRANSACTION_START, subject.chronologyStatusForTxn(validStart, validDuration, consensusTime));
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact.
private HapiApiSpec scheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact() {
String immutableTopic = "XXX";
String validSchedule = "withValidChunkNumber";
String invalidSchedule = "withInvalidChunkNumber";
String schedulePayer = "somebody";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
AtomicReference<TransactionID> initialTxnId = new AtomicReference<>();
return defaultHapiSpec("ScheduledSubmitFailedWithInvalidChunkNumberStillPaysServiceFeeButHasNoImpact").given(createTopic(immutableTopic), cryptoCreate(schedulePayer)).when(withOpContext((spec, opLog) -> {
var subOp = usableTxnIdNamed(successTxn).payerId(schedulePayer);
allRunFor(spec, subOp);
initialTxnId.set(spec.registry().getTxnId(successTxn));
}), sourcing(() -> scheduleCreate(validSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 1, scheduledVersionOf(initialTxnId.get()))).txnId(successTxn).logged().signedBy(schedulePayer)), getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 111, schedulePayer)).via(failedTxn).logged().payingWith(schedulePayer)).then(getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(INVALID_CHUNK_NUMBER)).revealingDebitsTo(failureFeesObs::set), assertionsHold((spec, opLog) -> Assertions.assertEquals(successFeesObs.get(), failureFeesObs.get())));
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class ScheduleExecutionSpecs method scheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact.
private HapiApiSpec scheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact() {
String immutableTopic = "XXX";
String validSchedule = "withValidChunkTxnId";
String invalidSchedule = "withInvalidChunkTxnId";
String schedulePayer = "somebody";
String successTxn = "good", failedTxn = "bad";
AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
AtomicReference<TransactionID> initialTxnId = new AtomicReference<>();
AtomicReference<TransactionID> irrelevantTxnId = new AtomicReference<>();
return defaultHapiSpec("ScheduledSubmitFailedWithInvalidChunkTxnIdStillPaysServiceFeeButHasNoImpact").given(createTopic(immutableTopic), cryptoCreate(schedulePayer)).when(withOpContext((spec, opLog) -> {
var subOp = usableTxnIdNamed(successTxn).payerId(schedulePayer);
var secondSubOp = usableTxnIdNamed("wontWork").payerId(schedulePayer);
allRunFor(spec, subOp, secondSubOp);
initialTxnId.set(spec.registry().getTxnId(successTxn));
irrelevantTxnId.set(spec.registry().getTxnId("wontWork"));
}), sourcing(() -> scheduleCreate(validSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 1, scheduledVersionOf(initialTxnId.get()))).txnId(successTxn).logged().signedBy(schedulePayer)), getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), sourcing(() -> scheduleCreate(invalidSchedule, submitMessageTo(immutableTopic).chunkInfo(3, 1, scheduledVersionOf(irrelevantTxnId.get()))).designatingPayer(schedulePayer).via(failedTxn).logged().signedBy(DEFAULT_PAYER, schedulePayer))).then(getTopicInfo(immutableTopic).hasSeqNo(1L), getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(INVALID_CHUNK_TRANSACTION_ID)).revealingDebitsTo(failureFeesObs::set), assertionsHold((spec, opLog) -> Assertions.assertEquals(successFeesObs.get(), failureFeesObs.get())));
}
Aggregations