From affe5835feb392e52d3fc1956340809be6042edc Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Fri, 17 Apr 2026 10:19:58 -0400 Subject: [PATCH] fix: Change AMMClawback return code to tecNO_PERMISSION (#6946) --- .../tx/transactors/dex/AMMClawback.cpp | 4 ++- src/test/app/AMMClawback_test.cpp | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/libxrpl/tx/transactors/dex/AMMClawback.cpp b/src/libxrpl/tx/transactors/dex/AMMClawback.cpp index e437da3e70..aaf5574049 100644 --- a/src/libxrpl/tx/transactors/dex/AMMClawback.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMClawback.cpp @@ -105,7 +105,9 @@ AMMClawback::preclaim(PreclaimContext const& ctx) // permission if (((issuerFlagsIn & lsfAllowTrustLineClawback) == 0u) || ((issuerFlagsIn & lsfNoFreeze) != 0u)) - return tesSUCCESS; + { + return tecNO_PERMISSION; + } } auto const checkClawAsset = [&](Asset const asset) -> bool { diff --git a/src/test/app/AMMClawback_test.cpp b/src/test/app/AMMClawback_test.cpp index 5803d1a0d3..897441eb81 100644 --- a/src/test/app/AMMClawback_test.cpp +++ b/src/test/app/AMMClawback_test.cpp @@ -10,14 +10,14 @@ namespace test { class AMMClawback_test : public beast::unit_test::suite { void - testInvalidRequest() + testInvalidRequest(FeatureBitset features) { testcase("test invalid request"); using namespace jtx; // Test if holder does not exist. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(100000), gw, alice); @@ -42,7 +42,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if asset pair provided does not exist. This should // return terNO_AMM error. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(100000), gw, alice); @@ -74,7 +74,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if the issuer field and holder field is the same. This should // return temMALFORMED error. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -102,7 +102,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if the Asset field matches the Account field. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -130,7 +130,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if the Amount field matches the Asset field. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -159,7 +159,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if the Amount is invalid, which is less than zero. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -192,7 +192,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if the issuer did not set asfAllowTrustLineClawback, AMMClawback // transaction is prohibited. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -216,7 +216,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test invalid flag. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -244,7 +244,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test if tfClawTwoAssets is set when the two assets in the AMM pool // are not issued by the same issuer. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(10000), gw, alice); @@ -275,7 +275,7 @@ class AMMClawback_test : public beast::unit_test::suite // Test clawing back XRP is being prohibited. { - Env env(*this); + Env env(*this, features); Account const gw{"gateway"}; Account const alice{"alice"}; env.fund(XRP(1000000), gw, alice); @@ -2491,10 +2491,14 @@ class AMMClawback_test : public beast::unit_test::suite FeatureBitset const all = jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol; - testInvalidRequest(); + testInvalidRequest(all); + testInvalidRequest(all - featureMPTokensV2); testFeatureDisabled(all - featureAMMClawback); for (auto const& features : - {all - fixAMMv1_3 - fixAMMClawbackRounding, all - fixAMMClawbackRounding, all}) + {all - fixAMMv1_3 - fixAMMClawbackRounding - featureMPTokensV2, + all - fixAMMClawbackRounding - featureMPTokensV2, + all - featureMPTokensV2, + all}) { testAMMClawbackSpecificAmount(features); testAMMClawbackExceedBalance(features);