mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Compare commits
5 Commits
bthomee/re
...
Bronek/max
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba2ac69f55 | ||
|
|
242b11f314 | ||
|
|
6af70476e8 | ||
|
|
4152dc53ba | ||
|
|
eb95da9cd3 |
@@ -84,6 +84,12 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// We do not want feature names to exceed this size.
|
||||
static constexpr std::size_t maxFeatureNameSize = 63;
|
||||
// We not want feature names of this length (and + 1), to enable the use of
|
||||
// 32-long byte string for selection of feature as uint256, in WASM
|
||||
static constexpr std::size_t reservedFeatureNameSize = 32;
|
||||
|
||||
enum class VoteBehavior : int { Obsolete = -1, DefaultNo = 0, DefaultYes };
|
||||
enum class AmendmentSupport : int { Retired = -1, Supported = 0, Unsupported };
|
||||
|
||||
|
||||
@@ -443,10 +443,22 @@ featureToName(uint256 const& f)
|
||||
#pragma push_macro("XRPL_ABANDON")
|
||||
#undef XRPL_ABANDON
|
||||
|
||||
template <std::size_t N>
|
||||
constexpr auto
|
||||
enforceMaxFeatureNameSize(char const (&n)[N]) -> char const*
|
||||
{
|
||||
static_assert(N != reservedFeatureNameSize);
|
||||
static_assert(N != reservedFeatureNameSize + 1);
|
||||
static_assert(N <= maxFeatureNameSize);
|
||||
return n;
|
||||
}
|
||||
|
||||
#define XRPL_FEATURE(name, supported, vote) \
|
||||
uint256 const feature##name = registerFeature(#name, supported, vote);
|
||||
#define XRPL_FIX(name, supported, vote) \
|
||||
uint256 const fix##name = registerFeature("fix" #name, supported, vote);
|
||||
uint256 const feature##name = \
|
||||
registerFeature(enforceMaxFeatureNameSize(#name), supported, vote);
|
||||
#define XRPL_FIX(name, supported, vote) \
|
||||
uint256 const fix##name = registerFeature( \
|
||||
enforceMaxFeatureNameSize("fix" #name), supported, vote);
|
||||
|
||||
// clang-format off
|
||||
#define XRPL_RETIRE(name) \
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <xrpld/app/misc/AmendmentTable.h>
|
||||
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/digest.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -202,16 +203,20 @@ class Feature_test : public beast::unit_test::suite
|
||||
using namespace test::jtx;
|
||||
Env env{*this};
|
||||
|
||||
auto jrr = env.rpc("feature", "MultiSignReserve")[jss::result];
|
||||
std::string const name = "MultiSignReserve";
|
||||
auto jrr = env.rpc("feature", name)[jss::result];
|
||||
BEAST_EXPECTS(jrr[jss::status] == jss::success, "status");
|
||||
jrr.removeMember(jss::status);
|
||||
BEAST_EXPECT(jrr.size() == 1);
|
||||
BEAST_EXPECT(
|
||||
jrr.isMember("586480873651E106F1D6339B0C4A8945BA705A777F3F4524626FF"
|
||||
"1FC07EFE41D"));
|
||||
auto const expected =
|
||||
to_string(sha512Half(Slice(name.data(), name.size())));
|
||||
char const sha[] =
|
||||
"586480873651E106F1D6339B0C4A8945BA705A777F3F4524626FF1FC07EFE41D";
|
||||
BEAST_EXPECT(expected == sha);
|
||||
BEAST_EXPECT(jrr.isMember(expected));
|
||||
auto feature = *(jrr.begin());
|
||||
|
||||
BEAST_EXPECTS(feature[jss::name] == "MultiSignReserve", "name");
|
||||
BEAST_EXPECTS(feature[jss::name] == name, "name");
|
||||
BEAST_EXPECTS(!feature[jss::enabled].asBool(), "enabled");
|
||||
BEAST_EXPECTS(
|
||||
feature[jss::vetoed].isBool() && !feature[jss::vetoed].asBool(),
|
||||
|
||||
Reference in New Issue
Block a user