@@ -4990,6 +4990,56 @@ class Vault_test : public beast::unit_test::suite
49904990 }
49914991 }
49924992
4993+ void
4994+ testVaultDeleteData ()
4995+ {
4996+ using namespace test ::jtx;
4997+
4998+ auto const test =
4999+ [&](std::string const & prefix, FeatureBitset features, std::string const & pl, TER expectedCode) {
5000+ Env env{*this , features};
5001+ testcase (" VaultDelete data " + prefix);
5002+ Account const owner{" owner" };
5003+
5004+ Vault vault{env};
5005+ env.fund (XRP (1'000'000 ), owner);
5006+ env.close ();
5007+
5008+ PrettyAsset const xrpAsset = xrpIssue ();
5009+
5010+ auto const [tx, keylet] = vault.create ({.owner = owner, .asset = xrpAsset});
5011+ env (tx, ter (tesSUCCESS), THISLINE);
5012+
5013+ auto delTx = vault.del ({.owner = owner, .id = keylet.key });
5014+ env (delTx, data (pl), ter (expectedCode), THISLINE);
5015+
5016+ env.close ();
5017+ };
5018+
5019+ auto const all = testable_amendments ();
5020+ {
5021+ // Test VaultDelete with fixLendingProtocolV1_1 disabled
5022+ // Transaction succeeds even if the data field is provided
5023+ test (
5024+ " fixLendingProtocolV1_1 disabled" ,
5025+ all - fixLendingProtocolV1_1,
5026+ std::string (maxDataPayloadLength, ' A' ),
5027+ tesSUCCESS);
5028+ }
5029+
5030+ {
5031+ // Transaction fails if the data field is too large
5032+ test (
5033+ " fixLendingProtocolV1_1 enabled data too large" ,
5034+ all,
5035+ std::string (maxDataPayloadLength + 1 , ' A' ),
5036+ temMALFORMED);
5037+ // Transaction fails if the data field is set, but is empty
5038+ test (" fixLendingProtocolV1_1 enabled data empty" , all, std::string (0 , ' A' ), temMALFORMED);
5039+ test (" fixLendingProtocolV1_1 enabled data valid" , all, std::string (maxDataPayloadLength, ' A' ), tesSUCCESS);
5040+ }
5041+ }
5042+
49935043public:
49945044 void
49955045 run () override
@@ -5011,6 +5061,7 @@ class Vault_test : public beast::unit_test::suite
50115061 testVaultClawbackBurnShares ();
50125062 testVaultClawbackAssets ();
50135063 testAssetsMaximum ();
5064+ testVaultDeleteData ();
50145065 }
50155066};
50165067
0 commit comments