diff --git a/plugins/trace_api_plugin/test/test_data_handlers.cpp b/plugins/trace_api_plugin/test/test_data_handlers.cpp index 34c3282762..464b3a81c1 100644 --- a/plugins/trace_api_plugin/test/test_data_handlers.cpp +++ b/plugins/trace_api_plugin/test/test_data_handlers.cpp @@ -134,53 +134,6 @@ BOOST_AUTO_TEST_SUITE(abi_data_handler_tests) BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element()); } - BOOST_AUTO_TEST_CASE(abi_fail_yield) - { - auto action = action_trace_v1 { - { 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}}, - {0x04, 0x05, 0x06, 0x07} - }; - - std::variant action_trace_t = action; - - auto abi = chain::abi_def ( {}, - { - { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } } - }, - { - { "foo"_n, "foo", ""} - }, - {}, {}, {} - ); - abi.version = "eosio::abi/1."; - - bool except_called = false; - auto except_handler = [&](const exception_with_context& e) { - except_called = true; - BOOST_CHECK(std::get<0>(e).operator bool()); - BOOST_CHECK(std::get<2>(e) > 0); - if (std::get<0>(e)) { // rethrow so caller is notified of error - std::rethrow_exception(std::get<0>(e)); - } - }; - - abi_data_handler handler(except_handler); - handler.add_abi("alice"_n, std::move(abi)); - - fc::variant expected = fc::mutable_variant_object() - ("a", 0) - ("b", 1) - ("c", 2) - ("d", 3); - - uint32_t depth = 0; - BOOST_CHECK_EXCEPTION(handler.serialize_to_variant(action_trace_t, [&](){ ++depth; if (depth > 1) throw std::runtime_error("oops"); }), std::runtime_error, - [](const std::runtime_error& e) { - return std::string(e.what()).find("oops") != std::string::npos; - }); - BOOST_CHECK(except_called); - } - BOOST_AUTO_TEST_CASE(basic_abi_wrong_type) { auto action = action_trace_v0 { diff --git a/plugins/trace_api_plugin/test/test_responses.cpp b/plugins/trace_api_plugin/test/test_responses.cpp index a138f9acf5..42ca936332 100644 --- a/plugins/trace_api_plugin/test/test_responses.cpp +++ b/plugins/trace_api_plugin/test/test_responses.cpp @@ -490,130 +490,6 @@ BOOST_AUTO_TEST_SUITE(trace_responses) BOOST_TEST(null_response.is_null()); } - BOOST_FIXTURE_TEST_CASE(yield_throws, response_test_fixture) - { - auto block_trace = block_trace_v1 { - { - "b000000000000000000000000000000000000000000000000000000000000001"_h, - 1, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - chain::block_timestamp_type(0), - "bp.one"_n - }, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - 0, - { - { - { - "0000000000000000000000000000000000000000000000000000000000000001"_h, - { - { - 0, - "receiver"_n, "contract"_n, "action"_n, - {{ "alice"_n, "active"_n }}, - { 0x00, 0x01, 0x02, 0x03 } - } - } - }, - fc::enum_type{chain::transaction_receipt_header::status_enum::executed}, - 10, - 5, - std::vector{chain::signature_type()}, - {chain::time_point(), 1, 0, 100, 50, 0} - } - } - }; - - mock_get_block = [&block_trace]( uint32_t height, const yield_function& ) -> get_block_t { - BOOST_TEST(height == 1); - return std::make_tuple(data_log_entry(block_trace), false); - }; - - int countdown = 3; - yield_function yield = [&]() { - if (countdown-- == 0) { - throw yield_exception("mock"); - } - }; - - BOOST_REQUIRE_THROW(get_block_trace( 1, yield ), yield_exception); - } - - BOOST_FIXTURE_TEST_CASE(yield_throws_from_get_block, response_test_fixture) - { - // no other yield calls will throw - yield_function yield = [&]() { - }; - - // simulate a yield throw inside get block - mock_get_block = []( uint32_t height, const yield_function& yield) -> get_block_t { - throw yield_exception("mock exception"); - }; - - - BOOST_REQUIRE_THROW(get_block_trace( 1, yield ), yield_exception); - } - - BOOST_FIXTURE_TEST_CASE(yield_throws_from_data_handler, response_test_fixture) - { - auto action_trace = action_trace_v1 { - { - 0, - "receiver"_n, "contract"_n, "action"_n, - {{ "alice"_n, "active"_n }}, - { 0x00, 0x01, 0x02, 0x03 } - }, - { 0x04, 0x05, 0x06, 0x07 } - }; - - auto transaction_trace = transaction_trace_v2 { - "0000000000000000000000000000000000000000000000000000000000000001"_h, - std::vector { - action_trace - }, - fc::enum_type{chain::transaction_receipt_header::status_enum::executed}, - 10, - 5, - std::vector{ chain::signature_type() }, - { chain::time_point(), 1, 0, 100, 50, 0 } - }; - - auto block_trace = block_trace_v2 { - "b000000000000000000000000000000000000000000000000000000000000001"_h, - 1, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - chain::block_timestamp_type(0), - "bp.one"_n, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - "0000000000000000000000000000000000000000000000000000000000000000"_h, - 0, - std::vector { - transaction_trace - } - }; - - mock_get_block = [&block_trace]( uint32_t height, const yield_function& ) -> get_block_t { - BOOST_TEST(height == 1); - return std::make_tuple(data_log_entry(block_trace), false); - }; - - mock_get_block = [&block_trace]( uint32_t height, const yield_function& ) -> get_block_t { - BOOST_TEST(height == 1); - return std::make_tuple(data_log_entry(block_trace), true); - }; - - // simulate data_handler failing - mock_data_handler_v1 = [&](const action_trace_v1&, const yield_function&) -> std::tuple> { - throw std::runtime_error("mock error"); - }; - - // no other yield calls will throw - yield_function yield = [&]() {}; - - BOOST_REQUIRE_THROW(get_block_trace( 1, yield ), std::runtime_error); - } - BOOST_FIXTURE_TEST_CASE(old_version_block_response, response_test_fixture) { auto block_trace = block_trace_v0 { diff --git a/tests/trace_plugin_test.py b/tests/trace_plugin_test.py index 0ab7836e0d..aecca71123 100755 --- a/tests/trace_plugin_test.py +++ b/tests/trace_plugin_test.py @@ -99,15 +99,16 @@ def test_TraceApi(self) : # relaunch with no time allocated for http response & abi-serializer. Will fail because get_info fails. node.kill(signal.SIGTERM) Utils.Print("Ignore expected: ERROR: Node relaunch Failed") - isRelaunchSuccess = node.relaunch(timeout=10, addSwapFlags={"--http-max-response-time-ms": "0", "--abi-serializer-max-time-ms": "10"}) + isRelaunchSuccess = node.relaunch(timeout=10, addSwapFlags={"--http-max-response-time-ms": "0", "--abi-serializer-max-time-ms": "0"}) + # Verify get block_trace still works even with no time for http-max-response-time-ms and no time for bi-serializer-max-time-ms cmdDesc="get block_trace" cmd=" --print-response %s %d" % (cmdDesc, blockNum) cmd="%s %s %s" % (Utils.EosClientPath, node.eosClientArgs(), cmd) result=Utils.runCmdReturnStr(cmd, ignoreError=True) Utils.Print(f"{cmdDesc} returned: {result}") - self.assertIn("Internal Server Error", result) + self.assertIn("test transfer a->b", result) @classmethod def setUpClass(self):