Skip to main content
Sign in
Snippets Groups Projects
Commit 65772940 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add wot tests related to issue #136

parent b871e19d
No related branches found
No related tags found
1 merge request!215refac membership
Pipeline #34848 failed
...@@ -584,8 +584,7 @@ fn test_cert_can_not_be_issued() { ...@@ -584,8 +584,7 @@ fn test_cert_can_not_be_issued() {
)); ));
run_to_block(11); run_to_block(11);
// /!\ COUNTERINTUITIVE BEHAVIOR // Dave should be able to receive a smith cert since
// Dave should not be able to receive a smith cert since he did not request smith membership
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(3), 3, 4)); assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(3), 3, 4));
// Bob renews his smith certification towards Alice // Bob renews his smith certification towards Alice
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(2), 2, 1)); assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(2), 2, 1));
...@@ -646,3 +645,54 @@ fn test_cert_can_not_be_issued() { ...@@ -646,3 +645,54 @@ fn test_cert_can_not_be_issued() {
// she would have been able to emit a cert without being member // she would have been able to emit a cert without being member
}) })
} }
/// test non smith identity can not emit smith cert
#[test]
fn test_non_smith_can_not_issue_smith_cert() {
new_test_ext(4, 3).execute_with(|| {
assert_noop!(
SmithCert::add_cert(RuntimeOrigin::signed(4), 4, 1),
pallet_certification::Error::<Test, Instance2>::NotEnoughCertReceived
);
})
}
/// FIXME this test should not fail with NotRespectCertPeriod but NotSmith or somthing like that
/// test non smith identity can not emit smith cert
#[test]
fn test_non_smith_with_certs_can_not_issue_smith_cert() {
new_test_ext(4, 3).execute_with(|| {
run_to_block(2);
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(1), 1, 4));
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(2), 2, 4));
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(3), 3, 4));
assert_noop!(
SmithCert::add_cert(RuntimeOrigin::signed(4), 4, 1),
pallet_certification::Error::<Test, Instance2>::NotRespectCertPeriod
);
})
}
/// FIXME this test should not succeed because Dave should not be able to issue cert
/// after revocation of his smith membership
/// test non smith identity can not emit smith cert
#[test]
fn test_revoked_smith_with_certs_can_not_issue_smith_cert() {
new_test_ext(4, 3).execute_with(|| {
run_to_block(2);
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(1), 1, 4));
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(2), 2, 4));
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(3), 3, 4));
assert_ok!(SmithMembership::claim_membership(RuntimeOrigin::signed(4)));
assert_noop!(
SmithCert::add_cert(RuntimeOrigin::signed(4), 4, 1),
pallet_certification::Error::<Test, Instance2>::NotRespectCertPeriod
);
run_to_block(4);
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(4), 4, 1),);
run_to_block(5);
assert_ok!(SmithMembership::revoke_membership(RuntimeOrigin::signed(4)));
run_to_block(6);
assert_ok!(SmithCert::add_cert(RuntimeOrigin::signed(4), 4, 1),);
})
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment