Skip to content

Commit

Permalink
Add GCOVR_EXCL_LINE for FC_CAPTURE_AND_RETHROW
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed May 16, 2023
1 parent b26d877 commit 2906a69
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 76 deletions.
28 changes: 14 additions & 14 deletions libraries/chain/credit_offer_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void_result credit_offer_create_evaluator::do_evaluate(const credit_offer_create
"The account is unauthorized by the asset" );

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

object_id_type credit_offer_create_evaluator::do_apply(const credit_offer_create_operation& op) const
{ try {
Expand All @@ -88,7 +88,7 @@ object_id_type credit_offer_create_evaluator::do_apply(const credit_offer_create
obj.acceptable_borrowers = op.acceptable_borrowers;
});
return new_credit_offer_object.id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_offer_delete_evaluator::do_evaluate(const credit_offer_delete_operation& op)
{ try {
Expand All @@ -104,7 +104,7 @@ void_result credit_offer_delete_evaluator::do_evaluate(const credit_offer_delete
// Note: no asset authorization check here, allow funds to be moved to account balance

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

asset credit_offer_delete_evaluator::do_apply(const credit_offer_delete_operation& op) const
{ try {
Expand All @@ -120,7 +120,7 @@ asset credit_offer_delete_evaluator::do_apply(const credit_offer_delete_operatio
d.remove( *_offer );

return released;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_offer_update_evaluator::do_evaluate(const credit_offer_update_operation& op)
{ try {
Expand Down Expand Up @@ -180,7 +180,7 @@ void_result credit_offer_update_evaluator::do_evaluate(const credit_offer_update
}

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_offer_update_evaluator::do_apply( const credit_offer_update_operation& op) const
{ try {
Expand Down Expand Up @@ -224,7 +224,7 @@ void_result credit_offer_update_evaluator::do_apply( const credit_offer_update_o
}

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_offer_accept_evaluator::do_evaluate(const credit_offer_accept_operation& op)
{ try {
Expand Down Expand Up @@ -304,7 +304,7 @@ void_result credit_offer_accept_evaluator::do_evaluate(const credit_offer_accept
}

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

extendable_operation_result credit_offer_accept_evaluator::do_apply( const credit_offer_accept_operation& op) const
{ try {
Expand Down Expand Up @@ -368,7 +368,7 @@ extendable_operation_result credit_offer_accept_evaluator::do_apply( const credi
result.value.impacted_accounts = flat_set<account_id_type>({ _offer->owner_account });

return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_deal_repay_evaluator::do_evaluate(const credit_deal_repay_operation& op)
{ try {
Expand Down Expand Up @@ -400,7 +400,7 @@ void_result credit_deal_repay_evaluator::do_evaluate(const credit_deal_repay_ope
"The owner of the credit offer is unauthorized by the repaying asset" );

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

extendable_operation_result credit_deal_repay_evaluator::do_apply( const credit_deal_repay_operation& op) const
{ try {
Expand Down Expand Up @@ -470,10 +470,10 @@ extendable_operation_result credit_deal_repay_evaluator::do_apply( const credit_
result.value.received = vector<asset>({ collateral_released });

return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_deal_update_evaluator::do_evaluate(const credit_deal_update_operation& op)
{
{ try {
const database& d = db();
const auto block_time = d.head_block_time();

Expand All @@ -486,17 +486,17 @@ void_result credit_deal_update_evaluator::do_evaluate(const credit_deal_update_o
FC_ASSERT( _deal->auto_repay != op.auto_repay, "The automatic repayment type does not change" );

return void_result();
}
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

void_result credit_deal_update_evaluator::do_apply( const credit_deal_update_operation& op) const
{
{ try {
database& d = db();

d.modify( *_deal, [&op]( credit_deal_object& obj ){
obj.auto_repay = op.auto_repay;
});

return void_result();
}
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

} } // graphene::chain
48 changes: 28 additions & 20 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool database::is_known_transaction( const transaction_id_type& id )const
block_id_type database::get_block_id_for_num( uint32_t block_num )const
{ try {
return _block_id_to_block.fetch_block_id( block_num );
} FC_CAPTURE_AND_RETHROW( (block_num) ) }
} FC_CAPTURE_AND_RETHROW( (block_num) ) } // GCOVR_EXCL_LINE

optional<signed_block> database::fetch_block_by_id( const block_id_type& id )const
{
Expand Down Expand Up @@ -92,7 +92,8 @@ const signed_transaction& database::get_recent_transaction(const transaction_id_

std::vector<block_id_type> database::get_block_ids_on_fork(block_id_type head_of_fork) const
{
pair<fork_database::branch_type, fork_database::branch_type> branches = _fork_db.fetch_branch_from(head_block_id(), head_of_fork);
pair<fork_database::branch_type, fork_database::branch_type> branches
= _fork_db.fetch_branch_from(head_block_id(), head_of_fork);
if( !((branches.first.back()->previous_id() == branches.second.back()->previous_id())) )
{
edump( (head_of_fork)
Expand Down Expand Up @@ -180,7 +181,8 @@ bool database::_push_block(const signed_block& new_block)
// remove the rest of branches.first from the fork_db, those blocks are invalid
while( ritr != branches.first.rend() )
{
ilog( "removing block from fork_db #${n} ${id}", ("n",(*ritr)->data.block_num())("id",(*ritr)->id) );
ilog( "removing block from fork_db #${n} ${id}",
("n",(*ritr)->data.block_num())("id",(*ritr)->id) );
_fork_db.remove( (*ritr)->id );
++ritr;
}
Expand Down Expand Up @@ -225,7 +227,7 @@ bool database::_push_block(const signed_block& new_block)
}

return false;
} FC_CAPTURE_AND_RETHROW( (new_block) ) }
} FC_CAPTURE_AND_RETHROW( (new_block) ) } // GCOVR_EXCL_LINE

void database::verify_signing_witness( const signed_block& new_block, const fork_item& fork_entry )const
{
Expand Down Expand Up @@ -275,7 +277,7 @@ processed_transaction database::push_transaction( const precomputable_transactio
result = _push_transaction( trx );
} );
return result;
} FC_CAPTURE_AND_RETHROW( (trx) ) }
} FC_CAPTURE_AND_RETHROW( (trx) ) } // GCOVR_EXCL_LINE

processed_transaction database::_push_transaction( const precomputable_transaction& trx )
{
Expand Down Expand Up @@ -313,7 +315,8 @@ class push_proposal_nesting_guard {
push_proposal_nesting_guard( uint32_t& nesting_counter, const database& db )
: orig_value(nesting_counter), counter(nesting_counter)
{
FC_ASSERT( counter < db.get_global_properties().active_witnesses.size() * 2, "Max proposal nesting depth exceeded!" );
FC_ASSERT( counter < db.get_global_properties().active_witnesses.size() * 2,
"Max proposal nesting depth exceeded!" );
counter++;
}
~push_proposal_nesting_guard()
Expand Down Expand Up @@ -370,7 +373,7 @@ processed_transaction database::push_proposal(const proposal_object& proposal)

ptrx.operation_results = std::move(eval_state.operation_results);
return ptrx;
} FC_CAPTURE_AND_RETHROW( (proposal) ) }
} FC_CAPTURE_AND_RETHROW( (proposal) ) } // GCOVR_EXCL_LINE

signed_block database::generate_block(
fc::time_point_sec when,
Expand All @@ -385,7 +388,7 @@ signed_block database::generate_block(
result = _generate_block( when, witness_id, block_signing_private_key );
} );
return result;
} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

signed_block database::_generate_block(
fc::time_point_sec when,
Expand Down Expand Up @@ -426,9 +429,10 @@ signed_block database::_generate_block(
FC_ASSERT( witness_id(*this).signing_key == block_signing_private_key.get_public_key() );
}

static const size_t max_partial_block_header_size = fc::raw::pack_size( signed_block_header() )
- fc::raw::pack_size( witness_id_type() ) // witness_id
+ 3; // max space to store size of transactions (out of block header),
static const size_t max_partial_block_header_size = ( fc::raw::pack_size( signed_block_header() )
- fc::raw::pack_size( witness_id_type() ) ) // witness_id
+ 3; // max space to store size of transactions
// (out of block header),
// +3 means 3*7=21 bits so it's practically safe
const size_t max_block_header_size = max_partial_block_header_size + fc::raw::pack_size( witness_id );
auto maximum_block_size = get_global_properties().parameters.maximum_block_size;
Expand Down Expand Up @@ -502,10 +506,11 @@ signed_block database::_generate_block(
if( 0 == (skip & skip_witness_signature) )
pending_block.sign( block_signing_private_key );

push_block( pending_block, skip | skip_transaction_signatures ); // skip authority check when pushing self-generated blocks
push_block( pending_block, skip | skip_transaction_signatures ); // skip authority check when pushing
// self-generated blocks

return pending_block;
} FC_CAPTURE_AND_RETHROW( (witness_id) ) }
} FC_CAPTURE_AND_RETHROW( (witness_id) ) } // GCOVR_EXCL_LINE

/**
* Removes the most recent block from the database and
Expand All @@ -524,15 +529,17 @@ void database::pop_block()
FC_ASSERT( fork_db_head, "Trying to pop() block that's not in fork database!?" );
}
pop_undo();
_popped_tx.insert( _popped_tx.begin(), fork_db_head->data.transactions.begin(), fork_db_head->data.transactions.end() );
} FC_CAPTURE_AND_RETHROW() }
_popped_tx.insert( _popped_tx.begin(),
fork_db_head->data.transactions.begin(),
fork_db_head->data.transactions.end() );
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

void database::clear_pending()
{ try {
assert( (_pending_tx.size() == 0) || _pending_tx_session.valid() );
_pending_tx.clear();
_pending_tx_session.reset();
} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

uint32_t database::push_applied_operation( const operation& op, bool is_virtual /* = true */ )
{
Expand Down Expand Up @@ -667,7 +674,7 @@ void database::_apply_block( const signed_block& next_block )
_applied_ops.clear();

notify_changed_objects();
} FC_CAPTURE_AND_RETHROW( (next_block.block_num()) ) }
} FC_CAPTURE_AND_RETHROW( (next_block.block_num()) ) } // GCOVR_EXCL_LINE

/**
* @note if a @c processed_transaction is passed in, it is cast into @c signed_transaction here.
Expand Down Expand Up @@ -768,7 +775,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
"Unpaid SameT Fund debt detected" );

return ptrx;
} FC_CAPTURE_AND_RETHROW( (trx) ) }
} FC_CAPTURE_AND_RETHROW( (trx) ) } // GCOVR_EXCL_LINE

operation_result database::apply_operation( transaction_evaluation_state& eval_state, const operation& op,
bool is_virtual /* = true */ )
Expand All @@ -783,7 +790,7 @@ operation_result database::apply_operation( transaction_evaluation_state& eval_s
auto result = eval->evaluate( eval_state, op, true );
set_applied_operation_result( op_id, result );
return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} FC_CAPTURE_AND_RETHROW( (op) ) } // GCOVR_EXCL_LINE

operation_result database::try_push_virtual_operation( transaction_evaluation_state& eval_state, const operation& op )
{
Expand Down Expand Up @@ -886,7 +893,8 @@ fc::future<void> database::precompute_parallel( const signed_block& block, const
for( size_t base = 0; base < block.transactions.size(); base += chunk_size )
workers.push_back( fc::do_parallel( [this,&block,base,chunk_size,skip] () {
_precompute_parallel( &block.transactions[base],
base + chunk_size < block.transactions.size() ? chunk_size : block.transactions.size() - base,
( ( base + chunk_size ) < block.transactions.size() ) ? chunk_size
: ( block.transactions.size() - base ),
skip );
}) );
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void database::update_active_witnesses()
});
});

} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

void database::update_active_committee_members()
{ try {
Expand Down Expand Up @@ -412,7 +412,7 @@ void database::update_active_committee_members()
std::inserter(gp.active_committee_members, gp.active_committee_members.begin()),
[](const committee_member_object& d) { return d.get_id(); });
});
} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

void database::initialize_budget_record( fc::time_point_sec now, budget_record& rec )const
{
Expand Down Expand Up @@ -564,7 +564,7 @@ void database::process_budget()
// available_funds is money we could spend, but don't want to.
// we simply let it evaporate back into the reserve.
}
FC_CAPTURE_AND_RETHROW()
FC_CAPTURE_AND_RETHROW() // GCOVR_EXCL_LINE
}

template< typename Visitor >
Expand Down
17 changes: 9 additions & 8 deletions libraries/chain/db_market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void database::globally_settle_asset_impl( const asset_object& mia,
obj.settlement_fund = collateral_gathered.amount;
});

} FC_CAPTURE_AND_RETHROW( (mia)(settlement_price) ) }
} FC_CAPTURE_AND_RETHROW( (mia)(settlement_price) ) } // GCOVR_EXCL_LINE

