Allow Lending transactions in Batch

This commit is contained in:
JCW
2026-02-06 11:09:04 +00:00
parent 79b3b4ffea
commit 93e98ac714
6 changed files with 6530 additions and 45 deletions

View File

@@ -2581,11 +2581,6 @@ class Batch_test : public beast::unit_test::suite
{
testcase("loan");
bool const lendingBatchEnabled =
!std::any_of(Batch::disabledTxTypes.begin(), Batch::disabledTxTypes.end(), [](auto const& disabled) {
return disabled == ttLOAN_BROKER_SET;
});
using namespace test::jtx;
test::jtx::Env env{*this, features | featureSingleAssetVault | featureLendingProtocol | featureMPTokensV1};
@@ -2645,7 +2640,7 @@ class Batch_test : public beast::unit_test::suite
{
auto const [txIDs, batchID] = submitBatch(
env,
lendingBatchEnabled ? temBAD_SIGNATURE : temINVALID_INNER_BATCH,
temBAD_SIGNATURE,
batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
batch::inner(
env.json(
@@ -2676,7 +2671,7 @@ class Batch_test : public beast::unit_test::suite
{
auto const [txIDs, batchID] = submitBatch(
env,
lendingBatchEnabled ? temBAD_SIGNER : temINVALID_INNER_BATCH,
temBAD_SIGNER,
batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
batch::inner(
env.json(
@@ -2696,7 +2691,7 @@ class Batch_test : public beast::unit_test::suite
auto const batchFee = batch::calcBatchFee(env, 1, 2);
auto const [txIDs, batchID] = submitBatch(
env,
lendingBatchEnabled ? TER(tesSUCCESS) : TER(temINVALID_INNER_BATCH),
TER(tesSUCCESS),
batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
batch::inner(
env.json(
@@ -2728,7 +2723,7 @@ class Batch_test : public beast::unit_test::suite
auto const batchFee = batch::calcBatchFee(env, 1, 2);
auto const [txIDs, batchID] = submitBatch(
env,
lendingBatchEnabled ? TER(tesSUCCESS) : TER(temINVALID_INNER_BATCH),
TER(tesSUCCESS),
batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
batch::inner(
env.json(
@@ -2743,8 +2738,7 @@ class Batch_test : public beast::unit_test::suite
}
env.close();
BEAST_EXPECT(env.le(brokerKeylet));
if (auto const sleLoan = env.le(loanKeylet);
lendingBatchEnabled ? BEAST_EXPECT(sleLoan) : !BEAST_EXPECT(!sleLoan))
if (auto const sleLoan = env.le(loanKeylet); BEAST_EXPECT(sleLoan))
{
BEAST_EXPECT(sleLoan->isFlag(lsfLoanImpaired));
}

File diff suppressed because it is too large Load Diff

View File

@@ -3396,11 +3396,6 @@ protected:
// From FIND-001
testcase << "Batch Bypass Counterparty";
bool const lendingBatchEnabled =
!std::any_of(Batch::disabledTxTypes.begin(), Batch::disabledTxTypes.end(), [](auto const& disabled) {
return disabled == ttLOAN_BROKER_SET;
});
using namespace jtx;
using namespace std::chrono_literals;
Env env(*this, all);
@@ -3444,7 +3439,7 @@ protected:
env(batch::outer(borrower, seq, batchFee, tfAllOrNothing),
batch::inner(forgedLoanSet, seq + 1),
batch::inner(pay(borrower, lender, XRP(1)), seq + 2),
ter(lendingBatchEnabled ? temBAD_SIGNATURE : temINVALID_INNER_BATCH));
ter(temBAD_SIGNATURE));
env.close();
// ? Check that the loan was NOT created
@@ -6877,7 +6872,7 @@ public:
}
};
class LoanBatch_test : public Loan_test
class LoanSimulator_test : public Loan_test
{
protected:
beast::xor_shift_engine engine_;
@@ -6977,7 +6972,7 @@ public:
}
};
class LoanArbitrary_test : public LoanBatch_test
class LoanArbitrary_test : public LoanSimulator_test
{
void
run() override
@@ -7003,7 +6998,7 @@ class LoanArbitrary_test : public LoanBatch_test
};
BEAST_DEFINE_TESTSUITE(Loan, tx, xrpl);
BEAST_DEFINE_TESTSUITE_MANUAL(LoanBatch, tx, xrpl);
BEAST_DEFINE_TESTSUITE_MANUAL(LoanSimulator, tx, xrpl);
BEAST_DEFINE_TESTSUITE_MANUAL(LoanArbitrary, tx, xrpl);
} // namespace test

View File

@@ -256,13 +256,6 @@ Batch::preflight(PreflightContext const& ctx)
return temINVALID;
}
if (std::any_of(disabledTxTypes.begin(), disabledTxTypes.end(), [txType](auto const& disabled) {
return txType == disabled;
}))
{
return temINVALID_INNER_BATCH;
}
if (!(stx.getFlags() & tfInnerBatchTxn))
{
JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "

View File

@@ -34,24 +34,6 @@ public:
TER
doApply() override;
static constexpr auto disabledTxTypes = std::to_array<TxType>({
ttVAULT_CREATE,
ttVAULT_SET,
ttVAULT_DELETE,
ttVAULT_DEPOSIT,
ttVAULT_WITHDRAW,
ttVAULT_CLAWBACK,
ttLOAN_BROKER_SET,
ttLOAN_BROKER_DELETE,
ttLOAN_BROKER_COVER_DEPOSIT,
ttLOAN_BROKER_COVER_WITHDRAW,
ttLOAN_BROKER_COVER_CLAWBACK,
ttLOAN_SET,
ttLOAN_DELETE,
ttLOAN_MANAGE,
ttLOAN_PAY,
});
};
} // namespace xrpl