Skip to content

Commit

Permalink
Additional test logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 22, 2024
1 parent 3afccb6 commit 82065e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ void nano::node::process_active (std::shared_ptr<nano::block> const & incoming)

[[nodiscard]] nano::block_status nano::node::process (store::write_transaction const & transaction, std::shared_ptr<nano::block> block)
{
return ledger.process (transaction, block);
auto status = ledger.process (transaction, block);
logger.debug (nano::log::type::node, "Directly processed block: {} (status: {})", block->hash ().to_string (), to_string (status));
return status;
}

nano::block_status nano::node::process (std::shared_ptr<nano::block> block)
Expand Down
11 changes: 11 additions & 0 deletions nano/test_common/testutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,14 @@ void nano::test::print_all_blocks (nano::node & node)
std::cout << b->to_json ();
}
}

std::vector<std::shared_ptr<nano::block>> nano::test::all_blocks (nano::node & node)
{
auto transaction = node.store.tx_begin_read ();
std::vector<std::shared_ptr<nano::block>> result;
for (auto it = node.store.block.begin (transaction), end = node.store.block.end (); it != end; ++it)
{
result.push_back (it->second.block);
}
return result;
}
5 changes: 5 additions & 0 deletions nano/test_common/testutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,10 @@ namespace test
* \brief Debugging function to print all blocks in a node. Intented to be used to debug unit tests.
*/
void print_all_blocks (nano::node & node);

/**
* Returns all blocks in the ledger
*/
std::vector<std::shared_ptr<nano::block>> all_blocks (nano::node &);
}
}

0 comments on commit 82065e8

Please sign in to comment.