This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
use crate::types::TippingName; | ||
use crate::{mock::*, Error, Event}; | ||
use frame_support::{assert_noop, assert_ok}; | ||
|
||
#[test] | ||
fn it_works_for_default_value() { | ||
fn check_create_project_function() { | ||
new_test_ext().execute_with(|| { | ||
// Go past genesis block so events get deposited | ||
System::set_block_number(1); | ||
// Dispatch a signed extrinsic. | ||
|
||
}); | ||
} | ||
let tipping_name = TippingName::SmallTipper; | ||
let tipping_value = ProjectTips::value_of_tipping_name(tipping_name); | ||
let max_tipping_value = tipping_value.max_tipping_value; | ||
let stake_required = tipping_value.stake_required; | ||
let funding_needed = max_tipping_value - 100; | ||
let balance = Balances::free_balance(1); | ||
assert_ok!(ProjectTips::create_project( | ||
RuntimeOrigin::signed(1), | ||
2, | ||
tipping_name, | ||
funding_needed | ||
)); | ||
|
||
#[test] | ||
fn correct_error_for_none_value() { | ||
new_test_ext().execute_with(|| { | ||
// Ensure the expected error is thrown when no value is present. | ||
|
||
let after_balance = Balances::free_balance(1); | ||
|
||
assert_eq!(after_balance, balance - stake_required); | ||
|
||
System::assert_last_event(Event::ProjectCreated { account: 1, project_id: 1 }.into()); | ||
|
||
let next_project_id = ProjectTips::next_project_id(); | ||
|
||
assert_eq!(2, next_project_id); | ||
|
||
let funding_needed = max_tipping_value + 100; | ||
|
||
assert_noop!( | ||
ProjectTips::create_project(RuntimeOrigin::signed(1), 2, tipping_name, funding_needed), | ||
Error::<Test>::FundingMoreThanTippingValue | ||
); | ||
}); | ||
} | ||
|