-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add membership pallet used to manage foundation members only allowed method is for the member to change his key
- Loading branch information
Showing
12 changed files
with
171 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -13,3 +13,5 @@ mod proxy; | |
mod identity; | ||
|
||
mod maintenance; | ||
|
||
mod membership; |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::setup::*; | ||
use frame_support::traits::Contains; | ||
use sp_runtime::testing::H256; | ||
|
||
fn test_env() -> TestExternalities { | ||
ExtBuilder { ..ExtBuilder::default() }.build() | ||
} | ||
|
||
#[test] | ||
fn change_key_works() { | ||
let mut ext = test_env(); | ||
ext.execute_with(|| { | ||
System::set_block_number(1); | ||
|
||
let alice = AccountId::from(ALICE); | ||
let bob = AccountId::from(BOB); | ||
|
||
assert_err!( | ||
FoundationMembers::change_key(RuntimeOrigin::signed(bob.clone()), alice), | ||
pallet_membership::Error::<Runtime>::NotMember, | ||
); | ||
|
||
assert!(<FoundationMembers as Contains<_>>::contains(&alice)); | ||
|
||
assert_ok!(FoundationMembers::change_key( | ||
RuntimeOrigin::signed( | ||
FoundationAccountsProvider::get().pop().expect("There atleast 1 F acc") | ||
) | ||
.into(), | ||
bob, | ||
)); | ||
|
||
assert!(!<FoundationMembers as Contains<_>>::contains(&alice)); | ||
assert!(<FoundationMembers as Contains<_>>::contains(&bob)); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn other_fn_doesnt_work_for_root() { | ||
let mut ext = test_env(); | ||
ext.execute_with(|| { | ||
System::set_block_number(1); | ||
|
||
let alice = AccountId::from(ALICE); | ||
let bob = AccountId::from(BOB); | ||
let origin: RuntimeOrigin = frame_system::RawOrigin::Root.into(); | ||
|
||
assert_err!(FoundationMembers::add_member(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::remove_member(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::swap_member(origin.clone(), alice, bob), BadOrigin,); | ||
assert_err!(FoundationMembers::reset_members(origin.clone(), vec![]), BadOrigin,); | ||
assert_err!(FoundationMembers::set_prime(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::clear_prime(origin.clone()), BadOrigin,); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn other_fn_doesnt_work_for_foundation() { | ||
let mut ext = test_env(); | ||
ext.execute_with(|| { | ||
System::set_block_number(1); | ||
|
||
let alice = AccountId::from(ALICE); | ||
let bob = AccountId::from(BOB); | ||
let origin: RuntimeOrigin = RuntimeOrigin::signed( | ||
FoundationAccountsProvider::get().pop().expect("There atleast 1 F acc"), | ||
); | ||
|
||
assert_err!(FoundationMembers::add_member(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::remove_member(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::swap_member(origin.clone(), alice, bob), BadOrigin,); | ||
assert_err!(FoundationMembers::reset_members(origin.clone(), vec![]), BadOrigin,); | ||
assert_err!(FoundationMembers::set_prime(origin.clone(), bob), BadOrigin,); | ||
assert_err!(FoundationMembers::clear_prime(origin.clone()), BadOrigin,); | ||
}); | ||
} |
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
Oops, something went wrong.