123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- use super::*;
- #[test]
- fn remove_curator_from_group_success() {
- with_test_externalities(|| {
- // Add curator group
- assert_ok!(add_curator_group(LEAD_ORIGIN));
- // Add first curator to group
- assert_ok!(add_curator_to_group(
- LEAD_ORIGIN,
- FIRST_CURATOR_GROUP_ID,
- FIRST_CURATOR_ID
- ));
- // Add second curator to group
- assert_ok!(add_curator_to_group(
- LEAD_ORIGIN,
- FIRST_CURATOR_GROUP_ID,
- SECOND_CURATOR_ID
- ));
- // Runtime tested state before call
- // Events number before tested call
- let number_of_events_before_call = System::events().len();
- // Remove first curator from group
- assert_ok!(remove_curator_from_group(
- LEAD_ORIGIN,
- FIRST_CURATOR_GROUP_ID,
- FIRST_CURATOR_ID
- ));
- // Runtime tested state after call
- // Ensure group contains only second curator
- let mut curator_group = CuratorGroup::default();
- curator_group.get_curators_mut().insert(SECOND_CURATOR_ID);
- assert_eq!(curator_group_by_id(FIRST_CURATOR_GROUP_ID), curator_group);
- let curator_group_curator_removed_event = get_test_event(RawEvent::CuratorRemoved(
- FIRST_CURATOR_GROUP_ID,
- FIRST_CURATOR_ID,
- ));
- // Event checked
- assert_event(
- curator_group_curator_removed_event,
- number_of_events_before_call + 1,
- );
- })
- }
- #[test]
- fn remove_curator_from_group_lead_auth_failed() {
- with_test_externalities(|| {
- // Add curator group
- assert_ok!(add_curator_group(LEAD_ORIGIN));
- // Add curator to group
- assert_ok!(add_curator_to_group(
- LEAD_ORIGIN,
- FIRST_CURATOR_GROUP_ID,
- FIRST_CURATOR_ID
- ));
- // Runtime tested state before call
- // Events number before tested call
- let number_of_events_before_call = System::events().len();
- // Make an attempt to remove curator from group using non lead origin
- let remove_curator_from_group_result = remove_curator_from_group(
- FIRST_MEMBER_ORIGIN,
- FIRST_CURATOR_GROUP_ID,
- FIRST_CURATOR_ID,
- );
- // Failure checked
- assert_failure(
- remove_curator_from_group_result,
- Error::<Runtime>::LeadAuthFailed,
- number_of_events_before_call,
- );
- })
- }
- #[test]
- fn remove_curator_from_group_curator_is_not_a_member() {
- with_test_externalities(|| {
- // Add curator group
- assert_ok!(add_curator_group(LEAD_ORIGIN));
- // Runtime tested state before call
- // Events number before tested call
- let number_of_events_before_call = System::events().len();
- // Make an attempt to remove curator that does not added to the provided curator group
- let remove_curator_from_group_result =
- remove_curator_from_group(LEAD_ORIGIN, FIRST_CURATOR_GROUP_ID, UNKNOWN_CURATOR_ID);
- // Failure checked
- assert_failure(
- remove_curator_from_group_result,
- Error::<Runtime>::CuratorIsNotAMemberOfGivenCuratorGroup,
- number_of_events_before_call,
- );
- })
- }
- #[test]
- fn remove_curator_from_non_existent_group() {
- with_test_externalities(|| {
- // Runtime tested state before call
- // Events number before tested call
- let number_of_events_before_call = System::events().len();
- // Make an attempt to remove curator from group using non lead origin
- let remove_curator_from_group_result =
- remove_curator_from_group(LEAD_ORIGIN, UNKNOWN_CURATOR_GROUP_ID, FIRST_CURATOR_ID);
- // Failure checked
- assert_failure(
- remove_curator_from_group_result,
- Error::<Runtime>::CuratorGroupDoesNotExist,
- number_of_events_before_call,
- );
- })
- }
|