Format first-party source according to .clang-format

This commit is contained in:
Pretty Printer
2020-04-17 09:56:34 -05:00
committed by manojsdoshi
parent 65dfc5d19e
commit 50760c6935
1076 changed files with 86161 additions and 77449 deletions

View File

@@ -17,17 +17,17 @@
*/
//==============================================================================
#include <test/jtx.h>
#include <ripple/json/to_string.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/beast/hash/uhash.h>
#include <ripple/beast/unit_test.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/app/misc/TxQ.h>
#include <ripple/beast/hash/uhash.h>
#include <ripple/beast/unit_test.h>
#include <ripple/json/to_string.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/jss.h>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <test/jtx.h>
#include <utility>
namespace ripple {
@@ -37,12 +37,10 @@ class Env_test : public beast::unit_test::suite
{
public:
template <class T>
static
std::string
to_string (T const& t)
static std::string
to_string(T const& t)
{
return boost::lexical_cast<
std::string>(t);
return boost::lexical_cast<std::string>(t);
}
// Declarations in Account.h
@@ -61,12 +59,11 @@ public:
Account("alice", KeyType::secp256k1);
Account("alice", KeyType::ed25519);
auto const gw = Account("gw");
[](AccountID){}(gw);
[](AccountID) {}(gw);
auto const USD = gw["USD"];
void(Account("alice") < gw);
std::set<Account>().emplace(gw);
std::unordered_set<Account,
beast::uhash<>>().emplace("alice");
std::unordered_set<Account, beast::uhash<>>().emplace("alice");
}
// Declarations in amount.h
@@ -80,21 +77,25 @@ public:
PrettyAmount(0u);
PrettyAmount(1u);
PrettyAmount(-1);
static_assert(! std::is_trivially_constructible<
PrettyAmount, char>::value, "");
static_assert(! std::is_trivially_constructible<
PrettyAmount, unsigned char>::value, "");
static_assert(! std::is_trivially_constructible<
PrettyAmount, short>::value, "");
static_assert(! std::is_trivially_constructible<
PrettyAmount, unsigned short>::value, "");
static_assert(
!std::is_trivially_constructible<PrettyAmount, char>::value, "");
static_assert(
!std::is_trivially_constructible<PrettyAmount, unsigned char>::
value,
"");
static_assert(
!std::is_trivially_constructible<PrettyAmount, short>::value, "");
static_assert(
!std::is_trivially_constructible<PrettyAmount, unsigned short>::
value,
"");
try
{
XRP(0.0000001);
fail("missing exception");
}
catch(std::domain_error const&)
catch (std::domain_error const&)
{
pass();
}
@@ -104,7 +105,7 @@ public:
XRP(-0.0000009);
fail("missing exception");
}
catch(std::domain_error const&)
catch (std::domain_error const&)
{
pass();
}
@@ -136,8 +137,8 @@ public:
BEAST_EXPECT(USD(1) == STAmount(USD, 1));
BEAST_EXPECT(USD(-1) == STAmount(USD, -1));
auto const get = [](AnyAmount a){ return a; };
BEAST_EXPECT(! get(USD(10)).is_any);
auto const get = [](AnyAmount a) { return a; };
BEAST_EXPECT(!get(USD(10)).is_any);
BEAST_EXPECT(get(any(USD(10))).is_any);
}
@@ -154,7 +155,11 @@ public:
// unfunded
{
Env env(*this);
env(pay("alice", "bob", XRP(1000)), seq(1), fee(10), sig("alice"), ter(terNO_ACCOUNT));
env(pay("alice", "bob", XRP(1000)),
seq(1),
fee(10),
sig("alice"),
ter(terNO_ACCOUNT));
}
// fund
@@ -196,7 +201,8 @@ public:
env.trust(USD(1000), alice);
env(pay(gw, alice, USD(10)));
BEAST_EXPECT(to_string(env.balance("alice", USD)) == "10/USD(gw)");
BEAST_EXPECT(to_string(env.balance(gw, alice["USD"])) == "-10/USD(alice)");
BEAST_EXPECT(
to_string(env.balance(gw, alice["USD"])) == "-10/USD(alice)");
}
// seq
@@ -212,11 +218,11 @@ public:
Env env(*this);
env.fund(n, "alice");
env.require(balance("alice", n));
env(noop("alice"), fee(1), ter(telINSUF_FEE_P));
env(noop("alice"), seq(none), ter(temMALFORMED));
env(noop("alice"), seq(none), fee(10), ter(temMALFORMED));
env(noop("alice"), fee(none), ter(temMALFORMED));
env(noop("alice"), sig(none), ter(temMALFORMED));
env(noop("alice"), fee(1), ter(telINSUF_FEE_P));
env(noop("alice"), seq(none), ter(temMALFORMED));
env(noop("alice"), seq(none), fee(10), ter(temMALFORMED));
env(noop("alice"), fee(none), ter(temMALFORMED));
env(noop("alice"), sig(none), ter(temMALFORMED));
env(noop("alice"), fee(autofill));
env(noop("alice"), fee(autofill), seq(autofill));
env(noop("alice"), fee(autofill), seq(autofill), sig(autofill));
@@ -236,13 +242,15 @@ public:
env.fund(XRP(10000), "alice", gw);
env.require(balance("alice", USD(none)));
env.trust(USD(100), "alice");
env.require(balance("alice", XRP(10000))); // fee refunded
env.require(balance("alice", XRP(10000))); // fee refunded
env.require(balance("alice", USD(0)));
env(pay(gw, "alice", USD(10)), require(balance("alice", USD(10))));
env.require(nflags("alice", asfRequireDest));
env(fset("alice", asfRequireDest), require(flags("alice", asfRequireDest)));
env(fclear("alice", asfRequireDest), require(nflags("alice", asfRequireDest)));
env(fset("alice", asfRequireDest),
require(flags("alice", asfRequireDest)));
env(fclear("alice", asfRequireDest),
require(nflags("alice", asfRequireDest)));
}
// Signing with secp256k1 and ed25519 keys
@@ -260,12 +268,12 @@ public:
// Master key only
env(noop(alice));
env(noop(bob));
env(noop(alice), sig("alice"), ter(tefBAD_AUTH));
env(noop(alice), sig(Account("alice",
KeyType::secp256k1)), ter(tefBAD_AUTH));
env(noop(bob), sig(Account("bob",
KeyType::ed25519)), ter(tefBAD_AUTH));
env(noop(alice), sig(carol), ter(tefBAD_AUTH));
env(noop(alice), sig("alice"), ter(tefBAD_AUTH));
env(noop(alice),
sig(Account("alice", KeyType::secp256k1)),
ter(tefBAD_AUTH));
env(noop(bob), sig(Account("bob", KeyType::ed25519)), ter(tefBAD_AUTH));
env(noop(alice), sig(carol), ter(tefBAD_AUTH));
// Master and Regular key
env(regkey(alice, bob));
@@ -277,8 +285,10 @@ public:
env(fset(alice, asfDisableMaster), sig(alice));
env(noop(alice));
env(noop(alice), sig(bob));
env(noop(alice), sig(alice), ter(tefMASTER_DISABLED));
env(fclear(alice, asfDisableMaster), sig(alice), ter(tefMASTER_DISABLED));
env(noop(alice), sig(alice), ter(tefMASTER_DISABLED));
env(fclear(alice, asfDisableMaster),
sig(alice),
ter(tefMASTER_DISABLED));
env(fclear(alice, asfDisableMaster), sig(bob));
env(noop(alice), sig(alice));
}
@@ -298,12 +308,12 @@ public:
env.require(balance("carol", XRP(10000)));
env.require(balance(gw, XRP(10000)));
env(pay(env.master, "alice", XRP(1000)), fee(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), fee(1), ter(telINSUF_FEE_P));
env(pay(env.master, "alice", XRP(1000)), seq(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), seq(20), ter(terPRE_SEQ));
env(pay(env.master, "alice", XRP(1000)), sig(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), sig("bob"), ter(tefBAD_AUTH));
env(pay(env.master, "alice", XRP(1000)), fee(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), fee(1), ter(telINSUF_FEE_P));
env(pay(env.master, "alice", XRP(1000)), seq(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), seq(20), ter(terPRE_SEQ));
env(pay(env.master, "alice", XRP(1000)), sig(none), ter(temMALFORMED));
env(pay(env.master, "alice", XRP(1000)), sig("bob"), ter(tefBAD_AUTH));
env(pay(env.master, "dilbert", XRP(1000)), sig(env.master));
@@ -316,11 +326,12 @@ public:
env.require(balance(gw, Account("carol")["USD"](-50)));
env(offer("carol", XRP(50), USD(50)), require(owners("carol", 2)));
env(pay("alice", "bob", any(USD(10))), ter(tecPATH_DRY));
env(pay("alice", "bob", any(USD(10))), ter(tecPATH_DRY));
env(pay("alice", "bob", any(USD(10))),
paths(XRP), sendmax(XRP(10)), ter(tecPATH_PARTIAL));
env(pay("alice", "bob", any(USD(10))), paths(XRP),
sendmax(XRP(20)));
paths(XRP),
sendmax(XRP(10)),
ter(tecPATH_PARTIAL));
env(pay("alice", "bob", any(USD(10))), paths(XRP), sendmax(XRP(20)));
env.require(balance("bob", USD(10)));
env.require(balance("carol", USD(39.5)));
@@ -329,23 +340,27 @@ public:
env(noop("alice"));
env(noop("alice"), sig("alice"));
env(noop("alice"), sig("eric"));
env(noop("alice"), sig("bob"), ter(tefBAD_AUTH));
env(fset("alice", asfDisableMaster), ter(tecNEED_MASTER_KEY));
env(fset("alice", asfDisableMaster), sig("eric"), ter(tecNEED_MASTER_KEY));
env(noop("alice"), sig("bob"), ter(tefBAD_AUTH));
env(fset("alice", asfDisableMaster), ter(tecNEED_MASTER_KEY));
env(fset("alice", asfDisableMaster),
sig("eric"),
ter(tecNEED_MASTER_KEY));
env.require(nflags("alice", asfDisableMaster));
env(fset("alice", asfDisableMaster), sig("alice"));
env.require(flags("alice", asfDisableMaster));
env(regkey("alice", disabled), ter(tecNO_ALTERNATIVE_KEY));
env(regkey("alice", disabled), ter(tecNO_ALTERNATIVE_KEY));
env(noop("alice"));
env(noop("alice"), sig("alice"), ter(tefMASTER_DISABLED));
env(noop("alice"), sig("alice"), ter(tefMASTER_DISABLED));
env(noop("alice"), sig("eric"));
env(noop("alice"), sig("bob"), ter(tefBAD_AUTH));
env(fclear("alice", asfDisableMaster), sig("bob"), ter(tefBAD_AUTH));
env(fclear("alice", asfDisableMaster), sig("alice"), ter(tefMASTER_DISABLED));
env(noop("alice"), sig("bob"), ter(tefBAD_AUTH));
env(fclear("alice", asfDisableMaster), sig("bob"), ter(tefBAD_AUTH));
env(fclear("alice", asfDisableMaster),
sig("alice"),
ter(tefMASTER_DISABLED));
env(fclear("alice", asfDisableMaster));
env.require(nflags("alice", asfDisableMaster));
env(regkey("alice", disabled));
env(noop("alice"), sig("eric"), ter(tefBAD_AUTH));
env(noop("alice"), sig("eric"), ter(tefBAD_AUTH));
env(noop("alice"));
}
@@ -360,67 +375,78 @@ public:
auto const gw = Account("gateway");
auto const USD = gw["USD"];
auto const alice = Account {"alice"};
env.fund (XRP(10000), alice);
auto const alice = Account{"alice"};
env.fund(XRP(10000), alice);
auto const localTxCnt = env.app().getOPs().getLocalTxCount();
auto const queueTxCount = env.app().getTxQ().getMetrics(*env.current()).txCount;
auto const queueTxCount =
env.app().getTxQ().getMetrics(*env.current()).txCount;
auto const openTxCount = env.current()->txCount();
BEAST_EXPECT(localTxCnt == 2 && queueTxCount == 0 && openTxCount == 2);
auto applyTxn = [&env](auto&& ...txnArgs)
{
auto jt = env.jt (txnArgs...);
auto applyTxn = [&env](auto&&... txnArgs) {
auto jt = env.jt(txnArgs...);
Serializer s;
jt.stx->add (s);
jt.stx->add(s);
Json::Value args {Json::objectValue};
Json::Value args{Json::objectValue};
args[jss::tx_blob] = strHex (s.slice ());
args[jss::tx_blob] = strHex(s.slice());
args[jss::fail_hard] = true;
return env.rpc ("json", "submit", args.toStyledString());
return env.rpc("json", "submit", args.toStyledString());
};
auto jr = applyTxn(noop (alice), fee (1));
auto jr = applyTxn(noop(alice), fee(1));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "telINSUF_FEE_P");
BEAST_EXPECT(env.app().getTxQ().getMetrics(*env.current()).txCount == queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt);
BEAST_EXPECT(
env.app().getTxQ().getMetrics(*env.current()).txCount ==
queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt);
BEAST_EXPECT(env.current()->txCount() == openTxCount);
jr = applyTxn(noop (alice), sig("bob"));
jr = applyTxn(noop(alice), sig("bob"));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "tefBAD_AUTH");
BEAST_EXPECT(env.app().getTxQ().getMetrics(*env.current()).txCount == queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt);
BEAST_EXPECT(
env.app().getTxQ().getMetrics(*env.current()).txCount ==
queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt);
BEAST_EXPECT(env.current()->txCount() == openTxCount);
jr = applyTxn(noop (alice), seq(20));
jr = applyTxn(noop(alice), seq(20));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "terPRE_SEQ");
BEAST_EXPECT(env.app().getTxQ().getMetrics(*env.current()).txCount == queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt);
BEAST_EXPECT(
env.app().getTxQ().getMetrics(*env.current()).txCount ==
queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt);
BEAST_EXPECT(env.current()->txCount() == openTxCount);
jr = applyTxn(offer(alice, XRP(1000), USD(1000)));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "tecUNFUNDED_OFFER");
BEAST_EXPECT(env.app().getTxQ().getMetrics(*env.current()).txCount == queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt);
BEAST_EXPECT(
jr[jss::result][jss::engine_result] == "tecUNFUNDED_OFFER");
BEAST_EXPECT(
env.app().getTxQ().getMetrics(*env.current()).txCount ==
queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt);
BEAST_EXPECT(env.current()->txCount() == openTxCount);
jr = applyTxn(noop (alice), fee (drops (-10)));
jr = applyTxn(noop(alice), fee(drops(-10)));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "temBAD_FEE");
BEAST_EXPECT(env.app().getTxQ().getMetrics(*env.current()).txCount == queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt);
BEAST_EXPECT(
env.app().getTxQ().getMetrics(*env.current()).txCount ==
queueTxCount);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt);
BEAST_EXPECT(env.current()->txCount() == openTxCount);
jr = applyTxn(noop (alice));
jr = applyTxn(noop(alice));
BEAST_EXPECT(jr[jss::result][jss::engine_result] == "tesSUCCESS");
BEAST_EXPECT(env.app().getOPs().getLocalTxCount () == localTxCnt + 1);
BEAST_EXPECT(env.app().getOPs().getLocalTxCount() == localTxCnt + 1);
BEAST_EXPECT(env.current()->txCount() == openTxCount + 1);
}
@@ -432,18 +458,19 @@ public:
Env env(*this);
env.fund(XRP(10000), "alice");
env(signers("alice", 1,
{ { "alice", 1 }, { "bob", 2 } }), ter(temBAD_SIGNER));
env(signers("alice", 1,
{ { "bob", 1 }, { "carol", 2 } }));
env(signers("alice", 1, {{"alice", 1}, {"bob", 2}}),
ter(temBAD_SIGNER));
env(signers("alice", 1, {{"bob", 1}, {"carol", 2}}));
env(noop("alice"));
auto const baseFee = env.current()->fees().base;
env(noop("alice"), msig("bob"), fee(2 * baseFee));
env(noop("alice"), msig("carol"), fee(2 * baseFee));
env(noop("alice"), msig("bob", "carol"), fee(3 * baseFee));
env(noop("alice"), msig("bob", "carol", "dilbert"),
fee(4 * baseFee), ter(tefBAD_SIGNATURE));
env(noop("alice"),
msig("bob", "carol", "dilbert"),
fee(4 * baseFee),
ter(tefBAD_SIGNATURE));
env(signers("alice", none));
}
@@ -461,9 +488,12 @@ public:
{
Env env(*this, supported_amendments().set(featureTickets));
env.fund(XRP(10000), "alice");
env(noop("alice"), require(owners("alice", 0), tickets("alice", 0)));
env(ticket::create("alice"), require(owners("alice", 1), tickets("alice", 1)));
env(ticket::create("alice"), require(owners("alice", 2), tickets("alice", 2)));
env(noop("alice"),
require(owners("alice", 0), tickets("alice", 0)));
env(ticket::create("alice"),
require(owners("alice", 1), tickets("alice", 1)));
env(ticket::create("alice"),
require(owners("alice", 2), tickets("alice", 2)));
}
}
@@ -471,9 +501,12 @@ public:
{
};
void testJTxProperties()
void
testJTxProperties()
{
struct T { };
struct T
{
};
using namespace jtx;
JTx jt1;
// Test a straightforward
@@ -505,32 +538,33 @@ public:
BEAST_EXPECT(!jt2.get<UDT>());
}
void testProp()
void
testProp()
{
using namespace jtx;
Env env(*this);
env.fund(XRP(100000), "alice");
auto jt1 = env.jt(noop("alice"));
BEAST_EXPECT(!jt1.get<std::uint16_t>());
auto jt2 = env.jt(noop("alice"),
prop<std::uint16_t>(-1));
auto jt2 = env.jt(noop("alice"), prop<std::uint16_t>(-1));
BEAST_EXPECT(jt2.get<std::uint16_t>());
BEAST_EXPECT(*jt2.get<std::uint16_t>() ==
65535);
auto jt3 = env.jt(noop("alice"),
prop<std::string>(
"Hello, world!"),
prop<bool>(false));
BEAST_EXPECT(*jt2.get<std::uint16_t>() == 65535);
auto jt3 = env.jt(
noop("alice"),
prop<std::string>("Hello, world!"),
prop<bool>(false));
BEAST_EXPECT(jt3.get<std::string>());
BEAST_EXPECT(*jt3.get<std::string>() ==
"Hello, world!");
BEAST_EXPECT(*jt3.get<std::string>() == "Hello, world!");
BEAST_EXPECT(jt3.get<bool>());
BEAST_EXPECT(!*jt3.get<bool>());
}
void testJTxCopy()
void
testJTxCopy()
{
struct T { };
struct T
{
};
using namespace jtx;
JTx jt1;
jt1.set<int>(7);
@@ -548,9 +582,12 @@ public:
BEAST_EXPECT(!jt3.get<UDT>());
}
void testJTxMove()
void
testJTxMove()
{
struct T { };
struct T
{
};
using namespace jtx;
JTx jt1;
jt1.set<int>(7);
@@ -584,7 +621,9 @@ public:
env(noop("alice"), memonformat("data", "type"));
env(noop("alice"), memontype("data", "format"));
env(noop("alice"), memo("data", "format", "type"));
env(noop("alice"), memo("data1", "format1", "type1"), memo("data2", "format2", "type2"));
env(noop("alice"),
memo("data1", "format1", "type1"),
memo("data2", "format2", "type2"));
}
void
@@ -596,9 +635,12 @@ public:
memo("data", "format", "type")(env, jt);
auto const& memo = jt.jv["Memos"][0u]["Memo"];
BEAST_EXPECT(memo["MemoData"].asString() == strHex(std::string("data")));
BEAST_EXPECT(memo["MemoFormat"].asString() == strHex(std::string("format")));
BEAST_EXPECT(memo["MemoType"].asString() == strHex(std::string("type")));
BEAST_EXPECT(
memo["MemoData"].asString() == strHex(std::string("data")));
BEAST_EXPECT(
memo["MemoFormat"].asString() == strHex(std::string("format")));
BEAST_EXPECT(
memo["MemoType"].asString() == strHex(std::string("type")));
}
void
@@ -642,34 +684,35 @@ public:
env.fund(XRP(10000), "alice", "bob");
env.json(
pay("alice", "bob", USD(10)),
path(Account("alice")),
path("bob"),
path(USD),
path(~XRP),
path(~USD),
path("bob", USD, ~XRP, ~USD)
);
path(Account("alice")),
path("bob"),
path(USD),
path(~XRP),
path(~USD),
path("bob", USD, ~XRP, ~USD));
}
// Test that jtx can re-sign a transaction that's already been signed.
void testResignSigned()
void
testResignSigned()
{
using namespace jtx;
Env env(*this);
env.fund(XRP(10000), "alice");
auto const baseFee = env.current()->fees().base;
std::uint32_t const aliceSeq = env.seq ("alice");
std::uint32_t const aliceSeq = env.seq("alice");
// Sign jsonNoop.
Json::Value jsonNoop = env.json (
noop ("alice"), fee(baseFee), seq(aliceSeq), sig("alice"));
Json::Value jsonNoop =
env.json(noop("alice"), fee(baseFee), seq(aliceSeq), sig("alice"));
// Re-sign jsonNoop.
JTx jt = env.jt (jsonNoop);
env (jt);
JTx jt = env.jt(jsonNoop);
env(jt);
}
void testSignAndSubmit()
void
testSignAndSubmit()
{
using namespace jtx;
Env env(*this);
@@ -709,15 +752,15 @@ public:
params[jss::fee_mult_max] = 1;
params[jss::fee_div_max] = 2;
// RPC errors result in temINVALID
envs(noop(alice), fee(none),
seq(none), ter(temINVALID))(params);
envs(noop(alice), fee(none), seq(none), ter(temINVALID))(params);
auto tx = env.tx();
BEAST_EXPECT(!tx);
}
}
void testFeatures()
void
testFeatures()
{
testcase("Env features");
using namespace jtx;
@@ -727,10 +770,9 @@ public:
// the supported amendments list and tests that it can be
// enabled explicitly
auto const neverSupportedFeat = [&]() -> boost::optional<uint256>
{
auto const neverSupportedFeat = [&]() -> boost::optional<uint256> {
auto const n = supported.size();
for(size_t i = 0; i < n; ++i)
for (size_t i = 0; i < n; ++i)
if (!supported[i])
return bitsetIndexToFeature(i);
@@ -739,15 +781,16 @@ public:
if (!neverSupportedFeat)
{
log << "No unsupported features found - skipping test." << std::endl;
log << "No unsupported features found - skipping test."
<< std::endl;
pass();
return;
}
auto hasFeature = [](Env& env, uint256 const& f)
{
return (env.app().config().features.find (f) !=
env.app().config().features.end());
auto hasFeature = [](Env& env, uint256 const& f) {
return (
env.app().config().features.find(f) !=
env.app().config().features.end());
};
{
@@ -765,7 +808,8 @@ public:
Env env{*this, FeatureBitset(featureMultiSignReserve, featureFlow)};
BEAST_EXPECT(env.app().config().features.size() == 2);
foreachFeature(supported, [&](uint256 const& f) {
bool const has = (f == featureMultiSignReserve || f == featureFlow);
bool const has =
(f == featureMultiSignReserve || f == featureFlow);
this->BEAST_EXPECT(has == hasFeature(env, f));
});
}
@@ -778,7 +822,8 @@ public:
BEAST_EXPECT(
env.app().config().features.size() == (supported.count() - 2));
foreachFeature(supported, [&](uint256 const& f) {
bool hasnot = (f == featureMultiSignReserve || f == featureFlow);
bool hasnot =
(f == featureMultiSignReserve || f == featureFlow);
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
});
}
@@ -808,8 +853,9 @@ public:
// add a feature that is NOT in the supported amendments list
// and omit a few standard amendments
// the unsupported features should be enabled
Env env{*this,
missingSomeFeatures | FeatureBitset{*neverSupportedFeat}};
Env env{
*this,
missingSomeFeatures | FeatureBitset{*neverSupportedFeat}};
// this app will have all supported amendments minus 2 and then the
// one additional never supported feature flag
@@ -818,7 +864,8 @@ public:
(supported.count() - 2 + 1));
BEAST_EXPECT(hasFeature(env, *neverSupportedFeat));
foreachFeature(supported, [&](uint256 const& f) {
bool hasnot = (f == featureMultiSignReserve || f == featureFlow);
bool hasnot =
(f == featureMultiSignReserve || f == featureFlow);
this->BEAST_EXPECT(hasnot != hasFeature(env, f));
});
}
@@ -840,19 +887,15 @@ public:
}
}
void testExceptionalShutdown()
void
testExceptionalShutdown()
{
except(
[this]
{
jtx::Env env {*this,
jtx::envconfig([](std::unique_ptr<Config> cfg)
{
(*cfg).deprecatedClearSection("port_rpc");
return cfg;
})};
}
);
except([this] {
jtx::Env env{*this, jtx::envconfig([](std::unique_ptr<Config> cfg) {
(*cfg).deprecatedClearSection("port_rpc");
return cfg;
})};
});
pass();
}
@@ -884,7 +927,7 @@ public:
}
};
BEAST_DEFINE_TESTSUITE(Env,app,ripple);
BEAST_DEFINE_TESTSUITE(Env, app, ripple);
} // test
} // ripple
} // namespace test
} // namespace ripple