Skip to content

Commit

Permalink
Emit TaskCompleted event when a Fixed task is completed (#385)
Browse files Browse the repository at this point in the history
* Emit TaskCompleted event when a Fixed task is completed

* Fix tests

* Add test scenarios for task failure and cancellation

* Fix expect text in will_emit_task_completed_event_when_task_completed
  • Loading branch information
imstar15 committed Jul 20, 2023
1 parent 54272be commit 0ebac69
Show file tree
Hide file tree
Showing 2 changed files with 310 additions and 25 deletions.
8 changes: 8 additions & 0 deletions pallets/automation-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ pub mod pallet {
task_id: TaskId<T>,
error: DispatchError,
},
TaskCompleted {
who: AccountOf<T>,
task_id: TaskId<T>,
},
}

#[pallet::hooks]
Expand Down Expand Up @@ -1183,6 +1187,10 @@ pub mod pallet {
*executions_left = executions_left.saturating_sub(1);
if *executions_left <= 0 {
AccountTasks::<T>::remove(task.owner_id.clone(), task_id);
Self::deposit_event(Event::TaskCompleted {
who: task.owner_id.clone(),
task_id,
});
} else {
AccountTasks::<T>::insert(task.owner_id.clone(), task_id, task);
}
Expand Down
Loading

0 comments on commit 0ebac69

Please sign in to comment.