Skip to content
Snippets Groups Projects
Commit 1e99f6b2 authored by Millicent Billette's avatar Millicent Billette
Browse files

test smith_members_should_not_be_able_to_invite_more_than_smith_cert_limit...

test smith_members_should_not_be_able_to_invite_more_than_smith_cert_limit fail like observed in gdev.
parent a0afb078
Branches 1000i100-test
No related tags found
No related merge requests found
Pipeline #39156 waiting for manual action
......@@ -186,6 +186,7 @@ pub mod pallet {
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
/// Receiver -> (is_online, issuers)
pub initial_smiths: BTreeMap<T::IdtyIndex, (bool, Vec<T::IdtyIndex>)>,
}
......
......@@ -721,3 +721,31 @@ fn losing_wot_membership_cascades_to_smith_members() {
);
});
}
#[test]
fn smith_members_should_not_be_able_to_invite_more_than_smith_cert_limit() { // MaxByIssuer
new_test_ext(GenesisConfig {
initial_smiths: btreemap![
1 => (true, vec![2, 3, 4]),
2 => (false, vec![3, 4]),
3 => (false, vec![1, 2]),
4 => (false, vec![]),
],
})
.execute_with(|| {
let max_by_issuer:u32 = <mock::Runtime as pallet::Config>::MaxByIssuer::get();
let max_by_issuer:u64 = max_by_issuer as _;
// Smith 1 Invite MaxByIssuer+1 member to become Simth
// Theses invites should pass
// Only MaxByIssuer - already_certified_by_1 (here -1 : smith 3) are invited
for i in 0..max_by_issuer-1 {
Pallet::<Runtime>::invite_smith(RuntimeOrigin::signed(1), 11+i).unwrap();
assert!(Smiths::<Runtime>::get(11+i).is_some());
}
// Theses invites should fail
// the other try to invite (here the 2 last) return error and are not invited
for i in max_by_issuer-1..max_by_issuer+1 {
Pallet::<Runtime>::invite_smith(RuntimeOrigin::signed(1), 11+i).unwrap_err();
assert!(Smiths::<Runtime>::get(11+i).is_none());
}
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment