From dcdd6e6b0b945d0cf3be26a644e2b8b4be5a53da Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@trentesaux.fr> Date: Fri, 14 Apr 2023 16:59:00 +0200 Subject: [PATCH] wip add revocation test --- pallets/duniter-wot/src/tests.rs | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 1f40cab21..3c51f2f6b 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -251,6 +251,56 @@ fn test_confirm_idty_ok() { }); } +#[test] +fn test_revoke_idty() { + new_test_ext(5, 1).execute_with(|| { + run_to_block(2); + + // Alice identity can not be revoked because she's smith + assert_noop!( + Identity::revoke_identity( + RuntimeOrigin::signed(1), + 1, + 1, + TestSignature( + 1, + ( + REVOCATION_PAYLOAD_PREFIX, + RevocationPayload { + idty_index: 1u32, + genesis_hash: System::block_hash(0), + } + ) + .encode() + ) + ), + pallet_duniter_wot::Error::<Test, Instance2>::NotAllowedToRemoveIdty + ); + + // Anyone should be able to submit Bob revocation certificate + assert_ok!(Identity::revoke_identity( + RuntimeOrigin::signed(42), + 2, + 2, + TestSignature( + 2, + ( + REVOCATION_PAYLOAD_PREFIX, + RevocationPayload { + idty_index: 2u32, + genesis_hash: System::block_hash(0), + } + ) + .encode() + ) + )); + + System::assert_has_event(RuntimeEvent::Identity( + pallet_identity::Event::IdtyRemoved { idty_index: 2 }, + )); + }); +} + #[test] fn test_idty_membership_expire_them_requested() { new_test_ext(3, 2).execute_with(|| { -- GitLab