Skip to content

Commit

Permalink
fix jshooks build error (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
tequdev authored Dec 16, 2024
1 parent 211e63c commit 1bed7f1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
8 changes: 5 additions & 3 deletions src/ripple/app/hook/impl/applyHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5435,7 +5435,7 @@ DEFINE_JS_FUNCTION(
returnJS(INVALID_ARGUMENT);

std::cout << "sto_from_json, valid json\n";
std::cout << to_string(json);
std::cout << json.asString() << "\n";

// turn the json into a stobject
STParsedJSONObject parsed(std::string(jss::tx_json), json);
Expand Down Expand Up @@ -8279,7 +8279,8 @@ DEFINE_JS_FUNCTION(
if (any_missing(f1, f2))
returnJS(INVALID_ARGUMENT);

int64_t const out = float_divide_internal(*f1, *f2);
bool const fixV3 = view.rules().enabled(fixFloatDivide);
int64_t const out = float_divide_internal(*f1, *f2, fixV3);
if (out < 0)
returnJS(out);

Expand Down Expand Up @@ -8334,7 +8335,8 @@ DEFINE_JS_FUNCTION(
if (*f1 == float_one_internal)
returnJSXFL(float_one_internal);

int64_t const out = float_divide_internal(float_one_internal, *f1);
bool const fixV3 = view.rules().enabled(fixFloatDivide);
int64_t const out = float_divide_internal(float_one_internal, *f1, fixV3);
if (out < 0)
returnJS(out);

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/basics/base_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
return (*ret.first > *ret.second) ? std::strong_ordering::greater
: std::strong_ordering::less;
}

#else
template <std::size_t Bits, class Tag>
[[nodiscard]] inline constexpr std::strong_ordering
operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
Expand Down
23 changes: 0 additions & 23 deletions src/test/app/SetHook_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@ namespace test {

using TestHook = std::vector<uint8_t> const&;

class JSSHasher
{
public:
size_t
operator()(const Json::StaticString& n) const
{
return std::hash<std::string_view>{}(n.c_str());
}
};

class JSSEq
{
public:
bool
operator()(const Json::StaticString& a, const Json::StaticString& b) const
{
return a == b;
}
};

using JSSMap =
std::unordered_map<Json::StaticString, Json::Value, JSSHasher, JSSEq>;

// Identical to BEAST_EXPECT except it returns from the function
// if the condition isn't met (and would otherwise therefore cause a crash)
#define BEAST_REQUIRE(x) \
Expand Down
6 changes: 0 additions & 6 deletions src/test/app/SetJSHook_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#include <unordered_map>

// DA TODO: Move duplicated functions to jtx
// JSSMap
// JSSHasher
// JSSEq
// overrideFlag

namespace ripple {
Expand All @@ -40,9 +37,6 @@ namespace test {

using TestHook = std::vector<uint8_t> const&;

using JSSMap =
std::unordered_map<Json::StaticString, Json::Value, JSSHasher, JSSEq>;

// Identical to BEAST_EXPECT except it returns from the function
// if the condition isn't met (and would otherwise therefore cause a crash)
#define BEAST_REQUIRE(x) \
Expand Down
24 changes: 24 additions & 0 deletions src/test/jtx/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define RIPPLE_TEST_JTX_HOOK_H_INCLUDED

#include <ripple/json/json_value.h>
#include <ripple/protocol/jss.h>
#include <optional>
#include <test/jtx/Account.h>

Expand All @@ -47,6 +48,29 @@ hso(std::string const& wasmHex, void (*f)(Json::Value& jv) = 0);
Json::Value
hso_delete(void (*f)(Json::Value& jv) = 0);

class JSSHasher
{
public:
size_t
operator()(const Json::StaticString& n) const
{
return std::hash<std::string_view>{}(n.c_str());
}
};

class JSSEq
{
public:
bool
operator()(const Json::StaticString& a, const Json::StaticString& b) const
{
return a == b;
}
};

using JSSMap =
std::unordered_map<Json::StaticString, Json::Value, JSSHasher, JSSEq>;

} // namespace jtx
} // namespace test
} // namespace ripple
Expand Down

0 comments on commit 1bed7f1

Please sign in to comment.