Browse Source

test code clean-up

iorveth 4 years ago
parent
commit
3e47f56e81

+ 6 - 10
runtime-modules/content-directory/src/tests/add_class_schema.rs

@@ -75,7 +75,7 @@ fn add_class_schema_lead_auth_failied() {
             FIRST_MEMBER_ORIGIN,
             FIRST_CLASS_ID,
             BTreeSet::new(),
-            vec![property.clone()],
+            vec![property],
         );
 
         // Failure checked
@@ -103,7 +103,7 @@ fn add_class_schema_class_does_not_exist() {
             LEAD_ORIGIN,
             UNKNOWN_CLASS_ID,
             BTreeSet::new(),
-            vec![property.clone()],
+            vec![property],
         );
 
         // Failure checked
@@ -136,12 +136,8 @@ fn add_class_schema_limit_reached() {
             );
 
             // Add class schema
-            let add_class_schema_result = add_class_schema(
-                LEAD_ORIGIN,
-                FIRST_CLASS_ID,
-                BTreeSet::new(),
-                vec![property.clone()],
-            );
+            let add_class_schema_result =
+                add_class_schema(LEAD_ORIGIN, FIRST_CLASS_ID, BTreeSet::new(), vec![property]);
 
             if add_class_schema_result.is_err() {
                 break add_class_schema_result;
@@ -242,7 +238,7 @@ fn add_class_schema_prop_name_not_unique() {
             LEAD_ORIGIN,
             FIRST_CLASS_ID,
             BTreeSet::new(),
-            vec![first_property.clone()]
+            vec![first_property]
         ));
 
         // Events number before tested call
@@ -253,7 +249,7 @@ fn add_class_schema_prop_name_not_unique() {
             LEAD_ORIGIN,
             FIRST_CLASS_ID,
             BTreeSet::from_iter(vec![FIRST_PROPERTY_ID].into_iter()),
-            vec![second_property.clone()],
+            vec![second_property],
         );
 
         // Failure checked

+ 9 - 9
runtime-modules/content-directory/src/tests/add_schema_support_to_entity.rs

@@ -617,7 +617,7 @@ fn add_schema_support_is_not_active() {
         schema_property_values.insert(FIRST_PROPERTY_ID, PropertyValue::default());
 
         // Make an attempt to add schema support to Entity, providing schema id,
-        // which correspondin class Schema is not active
+        // which corresponding class Schema is not active
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
             actor,
@@ -865,13 +865,13 @@ fn add_schema_support_referenced_entity_does_not_match_class() {
         schema_property_values.insert(FIRST_PROPERTY_ID, schema_property_value);
 
         // Make an attempt to add schema support to the Entity, when provided schema property value(s) refer(s) Entity, which Class
-        // does not match the class in corresponding Class Schema
+        // does not match the class in corresponding Class Property
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
-            schema_property_values.clone(),
+            schema_property_values,
         );
 
         // Failure checked
@@ -930,7 +930,7 @@ fn add_schema_support_referenced_entity_does_not_exist() {
         // which does not exist in runtime
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values,
@@ -1000,7 +1000,7 @@ fn add_schema_support_entity_can_not_be_referenced() {
         // refer(s) to Entity which can not be referenced
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values,
@@ -1076,7 +1076,7 @@ fn add_schema_support_same_controller_constraint_violation() {
         // when corresponding Entity can only be referenced from Entity with the same controller.
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values,
@@ -1136,7 +1136,7 @@ fn add_schema_support_text_property_is_too_long() {
         // length exceeds TextMaxLengthConstraint.
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values,
@@ -1212,7 +1212,7 @@ fn add_schema_support_vec_property_is_too_long() {
         // length exceeds VecMaxLengthConstraint.
         let add_schema_support_to_entity_result = add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values,

+ 3 - 7
runtime-modules/content-directory/src/tests/clear_entity_property_vector.rs

@@ -77,12 +77,8 @@ fn clear_entity_property_vector_entity_not_found() {
 
         // Make an attempt to clear property_vector under given `entity_id` & `in_class_schema_property_id`
         // in case when corresponding Entity does not exist
-        let clear_entity_property_vector_result = clear_entity_property_vector(
-            LEAD_ORIGIN,
-            actor.clone(),
-            FIRST_ENTITY_ID,
-            FIRST_PROPERTY_ID,
-        );
+        let clear_entity_property_vector_result =
+            clear_entity_property_vector(LEAD_ORIGIN, actor, FIRST_ENTITY_ID, FIRST_PROPERTY_ID);
 
         // Failure checked
         assert_failure(
@@ -396,7 +392,7 @@ fn clear_entity_property_vector_is_locked_for_given_actor() {
         // Add schema support to the entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            Actor::Lead,
+            actor.clone(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values

+ 9 - 13
runtime-modules/content-directory/src/tests/create_entity.rs

@@ -51,7 +51,7 @@ fn create_entity_success() {
 
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),
-            entity_voucher.clone(),
+            entity_voucher,
         );
 
         // Ensure new entity created
@@ -89,7 +89,7 @@ fn create_entity_of_non_existent_class() {
         let actor = Actor::Lead;
 
         // Make an attempt to create Entity of non existent Class
-        let create_entity_result = create_entity(LEAD_ORIGIN, UNKNOWN_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(LEAD_ORIGIN, UNKNOWN_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -178,7 +178,7 @@ fn create_entity_creation_blocked_on_class_level() {
         let actor = Actor::Lead;
 
         // Make an attempt to create Entity, when entiti creation was previously blocked on class level
-        let create_entity_result = create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Runtime tested state after call
 
@@ -205,8 +205,7 @@ fn create_entity_lead_auth_failed() {
         let actor = Actor::Lead;
 
         // Make an attempt to authorize as Lead under non lead origin
-        let create_entity_result =
-            create_entity(FIRST_MEMBER_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(FIRST_MEMBER_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -241,7 +240,7 @@ fn create_entity_member_auth_failed() {
         let actor = Actor::Member(UNKNOWN_MEMBER_ID);
 
         // Make an attempt to authorize under non existent member id
-        let create_entity_result = create_entity(UNKNOWN_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(UNKNOWN_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -266,7 +265,7 @@ fn create_entity_actor_can_not_create_entities() {
         let actor = Actor::Member(UNKNOWN_MEMBER_ID);
 
         // Make an attempt to create entity, authorizing as member in case, when members are not permitted to create entities on class level
-        let create_entity_result = create_entity(UNKNOWN_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(UNKNOWN_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -309,8 +308,7 @@ fn create_entity_unknown_curator_id() {
 
         // Make an attempt to create entity, authorizing as curator in group,
         // in case, when provided curator id wasn`t added to respective curator group set
-        let create_entity_result =
-            create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -353,8 +351,7 @@ fn create_entity_curator_group_is_not_active() {
 
         // Make an attempt to create entity, authorizing as curator in group, in case, when
         // corresponding curator group is not active. (default status of curator group right after creation)
-        let create_entity_result =
-            create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(
@@ -397,8 +394,7 @@ fn create_entity_curator_not_found_in_curator_group() {
 
         // Make an attempt to create entity, authorizing as curator in group, in case, when
         // curator was not added to corresponding curator group.
-        let create_entity_result =
-            create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor.clone());
+        let create_entity_result = create_entity(FIRST_CURATOR_ORIGIN, FIRST_CLASS_ID, actor);
 
         // Failure checked
         assert_failure(

+ 5 - 5
runtime-modules/content-directory/src/tests/insert_at_entity_property_vector.rs

@@ -45,7 +45,7 @@ fn insert_at_entity_property_vector_success() {
 
         // Ensure reference counter of second entity updated succesfully
         let inbound_rc = InboundReferenceCounter::new(4, true);
-        *second_entity.get_reference_counter_mut() = inbound_rc.clone();
+        *second_entity.get_reference_counter_mut() = inbound_rc;
 
         assert_eq!(second_entity, entity_by_id(SECOND_ENTITY_ID));
 
@@ -487,7 +487,7 @@ fn insert_at_entity_property_vector_is_locked_for_given_actor() {
         // Add schema support to the entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            Actor::Lead,
+            actor.clone(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -649,7 +649,7 @@ fn insert_at_entity_property_vector_nonces_does_not_match() {
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
 
         // Create class reference schema and add corresponding schema support to the Entity
-        add_class_reference_schema_and_entity_schema_support(&Actor::Lead, LEAD_ORIGIN);
+        add_class_reference_schema_and_entity_schema_support(&actor, LEAD_ORIGIN);
 
         // Runtime state before tested call
 
@@ -708,7 +708,7 @@ fn insert_at_entity_property_vector_index_is_out_of_range() {
             actor.to_owned(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
-            schema_property_values.clone()
+            schema_property_values
         ));
 
         // Runtime state before tested call
@@ -768,7 +768,7 @@ fn insert_at_entity_property_vector_is_too_long() {
             actor.to_owned(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
-            schema_property_values.clone()
+            schema_property_values
         ));
 
         // Runtime state before tested call

+ 4 - 4
runtime-modules/content-directory/src/tests/remove_at_entity_property_vector.rs

@@ -42,7 +42,7 @@ fn remove_at_entity_property_vector_success() {
 
         // Ensure reference counter of second entity updated succesfully
         let inbound_rc = InboundReferenceCounter::new(2, true);
-        *second_entity.get_reference_counter_mut() = inbound_rc.clone();
+        *second_entity.get_reference_counter_mut() = inbound_rc;
 
         assert_eq!(second_entity, entity_by_id(SECOND_ENTITY_ID));
 
@@ -88,7 +88,7 @@ fn remove_at_entity_property_vector_entity_not_found() {
         // from `PropertyValueVec` under `in_class_schema_property_id` in case when corresponding Entity does not exist
         let remove_at_entity_property_vector_result = remove_at_entity_property_vector(
             LEAD_ORIGIN,
-            actor.clone(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_PROPERTY_ID,
             index_in_property_vector,
@@ -463,7 +463,7 @@ fn remove_at_entity_property_vector_is_locked_for_given_actor() {
         // Add schema support to the entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            Actor::Lead,
+            actor.clone(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -676,7 +676,7 @@ fn remove_at_entity_property_vector_index_is_out_of_range() {
             actor.to_owned(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
-            schema_property_values.clone()
+            schema_property_values
         ));
 
         // Runtime state before tested call

+ 1 - 1
runtime-modules/content-directory/src/tests/remove_entity.rs

@@ -31,7 +31,7 @@ fn remove_entity_success() {
 
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),
-            entity_voucher.clone(),
+            entity_voucher,
         );
 
         let entity_removed_event =

+ 2 - 2
runtime-modules/content-directory/src/tests/transaction.rs

@@ -94,8 +94,8 @@ fn transaction_limit_reached() {
 
         let actor = Actor::Lead;
 
-        // make an attempt to complete transaction with operations, which total number exceeds MaxNumberOfOperationsDuringAtomicBatching runtime constraint
-        let transaction_result = transaction(LEAD_ORIGIN, actor.clone(), operations);
+        // Make an attempt to complete transaction with operations, which total number exceeds MaxNumberOfOperationsDuringAtomicBatching runtime constraint
+        let transaction_result = transaction(LEAD_ORIGIN, actor, operations);
 
         // Failure checked
         assert_failure(

+ 9 - 9
runtime-modules/content-directory/src/tests/transfer_entity_ownership.rs

@@ -9,7 +9,7 @@ fn transfer_entity_ownership_success() {
         let actor = Actor::Lead;
 
         // Create entity
-        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
+        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor));
 
         // Runtime state before tested call
 
@@ -67,7 +67,7 @@ fn transfer_entity_ownership_lead_auth_failed() {
         let actor = Actor::Lead;
 
         // Create entity
-        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
+        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor));
 
         // Runtime state before tested call
 
@@ -134,7 +134,7 @@ fn transfer_entity_ownership_provided_entity_controller_is_equal_to_the_current_
         let actor = Actor::Lead;
 
         // Create entity
-        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
+        assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor));
 
         // Runtime state before tested call
 
@@ -186,7 +186,7 @@ fn transfer_entity_ownership_inbound_same_owner_rc_does_not_equal_to_zero() {
         // Add schema support to the second Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             SECOND_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -254,7 +254,7 @@ fn transfer_entity_ownership_provided_property_value_ids_must_be_references_with
         // Add schema support to the second Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -337,7 +337,7 @@ fn transfer_entity_ownership_provided_new_property_value_referencing_entity_that
         // Add schema support to the second Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -417,7 +417,7 @@ fn transfer_entity_ownership_provided_new_property_value_referencing_non_existen
         // Add schema support to the second Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -571,7 +571,7 @@ fn transfer_entity_ownership_required_property_was_not_provided() {
         // Add schema support to the second Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -698,7 +698,7 @@ fn transfer_entity_ownership_unique_constraint_violation() {
         // Add second schema support to the first Entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            actor.to_owned(),
+            actor,
             FIRST_ENTITY_ID,
             SECOND_SCHEMA_ID,
             schema_property_values

+ 2 - 2
runtime-modules/content-directory/src/tests/update_class_schema_status.rs

@@ -71,7 +71,7 @@ fn update_class_schema_status_lead_auth_failed() {
             LEAD_ORIGIN,
             FIRST_CLASS_ID,
             BTreeSet::new(),
-            vec![property.clone()]
+            vec![property]
         ));
 
         // Events number before tested call
@@ -125,7 +125,7 @@ fn update_class_schema_status_for_non_existent_schema() {
             LEAD_ORIGIN,
             FIRST_CLASS_ID,
             BTreeSet::new(),
-            vec![property.clone()]
+            vec![property]
         ));
 
         // Events number before tested call

+ 5 - 5
runtime-modules/content-directory/src/tests/update_entity_creation_voucher.rs

@@ -32,7 +32,7 @@ fn create_entity_creation_voucher_success() {
 
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),
-            entity_voucher.clone(),
+            entity_voucher,
         );
 
         let entity_creation_voucher_created_event = get_test_event(
@@ -93,7 +93,7 @@ fn update_entity_creation_voucher_success() {
         entity_creation_voucher.set_maximum_entities_count(new_maximum_entities_count);
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),
-            entity_creation_voucher.clone()
+            entity_creation_voucher
         );
 
         let entity_creation_voucher_created_event = get_test_event(
@@ -125,7 +125,7 @@ fn update_entity_creation_voucher_lead_auth_failed() {
         let update_entity_creation_voucher_result = update_entity_creation_voucher(
             FIRST_MEMBER_ORIGIN,
             FIRST_CLASS_ID,
-            entity_controller.clone(),
+            entity_controller,
             IndividualEntitiesCreationLimit::get(),
         );
 
@@ -152,7 +152,7 @@ fn update_entity_creation_voucher_class_does_not_exist() {
         let update_entity_creation_voucher_result = update_entity_creation_voucher(
             LEAD_ORIGIN,
             UNKNOWN_CLASS_ID,
-            entity_controller.clone(),
+            entity_controller,
             IndividualEntitiesCreationLimit::get(),
         );
 
@@ -183,7 +183,7 @@ fn update_entity_creation_voucher_individual_creation_limit_exceed() {
         let update_entity_creation_voucher_result = update_entity_creation_voucher(
             LEAD_ORIGIN,
             FIRST_CLASS_ID,
-            entity_controller.clone(),
+            entity_controller,
             IndividualEntitiesCreationLimit::get() + 1,
         );
 

+ 4 - 4
runtime-modules/content-directory/src/tests/update_entity_property_values.rs

@@ -41,7 +41,7 @@ fn update_entity_property_values_success() {
 
         // Ensure reference counter of second entity updated succesfully
         let inbound_rc = InboundReferenceCounter::new(2, true);
-        *second_entity.get_reference_counter_mut() = inbound_rc.clone();
+        *second_entity.get_reference_counter_mut() = inbound_rc;
 
         assert_eq!(second_entity, entity_by_id(SECOND_ENTITY_ID));
 
@@ -427,7 +427,7 @@ fn update_entity_property_values_is_locked_for_given_actor() {
         // Add schema support to the entity
         assert_ok!(add_schema_support_to_entity(
             LEAD_ORIGIN,
-            Actor::Lead,
+            actor.clone(),
             FIRST_ENTITY_ID,
             FIRST_SCHEMA_ID,
             schema_property_values
@@ -746,7 +746,7 @@ fn update_entity_property_values_referenced_entity_does_not_match_its_class() {
         schema_new_property_values.insert(FIRST_PROPERTY_ID, schema_new_property_value);
 
         // Make an attempt to update entity property values, when provided schema new property value(s)
-        // refer(s) Entity, which Class does not match the class in corresponding Class Schema
+        // refer(s) Entity, which Class does not match the class in corresponding Class Property
         let update_entity_property_values_result = update_entity_property_values(
             LEAD_ORIGIN,
             actor,
@@ -947,7 +947,7 @@ fn update_entity_property_values_property_should_be_unique() {
         schema_new_property_values.insert(SECOND_PROPERTY_ID, schema_new_property_value);
 
         // Make an attempt to update entity property values, providing property value(s), which are identical to thouse,
-        // are already added to The Entity, though should be unique on Class Schema level
+        // are already added to The Entity, though should be unique on Class Property level
         let update_entity_property_values_result = update_entity_property_values(
             LEAD_ORIGIN,
             actor,