mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-01 11:32:10 +00:00
Compare commits
4 Commits
ximinez/nu
...
ximinez/pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3ad106797 | ||
|
|
f6ab0b16bb | ||
|
|
a8ead867ba | ||
|
|
84589262c1 |
@@ -463,7 +463,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
auto const batchFee = batch::calcBatchFee(env, 0, 2);
|
||||
auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), seq + 1);
|
||||
tx1[jss::Fee] = "1.5";
|
||||
env.setParseFailureExpected(true);
|
||||
auto const g = env.getParseFailureGuard(true);
|
||||
try
|
||||
{
|
||||
env(batch::outer(alice, seq, batchFee, tfAllOrNothing),
|
||||
@@ -475,7 +475,6 @@ class Batch_test : public beast::unit_test::Suite
|
||||
{
|
||||
BEAST_EXPECT(true);
|
||||
}
|
||||
env.setParseFailureExpected(false);
|
||||
}
|
||||
|
||||
// temSEQ_AND_TICKET: Batch: inner txn cannot have both Sequence
|
||||
|
||||
@@ -5458,9 +5458,9 @@ class Vault_test : public beast::unit_test::Suite
|
||||
env.close();
|
||||
|
||||
// 2. Mantissa larger than uint64 max
|
||||
env.setParseFailureExpected(true);
|
||||
try
|
||||
{
|
||||
auto const g = env.getParseFailureGuard(true);
|
||||
tx[sfAssetsMaximum] = "18446744073709551617e5"; // uint64 max + 1
|
||||
env(tx);
|
||||
BEAST_EXPECTS(false, "Expected parse_error for mantissa larger than uint64 max");
|
||||
@@ -5471,7 +5471,6 @@ class Vault_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(
|
||||
e.what() == "invalidParamsField 'tx_json.AssetsMaximum' has invalid data."s);
|
||||
}
|
||||
env.setParseFailureExpected(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -482,6 +482,46 @@ public:
|
||||
parseFailureExpected_ = b;
|
||||
}
|
||||
|
||||
/** RAII class to set and restore the parse failure flag (setParseFailureExpected).
|
||||
*
|
||||
* Can be created directly, or through the `getParseFailureGuard(bool)` function.
|
||||
*/
|
||||
class ParseFailureGuard final
|
||||
{
|
||||
Env& self_;
|
||||
bool oldExpected_ = self_.parseFailureExpected_;
|
||||
|
||||
public:
|
||||
ParseFailureGuard(Env& self, bool b) : self_(self)
|
||||
{
|
||||
self_.setParseFailureExpected(b);
|
||||
}
|
||||
|
||||
~ParseFailureGuard()
|
||||
{
|
||||
self_.setParseFailureExpected(oldExpected_);
|
||||
}
|
||||
|
||||
// No copy, no move
|
||||
ParseFailureGuard(ParseFailureGuard const&) = delete;
|
||||
ParseFailureGuard&
|
||||
operator=(ParseFailureGuard const&) = delete;
|
||||
ParseFailureGuard(ParseFailureGuard&& other) = delete;
|
||||
ParseFailureGuard&
|
||||
operator=(ParseFailureGuard&&) = delete;
|
||||
};
|
||||
|
||||
/** Gets an RAII guard to set and restore the parse failure flag
|
||||
*
|
||||
* Usage:
|
||||
* auto const guard = env.getParseFailureGuard(true/false);
|
||||
*/
|
||||
[[nodiscard]] ParseFailureGuard
|
||||
getParseFailureGuard(bool b)
|
||||
{
|
||||
return ParseFailureGuard{*this, b};
|
||||
}
|
||||
|
||||
/** Turn off signature checks. */
|
||||
void
|
||||
disableSigs()
|
||||
|
||||
@@ -602,7 +602,7 @@ Env::autofill(JTx& jt)
|
||||
catch (ParseError const&)
|
||||
{
|
||||
if (!parseFailureExpected_)
|
||||
test.log << "parse failed:\n" << pretty(jv) << std::endl;
|
||||
test.log << "parse failure:\n" << pretty(jv) << std::endl;
|
||||
rethrow();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user