Skip to content
Snippets Groups Projects
Commit c62e49bb authored by Hugo Trentesaux's avatar Hugo Trentesaux Committed by Hugo Trentesaux
Browse files

reveal smith certification quirck

smith certification do not require smith membership request
parent 0ee70682
No related branches found
No related tags found
No related merge requests found
Pipeline #31709 skipped
......@@ -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(())
}
}
......
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment