-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
349 add referral to beneficiaries list when the post is published #389
349 add referral to beneficiaries list when the post is published #389
Conversation
ba3b6c9
to
babffd2
Compare
//reusing a vector | ||
beneficiaries.reserve(benefic_map.size()); | ||
beneficiaries.clear(); | ||
for(auto & ben : benefic_map) | ||
for(auto & ben : benefic_map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove unnecessary changes.
@@ -124,14 +125,34 @@ void publication::create_message(name account, std::string permlink, | |||
} | |||
eosio_assert((benefic_map.size() <= max_beneficiaries_param.max_beneficiaries), "publication::create_message: benafic_map.size() > MAX_BENEFICIARIES"); | |||
|
|||
auto obj_referral = golos::referral::account_referrer( config::referral_name, account ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These actions must be performed if the parameters of the posting contract specify the referral program contract (see #383). I still can’t merge those changes, but you can rebase your PR on them and use the added parameter of the referral program.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use parameter with referral contracts account.
tests/golos.publication_tests.cpp
Outdated
BOOST_CHECK_EQUAL(success(), post.create_msg(N(brucelee), "permlink")); | ||
|
||
auto expire = 8; // sec | ||
BOOST_CHECK_EQUAL(success(), referral.create_referral(N(dan.larimer), N(chucknorris), 500, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am opposed to testing a bunch of posting a contract and a referral program contract in basic posting contract tests.
Please, make this test in referral contract tests (as for social contract, see https://github.com/GolosChain/golos-smart/blob/master/tests/golos.social_tests.cpp#L109-L143).
And remove all changes from base tests.
tests/golos.publication_tests.cpp
Outdated
BOOST_TEST_MESSAGE("--- checking that another user can create a message with the same permlink."); | ||
BOOST_CHECK_EQUAL(success(), post.create_msg(N(chucknorris), "permlink")); | ||
|
||
auto id = hash64("permlink"); | ||
auto post_chucknorris = post.get_message(N(chucknorris), id); | ||
auto size_ben = post_chucknorris["beneficiaries"].size(); | ||
BOOST_CHECK_EQUAL( post_chucknorris["beneficiaries"][size_ben - 1].as<structures::beneficiaries>().account, N(dan.larimer) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is not enough. We need to check that he has the right percentage of reward. Still need to make a check for incorrect input.
@@ -124,14 +125,34 @@ void publication::create_message(name account, std::string permlink, | |||
} | |||
eosio_assert((benefic_map.size() <= max_beneficiaries_param.max_beneficiaries), "publication::create_message: benafic_map.size() > MAX_BENEFICIARIES"); | |||
|
|||
auto obj_referral = golos::referral::account_referrer( config::referral_name, account ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use parameter with referral contracts account.
BOOST_CHECK_EQUAL( post_sania["beneficiaries"][size_ben - 1].as<beneficiary>().account, N(issuer) ); | ||
|
||
BOOST_CHECK_EQUAL(success(), referral.create_referral(N(issuer), N(pasha), 5000, cur_time().to_seconds() + expire, asset(50000, _sym))); | ||
BOOST_CHECK_EQUAL(err.limit_percents, post.create_msg(N(pasha), "permlink", N(), "parentprmlnk", { beneficiary{N(tania), 7000} })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test when referral already exist in beneficiary list?
Test when referral and beneficiary list execute success?
auto id = hash64("permlink"); | ||
auto post_sania = post.get_message(N(sania), id); | ||
auto size_ben = post_sania["beneficiaries"].size(); | ||
BOOST_CHECK_EQUAL( post_sania["beneficiaries"][size_ben - 1].as<beneficiary>().account, N(issuer) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that size_ben
equal 1?
And that percent equal from referral program?
produce_block(); | ||
|
||
install_contract(_code, contracts::posting_wasm(), contracts::posting_abi()); | ||
install_contract(cfg::vesting_name, contracts::vesting_wasm(), contracts::vesting_abi()); | ||
install_contract(cfg::token_name, contracts::token_wasm(), contracts::token_abi()); | ||
install_contract(cfg::referral_name, contracts::referral_wasm(), contracts::referral_abi()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change basic tests. Posting smart-contract must work without referral program!
4f30090
to
ab7b95b
Compare
…en_the_post_is_published # Conflicts: # golos.referral/abi/golos.referral.abi # golos.referral/include/golos.referral/golos.referral.hpp # golos.referral/src/golos.referral.cpp # tests/golos.referral_tests.cpp
No description provided.