Skip to content

Commit

Permalink
test(quote): extend test cases
Browse files Browse the repository at this point in the history
test multiple usesrs quoting a post
test `root_profile_address`
test `pointed_profile_address`
  • Loading branch information
EjembiEmmanuel committed Jun 14, 2024
1 parent 6f5de51 commit 3017b42
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion tests/test_publication.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn test_quote() {
_,
user_one_profile_address,
user_two_profile_address,
_,
user_three_profile_address,
user_one_first_post_pointed_pub_id,
) =
__setup__();
Expand Down Expand Up @@ -301,6 +301,84 @@ fn test_quote() {
stop_prank(
CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]),
);

start_prank(
CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]),
USER_TWO.try_into().unwrap()
);
let user_two_quote_content_URI = "ipfs://QmSkDCsS32eLpcymxtn1cEn7Rc5hfefLBgfvZysdjbezo/";

let user_two_quote_params = QuoteParams {
profile_address: user_three_profile_address,
content_URI: user_two_quote_content_URI,
pointed_profile_address: user_one_profile_address,
pointed_pub_id: user_one_first_post_pointed_pub_id
};
// user 2 publish quote to user 3 profile
let user_two_quote_pub_id = publication_dispatcher
.quote(user_two_quote_params, profile_contract_address);

let publication_type = publication_dispatcher
.get_publication_type(user_three_profile_address, user_two_quote_pub_id);
assert(publication_type == PublicationType::Quote, 'invalid pub_type');

let user_one_publication_root_id = publication_dispatcher
.get_publication(user_two_profile_address, quote_pub_id)
.root_profile_address;
let user_two_publication_root_id = publication_dispatcher
.get_publication(user_three_profile_address, user_two_quote_pub_id)
.root_profile_address;
assert(user_one_publication_root_id == user_two_publication_root_id, 'Invalid root_id');

stop_prank(
CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]),
);
}

#[test]
fn test_quote_pointed_profile_address() {
let (
_,
_,
profile_contract_address,
publication_contract_address,
_,
_,
user_one_profile_address,
user_two_profile_address,
_,
user_one_first_post_pointed_pub_id,
) =
__setup__();
let publication_dispatcher = IKarstPublicationsDispatcher {
contract_address: publication_contract_address
};
start_prank(
CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]),
USER_ONE.try_into().unwrap()
);
let quote_content_URI = "ipfs://QmSkDCsS32eLpcymxtn1cEn7Rc5hfefLBgfvZysddefzp/";

let quote_params = QuoteParams {
profile_address: user_two_profile_address,
content_URI: quote_content_URI,
pointed_profile_address: user_one_profile_address,
pointed_pub_id: user_one_first_post_pointed_pub_id
};

start_prank(CheatTarget::One(publication_contract_address), USER_ONE.try_into().unwrap());
let profileDispatcher = IKarstProfileDispatcher { contract_address: profile_contract_address };

publication_dispatcher.quote(quote_params, profile_contract_address);

let pointed_profile = profileDispatcher.get_profile(user_one_profile_address);

assert(
pointed_profile.profile_address == user_one_profile_address,
'Invalid Pointed Profile Address'
);

stop_prank(CheatTarget::One(publication_contract_address),);
}

#[test]
Expand Down

0 comments on commit 3017b42

Please sign in to comment.