diff --git a/include/xrpl/protocol/TER.h b/include/xrpl/protocol/TER.h index 0d8bb94b06..b0dafecf1c 100644 --- a/include/xrpl/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -344,10 +344,6 @@ enum TECcodes : TERUnderlyingType { tecLIMIT_EXCEEDED = 195, tecPSEUDO_ACCOUNT = 196, tecPRECISION_LOSS = 197, - // DEPRECATED: This error code tecNO_DELEGATE_PERMISSION is reserved for - // backward compatibility with historical data on non-prod networks, can be - // reclaimed after those networks reset. - tecNO_DELEGATE_PERMISSION = 198, }; //------------------------------------------------------------------------------ diff --git a/src/libxrpl/protocol/Permissions.cpp b/src/libxrpl/protocol/Permissions.cpp index 47fc0d28b6..686b6376c1 100644 --- a/src/libxrpl/protocol/Permissions.cpp +++ b/src/libxrpl/protocol/Permissions.cpp @@ -67,6 +67,11 @@ Permission::Permission() #pragma pop_macro("PERMISSION") }; + XRPL_ASSERT( + txFeatureMap_.size() == delegableTx_.size(), + "xrpl::Permission : txFeatureMap_ and delegableTx_ must have same " + "size"); + for ([[maybe_unused]] auto const& permission : granularPermissionMap_) { XRPL_ASSERT( diff --git a/src/libxrpl/tx/transactors/delegate/DelegateUtils.cpp b/src/libxrpl/tx/transactors/delegate/DelegateUtils.cpp index 862fcf280c..f5e92bf06d 100644 --- a/src/libxrpl/tx/transactors/delegate/DelegateUtils.cpp +++ b/src/libxrpl/tx/transactors/delegate/DelegateUtils.cpp @@ -6,7 +6,7 @@ NotTEC checkTxPermission(std::shared_ptr const& delegate, STTx const& tx) { if (!delegate) - return terNO_DELEGATE_PERMISSION; // LCOV_EXCL_LINE + return terNO_DELEGATE_PERMISSION; auto const permissionArray = delegate->getFieldArray(sfPermissions); auto const txPermission = tx.getTxnType() + 1; @@ -28,7 +28,7 @@ loadGranularPermission( std::unordered_set& granularPermissions) { if (!delegate) - return; // LCOV_EXCL_LINE + return; auto const permissionArray = delegate->getFieldArray(sfPermissions); for (auto const& permission : permissionArray) diff --git a/src/libxrpl/tx/transactors/payment/Payment.cpp b/src/libxrpl/tx/transactors/payment/Payment.cpp index 8b80491278..3a64b5c739 100644 --- a/src/libxrpl/tx/transactors/payment/Payment.cpp +++ b/src/libxrpl/tx/transactors/payment/Payment.cpp @@ -265,6 +265,7 @@ Payment::checkPermission(ReadView const& view, STTx const& tx) tx.isFieldPresent(sfPaths)) return terNO_DELEGATE_PERMISSION; + // PaymentMint and PaymentBurn apply to both IOU and MPT direct payments. if (granularPermissions.contains(PaymentMint) && !isXRP(amountAsset) && amountAsset.getIssuer() == tx[sfAccount]) return tesSUCCESS; diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index f301b6d60f..0bc2157b9d 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -4155,8 +4155,12 @@ class Batch_test : public beast::unit_test::suite std::vector const testCases = { {0, "Batch", "tesSUCCESS", batchID, std::nullopt}, {1, "TrustSet", "tesSUCCESS", txIDs[0], batchID}, + // jv2 fails with terNO_DELEGATE_PERMISSION. }; validateClosedLedger(env, testCases); + + // verify jv2 is not present in the closed ledger. + BEAST_EXPECT(env.rpc("tx", txIDs[1])[jss::result][jss::error] == "txnNotFound"); } } diff --git a/src/test/app/Delegate_test.cpp b/src/test/app/Delegate_test.cpp index d6e970190e..1d036266ad 100644 --- a/src/test/app/Delegate_test.cpp +++ b/src/test/app/Delegate_test.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -1856,6 +1857,21 @@ class Delegate_test : public beast::unit_test::suite "\n Action: Verify security requirements to interact with Delegation feature"); } + void + testDelegateUtilsNullptrCheck() + { + testcase("DelegateUtils nullptr check"); + + // checkTxPermission nullptr check + STTx const tx{ttPAYMENT, [](STObject&) {}}; + BEAST_EXPECT(checkTxPermission(nullptr, tx) == terNO_DELEGATE_PERMISSION); + + // loadGranularPermission nullptr check + std::unordered_set granularPermissions; + loadGranularPermission(nullptr, ttPAYMENT, granularPermissions); + BEAST_EXPECT(granularPermissions.empty()); + } + void run() override { @@ -1881,6 +1897,7 @@ class Delegate_test : public beast::unit_test::suite testPermissionValue(all); testTxRequireFeatures(all); testTxDelegableCount(); + testDelegateUtilsNullptrCheck(); } }; BEAST_DEFINE_TESTSUITE(Delegate, app, xrpl);