Skip to content
Snippets Groups Projects
Commit f6766760 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

test(smith-members): test_smith_member_can_revoke_its_idty

parent f4da450b
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ use frame_support::traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait};
use frame_support::{assert_err, assert_noop, assert_ok};
use frame_support::{StorageHasher, Twox128};
use gdev_runtime::*;
use pallet_identity::{RevocationPayload, REVOCATION_PAYLOAD_PREFIX};
use pallet_membership::MembershipRemovalReason;
use pallet_smith_members::{SmithMeta, SmithStatus};
use sp_core::Encode;
......@@ -1335,6 +1336,63 @@ fn test_change_owner_key() {
})
}
/// members of the smith subwot can revoke their identity
#[test]
fn test_smith_member_can_revoke_its_idty() {
ExtBuilder::new(1, 3, 4).build().execute_with(|| {
run_to_block(2);
// Charlie goes online
frame_system::Pallet::<Runtime>::inc_providers(&AccountKeyring::Charlie.to_account_id());
assert_ok!(AuthorityMembers::set_session_keys(
frame_system::RawOrigin::Signed(AccountKeyring::Charlie.to_account_id()).into(),
create_dummy_session_keys()
));
assert_ok!(AuthorityMembers::go_online(
frame_system::RawOrigin::Signed(AccountKeyring::Charlie.to_account_id()).into()
));
run_to_block(25);
// Charlie is in the authority members
System::assert_has_event(RuntimeEvent::AuthorityMembers(
pallet_authority_members::Event::IncomingAuthorities { members: vec![3] },
));
// Charlie is not going out
assert_eq!(
pallet_authority_members::OutgoingAuthorities::<Runtime>::get().contains(&3),
false
);
let revocation_payload = RevocationPayload {
idty_index: 3u32,
genesis_hash: System::block_hash(0),
};
let signature =
AccountKeyring::Charlie.sign(&(REVOCATION_PAYLOAD_PREFIX, revocation_payload).encode());
assert_ok!(Identity::revoke_identity(
frame_system::RawOrigin::Signed(AccountKeyring::Charlie.to_account_id()).into(),
3,
AccountKeyring::Charlie.to_account_id(),
signature.into()
));
// membership should be removed
System::assert_has_event(RuntimeEvent::Membership(
pallet_membership::Event::MembershipRemoved {
member: 3,
reason: MembershipRemovalReason::Revoked,
},
));
// smith membership should be removed as well
System::assert_has_event(RuntimeEvent::SmithMembers(
pallet_smith_members::Event::SmithExcluded { idty_index: 3 },
));
// Now Charlie is going out
assert!(pallet_authority_members::OutgoingAuthorities::<Runtime>::get().contains(&3));
});
}
/// test genesis account of identity is linked to identity
// (and account without identity is not linked)
#[test]
......@@ -1446,7 +1504,6 @@ fn test_killed_account() {
})
}
// TODO: test_smith_member_can_revoke_its_idty
// TODO: test_revoke_idty
// TODO: test_non_smith_can_not_issue_smith_cert
// TODO: test_non_smith_can_not_issue_smith_cert
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment