From 640c5a732afe900a880de17a02ba2fbedbd9af7f Mon Sep 17 00:00:00 2001 From: Adegbite Ademola Kelvin Date: Thu, 3 Oct 2024 09:49:12 +0100 Subject: [PATCH] chore: remove upvote & downvote from __setup__ --- tests/test_publication.cairo | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/test_publication.cairo b/tests/test_publication.cairo index ed8993f..63ca18b 100644 --- a/tests/test_publication.cairo +++ b/tests/test_publication.cairo @@ -133,16 +133,6 @@ fn __setup__() -> ( ); stop_cheat_caller_address(publication_contract_address); - //@notice: initialise upvote and downvote state to test that users cannot vote twice - // upvote - start_cheat_caller_address(publication_contract_address, USER_TWO.try_into().unwrap()); - dispatcher.upvote(user_one_profile_address, user_one_first_post_pointed_pub_id); - stop_cheat_caller_address(publication_contract_address); - // downvote - start_cheat_caller_address(publication_contract_address, USER_FOUR.try_into().unwrap()); - dispatcher.downvote(user_one_profile_address, user_one_first_post_pointed_pub_id); - stop_cheat_caller_address(publication_contract_address); - return ( nft_contract_address, registry_contract_address, @@ -208,6 +198,10 @@ fn test_upvote() { __setup__(); let dispatcher = IComposableDispatcher { contract_address: publication_contract_address }; + start_cheat_caller_address(publication_contract_address, USER_TWO.try_into().unwrap()); + dispatcher.upvote(user_one_profile_address, user_one_first_post_pointed_pub_id); + stop_cheat_caller_address(publication_contract_address); + let upvote_count = dispatcher .get_upvote_count(user_one_profile_address, user_one_first_post_pointed_pub_id); assert(upvote_count == 1, 'invalid upvote count'); @@ -230,6 +224,9 @@ fn test_downvote() { ) = __setup__(); let dispatcher = IComposableDispatcher { contract_address: publication_contract_address }; + start_cheat_caller_address(publication_contract_address, USER_FOUR.try_into().unwrap()); + dispatcher.downvote(user_one_profile_address, user_one_first_post_pointed_pub_id); + stop_cheat_caller_address(publication_contract_address); let downvote_count = dispatcher .get_downvote_count(user_one_profile_address, user_one_first_post_pointed_pub_id); assert(downvote_count == 1, 'invalid downvote count'); @@ -323,6 +320,7 @@ fn test_upvote_should_fail_if_user_already_upvoted() { start_cheat_caller_address(publication_contract_address, USER_TWO.try_into().unwrap()); dispatcher.upvote(user_one_profile_address, user_one_first_post_pointed_pub_id); + dispatcher.upvote(user_one_profile_address, user_one_first_post_pointed_pub_id); stop_cheat_caller_address(publication_contract_address); } @@ -347,6 +345,7 @@ fn test_downvote_should_fail_if_user_already_downvoted() { start_cheat_caller_address(publication_contract_address, USER_FOUR.try_into().unwrap()); dispatcher.downvote(user_one_profile_address, user_one_first_post_pointed_pub_id); + dispatcher.downvote(user_one_profile_address, user_one_first_post_pointed_pub_id); stop_cheat_caller_address(publication_contract_address); }