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 46dd57e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 78 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
59 changes: 37 additions & 22 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 @@ -428,7 +431,8 @@ signed_block database::_generate_block(

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; // 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 @@ -566,7 +573,9 @@ void database::apply_block( const signed_block& next_block, uint32_t skip )
{
auto itr = _checkpoints.find( block_num );
if( itr != _checkpoints.end() )
FC_ASSERT( next_block.id() == itr->second, "Block did not match checkpoint", ("checkpoint",*itr)("block_id",next_block.id()) );
FC_ASSERT( next_block.id() == itr->second,
"Block did not match checkpoint",
("checkpoint",*itr)("block_id",next_block.id()) );

if( _checkpoints.rbegin()->first >= block_num )
skip = ~0;// WE CAN SKIP ALMOST EVERYTHING
Expand Down Expand Up @@ -667,7 +676,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 @@ -732,7 +741,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
fc::time_point_sec now = head_block_time();

FC_ASSERT( trx.expiration <= now + chain_parameters.maximum_time_until_expiration, "",
("trx.expiration",trx.expiration)("now",now)("max_til_exp",chain_parameters.maximum_time_until_expiration));
("trx.expiration",trx.expiration)("now",now)
("max_til_exp",chain_parameters.maximum_time_until_expiration) );
FC_ASSERT( now <= trx.expiration, "", ("now",now)("trx.exp",trx.expiration) );
if ( 0 == (skip & skip_block_size_check ) ) // don't waste time on replay
FC_ASSERT( head_block_time() <= HARDFORK_CORE_1573_TIME
Expand Down Expand Up @@ -768,7 +778,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 +793,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 @@ -812,8 +822,12 @@ operation_result database::try_push_virtual_operation( transaction_evaluation_st

const witness_object& database::validate_block_header( uint32_t skip, const signed_block& next_block )const
{
FC_ASSERT( head_block_id() == next_block.previous, "", ("head_block_id",head_block_id())("next.prev",next_block.previous) );
FC_ASSERT( head_block_time() < next_block.timestamp, "", ("head_block_time",head_block_time())("next",next_block.timestamp)("blocknum",next_block.block_num()) );
FC_ASSERT( head_block_id() == next_block.previous,
"Unlinkable block",
("head_block_id",head_block_id())("next.prev",next_block.previous) );
FC_ASSERT( head_block_time() < next_block.timestamp,
"Invalid block timestamp",
("head_block_time",head_block_time())("next",next_block.timestamp)("blocknum",next_block.block_num()) );
const witness_object& witness = next_block.witness(*this);

if( 0 == (skip&skip_witness_signature) )
Expand Down Expand Up @@ -886,7 +900,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
Loading

0 comments on commit 46dd57e

Please sign in to comment.