From c06e4c826db0650d50f2a751cce68387cc6a0452 Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Sun, 4 Sep 2022 17:24:12 +0200 Subject: [PATCH] add test test_smith_member_cant_revoke_its_idty --- pallets/duniter-wot/src/tests.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 8ff6dddba..7e1e8e901 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -20,7 +20,10 @@ use codec::Encode; use frame_support::instances::Instance1; use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; -use pallet_identity::{IdtyName, IdtyStatus, NewOwnerKeyPayload, NEW_OWNER_KEY_PAYLOAD_PREFIX}; +use pallet_identity::{ + IdtyName, IdtyStatus, NewOwnerKeyPayload, RevocationPayload, NEW_OWNER_KEY_PAYLOAD_PREFIX, + REVOCATION_PAYLOAD_PREFIX, +}; use sp_runtime::testing::TestSignature; #[test] @@ -94,7 +97,7 @@ fn test_smith_certs_expirations_should_revoke_smith_membership() { } #[test] -fn test_smith_member_cant_change_idty_address() { +fn test_smith_member_cant_change_its_idty_address() { new_test_ext(5, 3).execute_with(|| { run_to_block(2); @@ -117,6 +120,29 @@ fn test_smith_member_cant_change_idty_address() { }); } +#[test] +fn test_smith_member_cant_revoke_its_idty() { + new_test_ext(5, 3).execute_with(|| { + run_to_block(2); + + let revocation_payload = RevocationPayload { + idty_index: 3u32, + genesis_hash: System::block_hash(0), + }; + + // Identity 3 can't change it's address + assert_noop!( + Identity::revoke_identity( + Origin::signed(3), + 3, + 3, + TestSignature(3, (REVOCATION_PAYLOAD_PREFIX, revocation_payload).encode()) + ), + pallet_identity::Error::<Test>::NotAllowedToRemoveIdty + ); + }); +} + #[test] fn test_revoke_smiths_them_rejoin() { new_test_ext(5, 4).execute_with(|| { -- GitLab