From d7d3741e1e0e5768d7c7fba0aa4f271bbe05df2e Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Tue, 30 Sep 2025 12:44:24 -0400 Subject: [PATCH] fixup! Implement transitive feature enabling for SAV --- src/test/app/AMM_test.cpp | 13 ++++++++---- src/test/app/Delegate_test.cpp | 38 ++++++++++++++++++++++++---------- src/test/app/MPToken_test.cpp | 25 ++++++++++++---------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 66bceec327..f8a7fb9ff4 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -58,7 +58,8 @@ private: {}, 0, {}, - {testable_amendments() - featureSingleAssetVault}); + {testable_amendments() - featureSingleAssetVault - + featureLendingProtocol}); // IOU to IOU testAMM( @@ -7499,7 +7500,9 @@ private: }; testCase( - "tecDUPLICATE", testable_amendments() - featureSingleAssetVault); + "tecDUPLICATE", + testable_amendments() - featureSingleAssetVault - + featureLendingProtocol); testCase( "terADDRESS_COLLISION", testable_amendments() | featureSingleAssetVault); @@ -7881,6 +7884,8 @@ private: run() override { FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const featuresNoSAV = + all - featureSingleAssetVault - featureLendingProtocol; testInvalidInstance(); testInstanceCreate(); testInvalidDeposit(all); @@ -7931,8 +7936,8 @@ private: testLPTokenBalance(all - fixAMMv1_3); testLPTokenBalance(all - fixAMMv1_1 - fixAMMv1_3); testAMMClawback(all); - testAMMClawback(all - featureSingleAssetVault); - testAMMClawback(all - featureAMMClawback - featureSingleAssetVault); + testAMMClawback(featuresNoSAV); + testAMMClawback(featuresNoSAV - featureAMMClawback); testAMMClawback(all - featureAMMClawback); testAMMClawback(all - fixAMMv1_1 - fixAMMv1_3 - featureAMMClawback); testAMMDepositWithFrozenAssets(all); diff --git a/src/test/app/Delegate_test.cpp b/src/test/app/Delegate_test.cpp index bec720a556..21a8684188 100644 --- a/src/test/app/Delegate_test.cpp +++ b/src/test/app/Delegate_test.cpp @@ -1692,17 +1692,33 @@ class Delegate_test : public beast::unit_test::suite } } + /// This class only adds a non-explicit ctor for uint256's to FeatureBitset + class BitsetWrapper : public FeatureBitset + { + public: + BitsetWrapper() = default; + + template + BitsetWrapper(uint256 const& f, Fs&&... fs) + : FeatureBitset(f, std::forward(fs)...) + { + } + }; + void testTxReqireFeatures(FeatureBitset features) { testcase("test delegate disabled tx"); using namespace jtx; + BitsetWrapper const featuresSAV{ + featureSingleAssetVault, featureLendingProtocol}; + // map of tx and required feature. // non-delegatable tx are not included. // NFTokenMint, NFTokenBurn, NFTokenCreateOffer, NFTokenCancelOffer, // NFTokenAcceptOffer are not included, they are tested separately. - std::unordered_map txRequiredFeatures{ + std::unordered_map txRequiredFeatures{ {"TicketCreate", featureTicketBatch}, {"CheckCreate", featureChecks}, {"CheckCash", featureChecks}, @@ -1739,12 +1755,12 @@ class Delegate_test : public beast::unit_test::suite {"NFTokenModify", featureDynamicNFT}, {"PermissionedDomainSet", featurePermissionedDomains}, {"PermissionedDomainDelete", featurePermissionedDomains}, - {"VaultCreate", featureSingleAssetVault}, - {"VaultSet", featureSingleAssetVault}, - {"VaultDelete", featureSingleAssetVault}, - {"VaultDeposit", featureSingleAssetVault}, - {"VaultWithdraw", featureSingleAssetVault}, - {"VaultClawback", featureSingleAssetVault}}; + {"VaultCreate", featuresSAV}, + {"VaultSet", featuresSAV}, + {"VaultDelete", featuresSAV}, + {"VaultDeposit", featuresSAV}, + {"VaultWithdraw", featuresSAV}, + {"VaultClawback", featuresSAV}}; // Can not delegate tx if any required feature disabled. { @@ -1762,8 +1778,8 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(alice, bob, {tx}), ter(temMALFORMED)); }; - for (auto const& tx : txRequiredFeatures) - txAmendmentDisabled(features, tx.first); + for (auto const& required : txRequiredFeatures) + txAmendmentDisabled(features, required.first); } // if all the required features in txRequiredFeatures are enabled, will @@ -1780,8 +1796,8 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(alice, bob, {tx})); }; - for (auto const& tx : txRequiredFeatures) - txAmendmentEnabled(tx.first); + for (auto const& required : txRequiredFeatures) + txAmendmentEnabled(required.first); } } diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 7d0126bd65..699159983c 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -3613,33 +3613,36 @@ public: using namespace test::jtx; FeatureBitset const all{testable_amendments()}; + auto const featuresNoSAV = + all - featureSingleAssetVault - featureLendingProtocol; + auto const featuresNoDomains = all - featurePermissionedDomains; // MPTokenIssuanceCreate - testCreateValidation(all - featureSingleAssetVault); - testCreateValidation(all - featurePermissionedDomains); + testCreateValidation(featuresNoSAV); + testCreateValidation(featuresNoDomains); testCreateValidation(all); - testCreateEnabled(all - featureSingleAssetVault); + testCreateEnabled(featuresNoSAV); testCreateEnabled(all); // MPTokenIssuanceDestroy - testDestroyValidation(all - featureSingleAssetVault); + testDestroyValidation(featuresNoSAV); testDestroyValidation(all); - testDestroyEnabled(all - featureSingleAssetVault); + testDestroyEnabled(featuresNoSAV); testDestroyEnabled(all); // MPTokenAuthorize - testAuthorizeValidation(all - featureSingleAssetVault); + testAuthorizeValidation(featuresNoSAV); testAuthorizeValidation(all); - testAuthorizeEnabled(all - featureSingleAssetVault); + testAuthorizeEnabled(featuresNoSAV); testAuthorizeEnabled(all); // MPTokenIssuanceSet - testSetValidation(all - featureSingleAssetVault - featureDynamicMPT); - testSetValidation(all - featureSingleAssetVault); + testSetValidation(featuresNoSAV - featureDynamicMPT); + testSetValidation(featuresNoSAV); testSetValidation(all - featureDynamicMPT); - testSetValidation(all - featurePermissionedDomains); + testSetValidation(featuresNoDomains); testSetValidation(all); - testSetEnabled(all - featureSingleAssetVault); + testSetEnabled(featuresNoSAV); testSetEnabled(all); // MPT clawback