Merged changes from Bitshares PR 1036
This commit is contained in:
parent
3b36d4686b
commit
b751508404
4 changed files with 51 additions and 20 deletions
|
|
@ -51,7 +51,7 @@ class proposal_object : public abstract_object<proposal_object>
|
|||
flat_set<account_id_type> available_owner_approvals;
|
||||
flat_set<public_key_type> available_key_approvals;
|
||||
account_id_type proposer;
|
||||
|
||||
std::string fail_reason;
|
||||
bool is_authorized_to_execute(database& db)const;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -244,20 +244,6 @@ void_result proposal_update_evaluator::do_evaluate(const proposal_update_operati
|
|||
"", ("id", id)("available", _proposal->available_owner_approvals) );
|
||||
}
|
||||
|
||||
/* All authority checks happen outside of evaluators
|
||||
if( (d.get_node_properties().skip_flags & database::skip_authority_check) == 0 )
|
||||
{
|
||||
for( const auto& id : o.key_approvals_to_add )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) );
|
||||
}
|
||||
for( const auto& id : o.key_approvals_to_remove )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||
|
||||
|
|
@ -293,6 +279,9 @@ void_result proposal_update_evaluator::do_apply(const proposal_update_operation&
|
|||
try {
|
||||
_processed_transaction = d.push_proposal(*_proposal);
|
||||
} catch(fc::exception& e) {
|
||||
d.modify(*_proposal, [&e](proposal_object& p) {
|
||||
p.fail_reason = e.to_string(fc::log_level(fc::log_level::all));
|
||||
});
|
||||
wlog("Proposed transaction ${id} failed to apply once approved with exception:\n----\n${reason}\n----\nWill try again when it expires.",
|
||||
("id", o.proposal)("reason", e.to_detail_string()));
|
||||
_proposal_failed = true;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ bool proposal_object::is_authorized_to_execute(database& db) const
|
|||
}
|
||||
catch ( const fc::exception& e )
|
||||
{
|
||||
//idump((available_active_approvals));
|
||||
//wlog((e.to_detail_string()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -389,6 +389,49 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( proposal_failure )
|
||||
{
|
||||
try
|
||||
{
|
||||
ACTORS( (bob) (alice) );
|
||||
|
||||
fund( bob, asset(1000000) );
|
||||
fund( alice, asset(1000000) );
|
||||
|
||||
// create proposal that will eventually fail due to lack of funds
|
||||
transfer_operation top;
|
||||
top.to = alice_id;
|
||||
top.from = bob_id;
|
||||
top.amount = asset(2000000);
|
||||
proposal_create_operation pop;
|
||||
pop.proposed_ops.push_back( { top } );
|
||||
pop.expiration_time = db.head_block_time() + fc::days(1);
|
||||
pop.fee_paying_account = bob_id;
|
||||
trx.operations.push_back( pop );
|
||||
trx.signatures.clear();
|
||||
sign( trx, bob_private_key );
|
||||
processed_transaction processed = PUSH_TX( db, trx );
|
||||
proposal_object prop = db.get<proposal_object>(processed.operation_results.front().get<object_id_type>());
|
||||
trx.clear();
|
||||
generate_block();
|
||||
// add signature
|
||||
proposal_update_operation up_op;
|
||||
up_op.proposal = prop.id;
|
||||
up_op.fee_paying_account = bob_id;
|
||||
up_op.active_approvals_to_add.emplace( bob_id );
|
||||
trx.operations.push_back( up_op );
|
||||
sign( trx, bob_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
|
||||
// check fail reason
|
||||
const proposal_object& result = db.get<proposal_object>(prop.id);
|
||||
BOOST_CHECK(!result.fail_reason.empty());
|
||||
BOOST_CHECK_EQUAL( result.fail_reason.substr(0, 16), "Assert Exception");
|
||||
}
|
||||
FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
/// Verify that committee authority cannot be invoked in a normal transaction
|
||||
BOOST_AUTO_TEST_CASE( committee_authority )
|
||||
{ try {
|
||||
|
|
@ -478,9 +521,10 @@ BOOST_AUTO_TEST_CASE( committee_authority )
|
|||
// Should throw because the transaction is now in review.
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
|
||||
// generate_blocks(prop.expiration_time);
|
||||
// fails
|
||||
// BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000);
|
||||
generate_blocks(prop.expiration_time);
|
||||
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000);
|
||||
// proposal deleted
|
||||
BOOST_CHECK_THROW( db.get<proposal_object>(prop.id), fc::exception );
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( fired_committee_members, database_fixture )
|
||||
|
|
|
|||
Loading…
Reference in a new issue