use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class ScheduleRepositoryTest method save.
@Test
void save() {
Schedule schedule = scheduleRepository.save(schedule(1));
assertThat(scheduleRepository.findById(schedule.getScheduleId())).get().isEqualTo(schedule);
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class ScheduleRepositoryTest method updateExecutedTimestamp.
@Test
void updateExecutedTimestamp() {
Schedule schedule = scheduleRepository.save(schedule(1));
long newExecutedTimestamp = 1000L;
scheduleRepository.updateExecutedTimestamp(schedule.getScheduleId(), newExecutedTimestamp);
assertThat(scheduleRepository.findById(schedule.getScheduleId())).get().returns(newExecutedTimestamp, from(Schedule::getExecutedTimestamp));
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class ScheduleRepositoryTest method schedule.
private Schedule schedule(long consensusTimestamp) {
Schedule schedule = new Schedule();
schedule.setConsensusTimestamp(consensusTimestamp);
schedule.setCreatorAccountId(EntityId.of("0.0.123", EntityType.ACCOUNT));
schedule.setPayerAccountId(EntityId.of("0.0.456", EntityType.ACCOUNT));
schedule.setScheduleId(EntityId.of("0.0.789", EntityType.SCHEDULE));
schedule.setTransactionBody("transaction body".getBytes());
return schedule;
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertScheduleCreate.
private void insertScheduleCreate(RecordItem recordItem) {
if (entityProperties.getPersist().isSchedules()) {
ScheduleCreateTransactionBody scheduleCreateTransactionBody = recordItem.getTransactionBody().getScheduleCreate();
long consensusTimestamp = recordItem.getConsensusTimestamp();
var scheduleId = EntityId.of(recordItem.getRecord().getReceipt().getScheduleID());
var creatorAccount = recordItem.getPayerAccountId();
var payerAccount = creatorAccount;
if (scheduleCreateTransactionBody.hasPayerAccountID()) {
payerAccount = EntityId.of(scheduleCreateTransactionBody.getPayerAccountID());
}
Schedule schedule = new Schedule();
schedule.setConsensusTimestamp(consensusTimestamp);
schedule.setCreatorAccountId(creatorAccount);
schedule.setPayerAccountId(payerAccount);
schedule.setScheduleId(scheduleId);
schedule.setTransactionBody(scheduleCreateTransactionBody.getScheduledTransactionBody().toByteArray());
entityListener.onSchedule(schedule);
}
}
use of com.hedera.mirror.common.domain.schedule.Schedule in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerScheduleTest method scheduleCreate.
@ParameterizedTest(name = "{2}")
@MethodSource("provideScheduleCreatePayer")
void scheduleCreate(AccountID payer, AccountID expectedPayer, String name) {
insertScheduleCreateTransaction(CREATE_TIMESTAMP, payer, SCHEDULE_ID);
// verify entity count
Entity expectedEntity = createEntity(EntityId.of(SCHEDULE_ID), SCHEDULE_REF_KEY, null, null, false, null, SCHEDULE_CREATE_MEMO, null, CREATE_TIMESTAMP, CREATE_TIMESTAMP);
Schedule expectedSchedule = Schedule.builder().consensusTimestamp(CREATE_TIMESTAMP).creatorAccountId(EntityId.of(PAYER)).payerAccountId(EntityId.of(expectedPayer)).scheduleId(EntityId.of(SCHEDULE_ID).getId()).transactionBody(SCHEDULED_TRANSACTION_BODY.toByteArray()).build();
assertEquals(1, entityRepository.count());
assertEntity(expectedEntity);
// verify schedule and signatures
assertThat(scheduleRepository.findAll()).containsOnly(expectedSchedule);
assertTransactionSignatureInRepository(defaultSignatureList);
// verify transaction
assertTransactionInRepository(CREATE_TIMESTAMP, false, SUCCESS);
}
Aggregations