Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Check TOP19 chagning for worker techspec approving #1199
Browse files Browse the repository at this point in the history
  • Loading branch information
maslenitsa93 committed Mar 14, 2019
1 parent 6290227 commit e4c8a97
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/common/worker_fixture.hpp
Expand Up @@ -25,6 +25,18 @@ struct worker_fixture : public clean_database_fixture {
return private_key;
}

void push_approvers_top19(const account_name_type& voter, const private_key_type& voter_key, uint16_t first, uint16_t count, bool up) {
signed_transaction tx;
for (auto i = first; i < count; ++i) {
const auto name = "approver" + std::to_string(i);
account_witness_vote_operation awvop;
awvop.account = voter;
awvop.witness = name;
awvop.approve = up;
BOOST_CHECK_NO_THROW(push_tx_with_ops(tx, voter_key, awvop));
}
}

const worker_proposal_object& worker_proposal(
const string& author, const private_key_type& author_key, const string& permlink, worker_proposal_type type) {
signed_transaction tx;
Expand Down
61 changes: 61 additions & 0 deletions tests/tests/worker_techspec_tests.cpp
Expand Up @@ -360,6 +360,67 @@ BOOST_AUTO_TEST_CASE(worker_techspec_approve_apply_combinations) {
check_approves(0, 0);
}

BOOST_AUTO_TEST_CASE(worker_techspec_approve_top19_updating) {
BOOST_TEST_MESSAGE("Testing: worker_techspec_approve_top19_updating");

ACTORS((alice)(bob)(carol))
auto private_key = create_approvers(0, 19*2);
generate_block();

signed_transaction tx;

comment_create("alice", alice_private_key, "alice-proposal", "", "alice-proposal");
generate_block();

worker_proposal("alice", alice_private_key, "alice-proposal", worker_proposal_type::task);
generate_block();

comment_create("bob", bob_private_key, "bob-techspec", "", "bob-techspec");
generate_block();

worker_techspec_operation wtop;
wtop.author = "bob";
wtop.permlink = "bob-techspec";
wtop.worker_proposal_author = "alice";
wtop.worker_proposal_permlink = "alice-proposal";
wtop.specification_cost = ASSET_GOLOS(6);
wtop.development_cost = ASSET_GOLOS(60);
wtop.payments_interval = 60*60*24;
wtop.payments_count = 2;
BOOST_CHECK_NO_THROW(push_tx_with_ops(tx, bob_private_key, wtop));
generate_block();

generate_blocks(STEEMIT_MAX_WITNESSES);

BOOST_TEST_MESSAGE("-- Disapproving worker techspec by one witness");

worker_techspec_approve_operation op;

op.author = "bob";
op.permlink = "bob-techspec";
op.state = worker_techspec_approve_state::disapprove;
op.approver = "approver0";
BOOST_CHECK_NO_THROW(push_tx_with_ops(tx, private_key, op));
generate_block();

{
const auto& wto_post = db->get_comment("bob", string("bob-techspec"));
BOOST_CHECK(db->count_worker_techspec_approves(wto_post.id)[worker_techspec_approve_state::disapprove] == 1);
}

BOOST_TEST_MESSAGE("-- Upvoting another witnesses to remove approver from top19");

push_approvers_top19("carol", carol_private_key, 0, 19, true);
push_approvers_top19("carol", carol_private_key, 0, 19, false);
push_approvers_top19("carol", carol_private_key, 19, 19*2, true);
generate_blocks(STEEMIT_MAX_WITNESSES);

{
const auto& wto_post = db->get_comment("bob", string("bob-techspec"));
BOOST_CHECK(db->count_worker_techspec_approves(wto_post.id)[worker_techspec_approve_state::approve] == 0);
}
}

BOOST_AUTO_TEST_CASE(worker_techspec_approve_apply_approve) {
BOOST_TEST_MESSAGE("Testing: worker_techspec_approve_apply_approve");

Expand Down

0 comments on commit e4c8a97

Please sign in to comment.