Compare commits

...

13 Commits

Author SHA1 Message Date
Ed Hennis
d953075853 Merge branch 'develop' into ximinez/parse-guard 2026-07-14 20:25:51 -04:00
Ed Hennis
97cd7281f1 Merge branch 'develop' into ximinez/parse-guard 2026-07-14 13:48:29 -04:00
Ed Hennis
2c58746092 Merge remote-tracking branch 'XRPLF/develop' into ximinez/parse-guard
* XRPLF/develop:
  chore: Run clang_tidy_check with `pass_filenames: false` from pre-commit (7800)
  feat: Add delegate filter param for account_tx RPC (6126)
  refactor: Move `jss.h` `include` out of `Indexes.h` (7799)
  test: Add tests for check doxygen style (7795)
  style: Add pre-commit hook to check doxygen style (7794)
  style: Unify style for all Doxygen comments (7776)
  fix: Improve Number addition/subtraction rounding (7369)
  feat: XLS-68: Sponsor, 5887 continuation  (7350)
2026-07-13 21:18:00 -04:00
Ed Hennis
13719d4eaa Merge branch 'develop' into ximinez/parse-guard 2026-07-08 17:23:42 -04:00
Ed Hennis
a0a99b0cc7 Merge branch 'develop' into ximinez/parse-guard 2026-07-07 19:32:52 -04:00
Ed Hennis
cc179f1ebc Merge branch 'develop' into ximinez/parse-guard 2026-07-07 17:35:04 -04:00
Ed Hennis
bb9d1323dd Merge branch 'develop' into ximinez/parse-guard 2026-07-02 11:18:45 -04:00
Ed Hennis
4a3365eb36 Merge branch 'develop' into ximinez/parse-guard 2026-07-01 16:03:10 -04:00
Ed Hennis
bd7c711ac8 Merge branch 'develop' into ximinez/parse-guard 2026-07-01 12:18:52 -04:00
Ed Hennis
e3ad106797 Merge branch 'develop' into ximinez/parse-guard 2026-06-30 16:28:16 -04:00
Ed Hennis
f6ab0b16bb fixup! Review feedback: ParseFailureGuard 2026-06-30 14:34:06 -04:00
Ed Hennis
a8ead867ba Review feedback: ParseFailureGuard
- Rename oldExpected to oldExpected_.
- Prevent copying, and moving.
- Make getParseFailureGuard [[nodiscard]].
2026-06-30 13:44:38 -04:00
Ed Hennis
84589262c1 test: Add an RAII class to manage the env.parseFailureExpected flag 2026-06-29 18:26:31 -04:00
4 changed files with 45 additions and 5 deletions

View File

@@ -498,7 +498,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),
@@ -510,7 +510,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

View File

@@ -5524,9 +5524,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");
@@ -5537,7 +5537,6 @@ class Vault_test : public beast::unit_test::Suite
BEAST_EXPECT(
e.what() == "invalidParamsField 'tx_json.AssetsMaximum' has invalid data."s);
}
env.setParseFailureExpected(false);
}
}

View File

@@ -514,6 +514,48 @@ 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.
*/

View File

@@ -629,7 +629,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();
}
}