Skip to content

Commit

Permalink
skip test for sanitizer builds
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat committed Jan 4, 2024
1 parent 98c0391 commit 23537c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 5 additions & 5 deletions silkworm/rpc/json/glaze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ struct GlazeJsonErrorRsp {
};
};

void make_glaze_json_error(const nlohmann::json& request_json, const int error_id, const std::string& message, std::string& json_reply) {
void make_glaze_json_error(const nlohmann::json& request, const int error_id, const std::string& message, std::string& reply) {
GlazeJsonErrorRsp glaze_json_error{};

glaze_json_error.id = make_jsonrpc_id(request_json);
glaze_json_error.id = make_jsonrpc_id(request);
glaze_json_error.json_error.code = error_id;
fill_error_message(glaze_json_error.json_error.message, message);

glz::write_json(glaze_json_error, json_reply);
glz::write_json(glaze_json_error, reply);
}

struct GlazeJsonRevert {
Expand Down Expand Up @@ -96,10 +96,10 @@ struct GlazeJsonRevertError {
};
};

void make_glaze_json_error(const nlohmann::json& request_json, const RevertError& error, std::string& reply) {
void make_glaze_json_error(const nlohmann::json& request, const RevertError& error, std::string& reply) {
GlazeJsonRevertError glaze_json_revert{};

glaze_json_revert.id = make_jsonrpc_id(request_json);
glaze_json_revert.id = make_jsonrpc_id(request);
glaze_json_revert.revert_data.code = error.code;
fill_error_message(glaze_json_revert.revert_data.message, error.message);
glaze_json_revert.revert_data.data = "0x" + silkworm::to_hex(error.data);
Expand Down
4 changes: 2 additions & 2 deletions silkworm/rpc/json/glaze.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ inline constexpr auto kInt256HexSize = 2 + 2 * sizeof(intx::uint256) + 1;
inline constexpr auto kDataSize = 16384;
inline constexpr auto kEthCallResultFixedSize = 2048;

void make_glaze_json_error(const nlohmann::json& request_json, int error_id, const std::string& message, std::string& reply);
void make_glaze_json_error(const nlohmann::json& request_json, const RevertError& error, std::string& reply);
void make_glaze_json_error(const nlohmann::json& request, int error_id, const std::string& message, std::string& reply);
void make_glaze_json_error(const nlohmann::json& request, const RevertError& error, std::string& reply);

} // namespace silkworm::rpc
8 changes: 6 additions & 2 deletions silkworm/rpc/json/glaze_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@ TEST_CASE("make glaze json error", "[silkworm][rpc][make_glaze_json_error]") {
CHECK(json == R"({"jsonrpc":"2.0","id":1,"error":{"code":3,"message":"generic_error"}})");
}

// Temporary skip in sanitizer builds due to ASAN error after upgrade to glaze 1.9.9
// https://app.circleci.com/pipelines/github/erigontech/silkworm/10176/workflows/e2c43524-e9c4-4c95-b087-199ded7baf09/jobs/45082
#ifndef SILKWORM_SANITIZE
TEST_CASE("make glaze json revert error", "[silkworm][rpc][make_glaze_json_error]") {
std::string json;
const char* data_hex{"c68341b58302c0"};
Bytes data_bytes{*silkworm::from_hex(data_hex)};
Bytes data_bytes{*from_hex(data_hex)};
make_glaze_json_error(kEmptyRequest, RevertError{{3, "generic_error"}, data_bytes}, json);
CHECK(json == R"({"jsonrpc":"2.0","id":1,"error":{"code":3,"message":"generic_error","data":"0xc68341b58302c0"}})");
}
#endif // SILKWORM_SANITIZE

TEST_CASE("make glaze json revert error too big", "[silkworm][rpc][make_glaze_json_error]") {
std::string json;
const char* data_hex{"c68341b58302c0"};
Bytes data_bytes{*silkworm::from_hex(data_hex)};
Bytes data_bytes{*from_hex(data_hex)};
std::string error_message(1024, '\1');
make_glaze_json_error(kEmptyRequest, RevertError{{3, error_message}, data_bytes}, json);
CHECK(std::strcmp(json.c_str(), R"({"jsonrpc":"2.0","id":1,"error":{"code":3,"message":")"
Expand Down

0 comments on commit 23537c2

Please sign in to comment.