void database::individually_settle( const asset_bitasset_data_object& bitasset, const call_order_object& order )
{
Expand Down Expand Up @@ -448,7 +448,7 @@ void database::revive_bitasset( const asset_object& bitasset, const asset_bitass
FC_ASSERT( bad.settlement_fund == 0 );

_cancel_bids_and_revive_mpa( bitasset, bad );
} FC_CAPTURE_AND_RETHROW( (bitasset) ) }
} FC_CAPTURE_AND_RETHROW( (bitasset) ) } // GCOVR_EXCL_LINE

void database::_cancel_bids_and_revive_mpa( const asset_object& bitasset, const asset_bitasset_data_object& bad )
{ try {
Expand All @@ -472,7 +472,7 @@ void database::_cancel_bids_and_revive_mpa( const asset_object& bitasset, const
obj.settlement_price = price();
obj.settlement_fund = 0;
});
} FC_CAPTURE_AND_RETHROW( (bitasset) ) }
} FC_CAPTURE_AND_RETHROW( (bitasset) ) } // GCOVR_EXCL_LINE

void database::cancel_bid(const collateral_bid_object& bid, bool create_virtual_op)
{
Expand Down Expand Up @@ -1619,7 +1619,8 @@ asset database::match_impl( const force_settlement_object& settle,
cancel_settle_order( settle );

return call_receives;
} FC_CAPTURE_AND_RETHROW( (p_match_price)(max_settlement)(p_fill_price)(is_margin_call)(settle_is_taker) ) }
} FC_CAPTURE_AND_RETHROW( (p_match_price)(max_settlement)(p_fill_price) // GCOVR_EXCL_LINE
(is_margin_call)(settle_is_taker) ) } // GCOVR_EXCL_LINE

