Skip to content

Commit

Permalink
Merge pull request #1239 from bitshares/voting-account-update
Browse files Browse the repository at this point in the history
Check voting_account
  • Loading branch information
abitmore authored Aug 8, 2018
2 parents e259711 + cfea090 commit 2eb6132
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void verify_account_votes( const database& db, const account_options& options )
FC_ASSERT( options.num_committee <= chain_params.maximum_committee_count,
"Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) );

FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." );

uint32_t max_vote_id = gpo.next_available_vote_id;
bool has_worker_votes = false;
for( auto id : options.votes )
Expand Down Expand Up @@ -134,7 +136,6 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
FC_ASSERT( !op.extensions.value.buyback_options.valid() );
}

FC_ASSERT( d.find_object(op.options.voting_account), "Invalid proxy account specified." );
FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." );
FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." );

Expand Down
22 changes: 22 additions & 0 deletions tests/tests/voting_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,26 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_disabled)
} FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE(invalid_voting_account)
{
try
{
ACTORS((alice));

account_id_type invalid_account_id( (uint64_t)999999 );

BOOST_CHECK( !db.find( invalid_account_id ) );

graphene::chain::account_update_operation op;
op.account = alice_id;
op.new_options = alice.options;
op.new_options->voting_account = invalid_account_id;
trx.operations.push_back(op);
sign(trx, alice_private_key);

GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, ~0 ), fc::exception );

} FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 2eb6132

Please sign in to comment.