Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0.1] Should never move from a signed_block in a shared_ptr #738

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions unittests/block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( block_with_invalid_tx_test, T, testers )
auto b = main.produce_block();

// Make a copy of the valid block and corrupt the transaction
auto copy_b = std::make_shared<signed_block>(std::move(*b));
auto copy_b = std::make_shared<signed_block>(b->clone());
auto signed_tx = std::get<packed_transaction>(copy_b->transactions.back().trx).get_signed_transaction();
auto& act = signed_tx.actions.back();
auto act_data = act.template data_as<newaccount>();
Expand Down Expand Up @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( block_with_invalid_tx_mroot_test, T, testers )
auto b = main.produce_block();

// Make a copy of the valid block and corrupt the transaction
auto copy_b = std::make_shared<signed_block>(std::move(*b));
auto copy_b = std::make_shared<signed_block>(b->clone());
const auto& packed_trx = std::get<packed_transaction>(copy_b->transactions.back().trx);
auto signed_tx = packed_trx.get_signed_transaction();

Expand Down
4 changes: 2 additions & 2 deletions unittests/forked_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ BOOST_AUTO_TEST_CASE( forking ) try {
}
wlog( "end push c2 blocks to c1" );
wlog( "now push dan's block to c1 but first corrupt it so it is a bad block" );
signed_block bad_block = std::move(*b);
signed_block bad_block{b->clone()};
bad_block.action_mroot = bad_block.previous;
auto bad_id = bad_block.calculate_id();
auto bad_block_btf = c.control->create_block_handle_future( bad_id, std::make_shared<signed_block>(std::move(bad_block)) );
auto bad_block_btf = c.control->create_block_handle_future( bad_id, std::make_shared<signed_block>(bad_block.clone()) );
c.control->abort_block();
controller::block_report br;
BOOST_REQUIRE_EXCEPTION(c.control->push_block( br, bad_block_btf.get(), {}, trx_meta_cache_lookup{} ), fc::exception,
Expand Down
2 changes: 1 addition & 1 deletion unittests/protocol_feature_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ BOOST_AUTO_TEST_CASE( block_validation_after_stage_1_test ) { try {
auto b = tester1.produce_block();

// Make a copy of the block
auto copy_b = std::make_shared<signed_block>(std::move(*b));
auto copy_b = std::make_shared<signed_block>(b->clone());
// Retrieve the last transaction
auto signed_tx = std::get<packed_transaction>(copy_b->transactions.back().trx).get_signed_transaction();
// Make a delayed transaction by forcing delay_sec greater than 0
Expand Down