diff --git a/task/src/lib.rs b/task/src/lib.rs index a8fd485..aed7409 100644 --- a/task/src/lib.rs +++ b/task/src/lib.rs @@ -36,7 +36,7 @@ //! //! When Tasks are created, there is some associated metadata that shall be defined. //! This includes the following: -//! - Task Description (Defining the Task description) +//! - Task Specification (Defining the Task specification) //! - Task Budget (The cost of completion for the Task) //! - Task Deadline (The specified time until which the task should be completed) //! @@ -97,7 +97,7 @@ pub mod pallet { #[scale_info(skip_type_params(T))] pub struct Task { pub title: Vec, - pub description: Vec, + pub specification: Vec, pub initiator: AccountOf, pub volunteer: AccountOf, pub current_owner: AccountOf, @@ -191,15 +191,15 @@ pub mod pallet { // Dispatchable functions must be annotated with a weight and must return a DispatchResult. #[pallet::call] impl Pallet { - /// Function call that creates tasks. [ origin, description, budget, deadline] + /// Function call that creates tasks. [ origin, specification, budget, deadline] #[pallet::weight(10_000 + T::DbWeight::get().writes(1))] - pub fn create_task(origin: OriginFor, title: Vec, description: Vec, budget: BalanceOf, deadline: u32) -> DispatchResultWithPostInfo { + pub fn create_task(origin: OriginFor, title: Vec, specification: Vec, budget: BalanceOf, deadline: u32) -> DispatchResultWithPostInfo { // Check that the extrinsic was signed and get the signer. let signer = ensure_signed(origin)?; // Update storage. - let task_id = Self::new_task(&signer, &title, &description, &budget, &deadline)?; + let task_id = Self::new_task(&signer, &title, &specification, &budget, &deadline)?; // TODO: Check if user has balance to create task // T::Currency::reserve(&signer, budget).map_err(|_| "locker can't afford to lock the amount requested")?; @@ -263,7 +263,7 @@ pub mod pallet { // *** Helper functions *** // impl Pallet { - pub fn new_task(from_initiator: &T::AccountId, title: &[u8], description: &[u8], budget: &BalanceOf, deadline: &u32) -> Result> { + pub fn new_task(from_initiator: &T::AccountId, title: &[u8], specification: &[u8], budget: &BalanceOf, deadline: &u32) -> Result> { // Ensure user has a profile before creating a task ensure!(pallet_profile::Pallet::::has_profile(from_initiator).unwrap(), >::NoProfile); @@ -271,7 +271,7 @@ pub mod pallet { // Init Task Object let task = Task:: { title: title.to_owned(), - description: description.to_owned(), + specification: specification.to_owned(), initiator: from_initiator.clone(), volunteer: from_initiator.clone(), status: Created, diff --git a/task/src/tests.rs b/task/src/tests.rs index 13232ef..49ea57f 100644 --- a/task/src/tests.rs +++ b/task/src/tests.rs @@ -15,7 +15,7 @@ fn create_new_task(){ let mut vec = Vec::new(); vec.push(2); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec, 7, DEADLINE)); }); } @@ -30,7 +30,7 @@ fn increase_task_count_when_creating_task(){ let mut vec = Vec::new(); vec.push(2); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec, 7, DEADLINE)); // Assert that count is incremented by 1 after task creation @@ -51,7 +51,7 @@ fn increase_task_count_when_creating_two_tasks(){ let mut vec2 = Vec::new(); vec2.push(7); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec2, 99, DEADLINE)); @@ -75,7 +75,7 @@ fn cant_own_more_tax_than_max_tasks(){ let mut vec1 = Vec::new(); vec1.push(n); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); } @@ -146,7 +146,7 @@ fn start_tasks_assigns_new_current_owner(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -175,7 +175,7 @@ fn start_tasks_assigns_task_to_volunteer(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -204,7 +204,7 @@ fn completing_tasks_assigns_new_current_owner(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -241,7 +241,7 @@ fn only_creator_deletes_task(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -281,7 +281,7 @@ fn only_started_task_can_be_completed(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget, deadline] + // Ensure new task can be created with [signer, specification, budget, deadline] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -311,7 +311,7 @@ fn when_task_is_removed_ownership_is_cleared(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -354,7 +354,7 @@ fn decrease_task_count_when_removing_task(){ let mut vec = Vec::new(); vec.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec, 8, DEADLINE)); // Get hash of task owned @@ -391,7 +391,7 @@ fn increase_profile_reputation_when_task_completed(){ let mut vec1 = Vec::new(); vec1.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec1, 7, DEADLINE)); // Ensure new task is assigned to new current_owner (user 1) @@ -428,7 +428,7 @@ fn only_add_reputation_when_task_has_been_completed(){ let mut vec = Vec::new(); vec.push(2); - // Ensure new task can be created with [signer, description vector, budget] + // Ensure new task can be created with [signer, specification, budget] assert_ok!(Task::create_task(Origin::signed(1), TITLE.to_vec(), vec, 8, DEADLINE)); // Get hash of task owned