Search in sources :

Example 1 with Schedule

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);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Schedule(com.hedera.mirror.common.domain.schedule.Schedule) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Schedule

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);
}
Also used : Schedule(com.hedera.mirror.common.domain.schedule.Schedule) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with 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);
    }
}
Also used : Schedule(com.hedera.mirror.common.domain.schedule.Schedule) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 4 with 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);
}
Also used : Schedule(com.hedera.mirror.common.domain.schedule.Schedule)

Example 5 with 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;
}
Also used : Schedule(com.hedera.mirror.common.domain.schedule.Schedule)

Aggregations

Schedule (com.hedera.mirror.common.domain.schedule.Schedule)10 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)2 Entity (com.hedera.mirror.common.domain.entity.Entity)1 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 ScheduleCreateTransactionBody (com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody)1 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1