From 60653e87b1add52d4658d20d022ad76cce846168 Mon Sep 17 00:00:00 2001 From: Adegbite Ademola Kelvin Date: Thu, 3 Oct 2024 04:40:03 +0100 Subject: [PATCH] chore: fix caller_address in publication test --- src/publication/publication.cairo | 2 +- tests/test_publication.cairo | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/publication/publication.cairo b/src/publication/publication.cairo index 70cac84..dcf7a78 100644 --- a/src/publication/publication.cairo +++ b/src/publication/publication.cairo @@ -619,7 +619,7 @@ pub mod PublicationComponent { collect_nft_address } fn _mint_collect_nft( - ref self: ComponentState, collect_nft: ContractAddress, + ref self: ComponentState, collect_nft: ContractAddress ) -> u256 { let caller: ContractAddress = get_caller_address(); let token_id = ICollectNFTDispatcher { contract_address: collect_nft }.mint_nft(caller); diff --git a/tests/test_publication.cairo b/tests/test_publication.cairo index ed6653d..ed8993f 100644 --- a/tests/test_publication.cairo +++ b/tests/test_publication.cairo @@ -981,7 +981,7 @@ fn test_collect() { ) = __setup__(); let dispatcher = IComposableDispatcher { contract_address: publication_contract_address }; - start_cheat_caller_address(publication_contract_address, USER_TWO.try_into().unwrap()); + start_cheat_caller_address(publication_contract_address, user_two_profile_address); // Case 1: First collection, expecting new deployment let token_id = dispatcher .collect( @@ -995,12 +995,12 @@ fn test_collect() { .get_publication(user_one_profile_address, user_one_first_post_pointed_pub_id) .collect_nft; let collect_dispatcher = ICollectNFTDispatcher { contract_address: collect_nft1 }; - let user2_token_id = collect_dispatcher.get_user_token_id(USER_TWO.try_into().unwrap()); + let user2_token_id = collect_dispatcher.get_user_token_id(user_two_profile_address); assert(token_id == user2_token_id, 'invalid token_id'); stop_cheat_caller_address(publication_contract_address); - start_cheat_caller_address(publication_contract_address, USER_THREE.try_into().unwrap()); + start_cheat_caller_address(publication_contract_address, user_three_profile_address); // Case 2: collect the same publication, expecting reuse of the existing contract let token_id2 = dispatcher .collect( @@ -1014,8 +1014,7 @@ fn test_collect() { .get_publication(user_one_profile_address, user_one_first_post_pointed_pub_id) .collect_nft; let collect_dispatcher = ICollectNFTDispatcher { contract_address: collect_nft2 }; - let user3_token_id = collect_dispatcher.get_user_token_id(USER_THREE.try_into().unwrap()); - + let user3_token_id = collect_dispatcher.get_user_token_id(user_three_profile_address); assert(collect_nft1 == collect_nft2, 'invalid_ address'); assert(token_id2 == user3_token_id, 'invalid token_id'); stop_cheat_caller_address(publication_contract_address);