Search in sources :

Example 6 with Schedule

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

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

Example 8 with Schedule

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

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

Example 10 with 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);
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) Schedule(com.hedera.mirror.common.domain.schedule.Schedule) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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