diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index bcd64dafafc59d15314af3ced929c5e2d3fdea98..b25d29d346408f049c9dbce598b017cafb365941 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -209,6 +209,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, @@ -217,6 +218,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 @@ -225,6 +227,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 b7eb8a87f20d99898a799528a1d89820668ffd2e..60783623a7d46173360d5876d90899e5ea27f432 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -631,6 +631,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 create new account with balance lower than existential deposit // the treasury gets the dust