use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onSchedule.
@Test
void onSchedule() {
EntityId entityId1 = EntityId.of("0.0.100", EntityType.SCHEDULE);
EntityId entityId2 = EntityId.of("0.0.200", EntityType.SCHEDULE);
Schedule schedule1 = domainBuilder.schedule().get();
Schedule schedule2 = domainBuilder.schedule().get();
// when
sqlEntityListener.onSchedule(schedule1);
sqlEntityListener.onSchedule(schedule2);
completeFileAndCommit();
// then
assertThat(scheduleRepository.findAll()).containsExactlyInAnyOrder(schedule1, schedule2);
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onScheduleMerge.
@Test
void onScheduleMerge() {
Schedule schedule = domainBuilder.schedule().get();
sqlEntityListener.onSchedule(schedule);
Schedule scheduleUpdated = new Schedule();
scheduleUpdated.setScheduleId(schedule.getScheduleId());
scheduleUpdated.setExecutedTimestamp(5L);
sqlEntityListener.onSchedule(scheduleUpdated);
// when
completeFileAndCommit();
// then
schedule.setExecutedTimestamp(5L);
assertThat(scheduleRepository.findAll()).containsExactlyInAnyOrder(schedule);
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method onScheduledTransaction.
private void onScheduledTransaction(RecordItem recordItem) {
if (entityProperties.getPersist().isSchedules()) {
long consensusTimestamp = recordItem.getConsensusTimestamp();
TransactionRecord transactionRecord = recordItem.getRecord();
// update schedule execute time
Schedule schedule = new Schedule();
schedule.setScheduleId(EntityId.of(transactionRecord.getScheduleRef()));
schedule.setExecutedTimestamp(consensusTimestamp);
entityListener.onSchedule(schedule);
}
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class ScheduleCreateTransactionHandler method doUpdateTransaction.
@Override
protected void doUpdateTransaction(Transaction transaction, RecordItem recordItem) {
if (!recordItem.isSuccessful() || !entityProperties.getPersist().isSchedules()) {
return;
}
var body = recordItem.getTransactionBody().getScheduleCreate();
long consensusTimestamp = recordItem.getConsensusTimestamp();
var creatorAccount = recordItem.getPayerAccountId();
var expirationTime = body.hasExpirationTime() ? DomainUtils.timestampInNanosMax(body.getExpirationTime()) : null;
var payerAccount = body.hasPayerAccountID() ? EntityId.of(body.getPayerAccountID()) : creatorAccount;
var scheduleId = EntityId.of(recordItem.getRecord().getReceipt().getScheduleID());
Schedule schedule = new Schedule();
schedule.setConsensusTimestamp(consensusTimestamp);
schedule.setCreatorAccountId(creatorAccount);
schedule.setExpirationTime(expirationTime);
schedule.setPayerAccountId(payerAccount);
schedule.setScheduleId(scheduleId);
schedule.setTransactionBody(body.getScheduledTransactionBody().toByteArray());
schedule.setWaitForExpiry(body.getWaitForExpiry());
entityListener.onSchedule(schedule);
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class BatchUpserterTest method getSchedule.
private Schedule getSchedule(Long createdTimestamp, String scheduleId, Long executedTimestamp) {
Schedule schedule = new Schedule();
schedule.setConsensusTimestamp(createdTimestamp);
schedule.setCreatorAccountId(EntityId.of("0.0.123", EntityType.ACCOUNT));
schedule.setExecutedTimestamp(executedTimestamp);
schedule.setPayerAccountId(EntityId.of("0.0.456", EntityType.ACCOUNT));
schedule.setScheduleId(EntityId.of(scheduleId, EntityType.SCHEDULE));
schedule.setTransactionBody("transaction body".getBytes());
return schedule;
}
Aggregations