Fix LoanBrokerDelete with empty or zero broker ID (RIPD-3858) (#5967)

This commit is contained in:
Gregory Tsipenyuk
2025-10-30 23:01:05 -04:00
committed by GitHub
parent 7a758a42f9
commit e8dddcbb7f
2 changed files with 21 additions and 0 deletions

View File

@@ -1015,6 +1015,24 @@ class LoanBroker_test : public beast::unit_test::suite
sig(sfCounterpartySignature, alice),
fee(env.current()->fees().base * 2));
// preflight: temINVALID (empty broker id)
{
auto jv = del(alice, brokerKeylet.key);
jv[sfLoanBrokerID] = "";
env(jv, ter(temINVALID));
}
// preflight: temINVALID (zero broker id)
{
// needs a flag to distinguish the parsed STTx from the prior
// test
auto jv = del(alice, uint256{}, tfFullyCanonicalSig);
BEAST_EXPECT(
jv[sfLoanBrokerID] ==
"0000000000000000000000000000000000000000000000000000000000"
"000000");
env(jv, ter(temINVALID));
}
// preclaim: tecHAS_OBLIGATIONS
env(del(alice, brokerKeylet.key), ter(tecHAS_OBLIGATIONS));
}

View File

@@ -32,6 +32,9 @@ LoanBrokerDelete::checkExtraFeatures(PreflightContext const& ctx)
NotTEC
LoanBrokerDelete::preflight(PreflightContext const& ctx)
{
if (ctx.tx[sfLoanBrokerID] == beast::zero)
return temINVALID;
return tesSUCCESS;
}