diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index e285dde5d0f2beb6fdd77abb682e2abcb7093eb6..0e23109449cf07ba176f2411c402d760699e6869 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -195,6 +195,7 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id for Pallet<T, I> { fn check_cert_allowed(issuer: IdtyIndex, receiver: IdtyIndex) -> Result<(), DispatchError> { + // ensure issuer has validated identity if let Some(issuer_data) = pallet_identity::Pallet::<T>::identity(issuer) { ensure!( issuer_data.status == IdtyStatus::Validated, @@ -203,6 +204,7 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id } else { return Err(Error::<T, I>::IdtyNotFound.into()); } + // ensure receiver has confirmed or validated identity if let Some(receiver_data) = pallet_identity::Pallet::<T>::identity(receiver) { match receiver_data.status { IdtyStatus::ConfirmedByOwner | IdtyStatus::Validated => {} // able to receive cert @@ -211,6 +213,9 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id } else { return Err(Error::<T, I>::IdtyNotFound.into()); } + /* if T::IsSubWot::get() { + // in case of smith wot no additional constraint + } */ Ok(()) } } diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 0588a74aabc46df705eca45fcea44c9ab94be44c..a8f404727843f8c2ef56a71c5c3ac33089cc40f9 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -172,6 +172,41 @@ fn test_remove_smith_identity() { )); }); } +use pallet_certification::Instance2; +#[test] +fn test_smith_certification() { + // 3 smith (1. alice, 2. bob, 3. charlie) + // 4 identities (4. dave) + // no identity 5. eve + ExtBuilder::new(1, 3, 4).build().execute_with(|| { + run_to_block(1); + + // alice can renew smith cert to bob + assert_ok!(SmithCert::add_cert( + frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), + 1, // alice + 2 // bob + )); + + // bob can add new smith cert to to dave even he did not requested smith membership + assert_ok!(SmithCert::add_cert( + frame_system::RawOrigin::Signed(AccountKeyring::Bob.to_account_id()).into(), + 2, // bob + 4 // dave + )); + + // charlie can not add new cert to to eve (no identity) + assert_noop!( + SmithCert::add_cert( + frame_system::RawOrigin::Signed(AccountKeyring::Charlie.to_account_id()).into(), + 3, // charlie + 5 // eve + ), + // SmithSubWot::Error::IdtyNotFound, + pallet_duniter_wot::Error::<gdev_runtime::Runtime, Instance2>::IdtyNotFound, + ); + }); +} #[test] fn test_create_new_account_with_insufficient_balance() {