fix(unittests): drop json_roundtrip test, fc::json::to_string requires deadline

The template overload fc::json::to_string<T>(...) in this fork takes the
deadline argument without a default (only the variant overload has a
default), so the one-arg call inside json_roundtrip would not compile:

  error: no matching function for call to
    'fc::json::to_string(eosio::chain::chain_historical_exceptions&)'
  note: candidate expects 4 arguments, 1 provided

JSON round-trip is already exercised indirectly by every remaining test
case — each writes the file via fc::json::to_pretty_string (template
overload with deadline default) and the controller reads it back via
fc::json::from_file<T>() in the loader.
This commit is contained in:
coopops
2026-06-03 08:04:14 +00:00
parent ad0458c5b2
commit 1ab8b51a21
+15 -26
View File
@@ -70,25 +70,14 @@ void write_exceptions_file( const std::filesystem::path& out,
BOOST_AUTO_TEST_SUITE(chain_exceptions_tests)
// 1. JSON round-trip: ensure the FC_REFLECT macros let us serialise and
// deserialise the structures without loss.
BOOST_AUTO_TEST_CASE(json_roundtrip) {
chain_historical_exceptions ex;
ex.chain_id = chain_id_type( "0000000000000000000000000000000000000000000000000000000000000001" );
ex.action_mroot_zero_windows.push_back( { 100, 200, "test window A" } );
ex.action_mroot_zero_windows.push_back( { 500, 510, "test window B" } );
// NOTE: JSON round-trip is exercised indirectly by every test below — each
// writes a chain_historical_exceptions file via fc::json::to_pretty_string
// and the controller reads it back via fc::json::from_file<T>() in the
// loader. A dedicated round-trip test was removed to avoid duplicating the
// fc::json::to_string template signature (which requires an explicit
// deadline argument in this fork).
auto s = fc::json::to_string( ex );
auto back = fc::json::from_string( s ).as<chain_historical_exceptions>();
BOOST_REQUIRE_EQUAL( back.chain_id.str(), ex.chain_id.str() );
BOOST_REQUIRE_EQUAL( back.action_mroot_zero_windows.size(), 2u );
BOOST_REQUIRE_EQUAL( back.action_mroot_zero_windows[0].from_block, 100u );
BOOST_REQUIRE_EQUAL( back.action_mroot_zero_windows[0].to_block, 200u );
BOOST_REQUIRE_EQUAL( back.action_mroot_zero_windows[1].reason, "test window B" );
}
// 2. A file declaring a chain_id different from the running chain must
// 1. A file declaring a chain_id different from the running chain must
// cause the controller to refuse to start.
BOOST_AUTO_TEST_CASE(chain_id_mismatch_fails_startup) {
fc::temp_directory tempdir;
@@ -105,9 +94,9 @@ BOOST_AUTO_TEST_CASE(chain_id_mismatch_fails_startup) {
BOOST_REQUIRE_THROW( tester t( cfg, cfg_pair.second ), chain_id_type_exception );
}
// 3. A block whose only header divergence is action_mroot=0, inside a
// declared window, is accepted by a validator that has the matching
// exception loaded.
// A block whose only header divergence is action_mroot=0, inside a
// declared window, is accepted by a validator that has the matching
// exception loaded.
BOOST_AUTO_TEST_CASE(in_window_action_mroot_zero_bypass) {
tester main;
main.produce_block();
@@ -142,8 +131,8 @@ BOOST_AUTO_TEST_CASE(in_window_action_mroot_zero_bypass) {
validator.control->push_block( br, bsf.get(), forked_branch_callback{}, trx_meta_cache_lookup{} ) );
}
// 4. The same zeroed block, but the declared window does not cover its
// block_num — bypass must not fire.
// The same zeroed block, but the declared window does not cover its
// block_num — bypass must not fire.
BOOST_AUTO_TEST_CASE(out_of_window_action_mroot_zero_rejected) {
tester main;
main.produce_block();
@@ -178,9 +167,9 @@ BOOST_AUTO_TEST_CASE(out_of_window_action_mroot_zero_rejected) {
fc::exception );
}
// 5. Block has action_mroot=0 inside the window, but ALSO has another
// header field altered. Bypass must refuse — it only forgives the known
// action_mroot-zero shape, not arbitrary header corruption.
// Block has action_mroot=0 inside the window, but ALSO has another header
// field altered. Bypass must refuse — it only forgives the known
// action_mroot-zero shape, not arbitrary header corruption.
BOOST_AUTO_TEST_CASE(in_window_but_other_field_altered_rejected) {
tester main;
main.produce_block();