bool database::fill_limit_order( const limit_order_object& order, const asset& pays, const asset& receives,
bool cull_if_small, const price& fill_price, const bool is_maker)
Expand Down Expand Up @@ -1725,7 +1726,7 @@ bool database::fill_limit_order( const limit_order_object& order, const asset& p
return maybe_cull_small_order( *this, order );
return false;
}
} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) }
} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) } // GCOVR_EXCL_LINE

/***
* @brief fill a call order in the specified amounts
Expand Down Expand Up @@ -1808,7 +1809,7 @@ bool database::fill_call_order( const call_order_object& order, const asset& pay
remove( order );

return collateral_freed.valid();
} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) }
} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) } // GCOVR_EXCL_LINE

/***
* @brief fullfill a settle order in the specified amounts
Expand Down Expand Up @@ -1881,7 +1882,7 @@ bool database::fill_settle_order( const force_settlement_object& settle, const a

return filled;

} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) }
} FC_CAPTURE_AND_RETHROW( (pays)(receives) ) } // GCOVR_EXCL_LINE

/**
* Starting with the least collateralized orders, fill them if their
Expand Down Expand Up @@ -2254,7 +2255,7 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa
} // while there exists a call order
check_settled_debt_order( bitasset );
return margin_called;
} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() } // GCOVR_EXCL_LINE

bool database::match_force_settlements( const asset_bitasset_data_object& bitasset )
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/db_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,6 @@ void database::notify_changed_objects()
} catch( const graphene::chain::plugin_exception& e ) {
elog( "Caught plugin exception: ${e}", ("e", e.to_detail_string() ) );
throw;
} FC_CAPTURE_AND_LOG( (0) ) }
} FC_CAPTURE_AND_LOG( (0) ) } // GCOVR_EXCL_LINE

} } // namespace graphene::chain
Loading

0 comments on commit 2906a69

Please sign in to comment.