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

Commit

Permalink
Merge pull request #1310 from GolosChain/1307-worker-proposal-edit-bug
Browse files Browse the repository at this point in the history
Fix worker proposal edit, and test it #1307
  • Loading branch information
afalaleev authored May 29, 2019
2 parents c57afb8 + c339356 commit 9f0cfce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
4 changes: 3 additions & 1 deletion libraries/chain/worker_evaluators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ namespace golos { namespace chain {
const auto* wpo = _db.find_worker_proposal(post.id);

if (wpo) {
GOLOS_CHECK_LOGIC(wpo->state == worker_proposal_state::created,
const auto& wto_idx = _db.get_index<worker_techspec_index, by_worker_proposal>();
auto wto_itr = wto_idx.find(wpo->post);
GOLOS_CHECK_LOGIC(wto_itr == wto_idx.end(),
logic_exception::cannot_edit_worker_proposal_with_techspecs,
"Cannot edit worker proposal with techspecs");

Expand Down
17 changes: 1 addition & 16 deletions tests/tests/worker_proposal_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(worker_proposal_apply_modify) {
BOOST_CHECK(wpo_mod);
BOOST_CHECK(wpo_mod->type == worker_proposal_type::task);

BOOST_TEST_MESSAGE("-- Check cannot modify worker proposal with approved techspec");
BOOST_TEST_MESSAGE("-- Check cannot modify worker proposal with techspec");

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

Expand All @@ -147,21 +147,6 @@ BOOST_AUTO_TEST_CASE(worker_proposal_apply_modify) {
wtop.payments_count = 2;
BOOST_CHECK_NO_THROW(push_tx_with_ops(tx, bob_private_key, wtop));

auto private_key = create_approvers(0, STEEMIT_MAJOR_VOTED_WITNESSES);

generate_blocks(STEEMIT_MAX_WITNESSES); // Enough for approvers to reach TOP-19 and not leave it

for (auto i = 0; i < STEEMIT_MAJOR_VOTED_WITNESSES; ++i) {
const auto name = "approver" + std::to_string(i);
worker_techspec_approve_operation wtaop;
wtaop.approver = name;
wtaop.author = "bob";
wtaop.permlink = "bob-techspec";
wtaop.state = worker_techspec_approve_state::approve;
BOOST_CHECK_NO_THROW(push_tx_with_ops(tx, private_key, wtaop));
generate_block();
}

op.type = worker_proposal_type::task;
GOLOS_CHECK_ERROR_LOGIC(cannot_edit_worker_proposal_with_techspecs, alice_private_key, op);
}
Expand Down

0 comments on commit 9f0cfce

Please sign in to comment.