Skip to content
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

Conversation

adedkov
Copy link
Contributor

@adedkov adedkov commented Jan 3, 2019

No description provided.

@adedkov adedkov force-pushed the 349_add_referral_to_beneficiaries_list_when_the_post_is_published branch from ba3b6c9 to babffd2 Compare January 10, 2019 08:25
//reusing a vector
beneficiaries.reserve(benefic_map.size());
beneficiaries.clear();
for(auto & ben : benefic_map)
for(auto & ben : benefic_map) {
Copy link
Contributor

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 );
Copy link
Contributor

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.

Copy link
Contributor

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(success(), post.create_msg(N(brucelee), "permlink"));

auto expire = 8; // sec
BOOST_CHECK_EQUAL(success(), referral.create_referral(N(dan.larimer), N(chucknorris), 500,
Copy link
Contributor

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.

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) );
Copy link
Contributor

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 );
Copy link
Contributor

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} }));
Copy link
Contributor

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) );
Copy link
Contributor

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());
Copy link
Contributor

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!

@adedkov adedkov force-pushed the 349_add_referral_to_beneficiaries_list_when_the_post_is_published branch from 4f30090 to ab7b95b Compare January 11, 2019 12:56
…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
@s-medvedev s-medvedev closed this Jan 30, 2019
@s-medvedev s-medvedev deleted the 349_add_referral_to_beneficiaries_list_when_the_post_is_published branch January 30, 2019 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants