mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
fix: add [[nodiscard]] to preclaim helpers and cover pre-amendment path
Mark readVault, preclaimUpdate, and preclaimCreate with [[nodiscard]] to match project convention for error-bearing return types. Add test for the pre-amendment preclaimUpdate path where the vault doesn't exist (readVault returning tecNO_ENTRY).
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <xrpl/tx/transactors/lending/LendingHelpers.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
bool
|
||||
LoanBrokerSet::checkExtraFeatures(PreflightContext const& ctx)
|
||||
{
|
||||
@@ -97,7 +98,7 @@ LoanBrokerSet::getValueFields()
|
||||
* @param id The vault ID to look up.
|
||||
* @return The vault SLE on success, or a TER error.
|
||||
*/
|
||||
static Expected<std::shared_ptr<SLE const>, TER>
|
||||
[[nodiscard]] static Expected<std::shared_ptr<SLE const>, TER>
|
||||
readVault(PreclaimContext const& ctx, AccountID const& account, uint256 const& id)
|
||||
{
|
||||
auto const sle = ctx.view.read(keylet::vault(id));
|
||||
@@ -121,7 +122,7 @@ readVault(PreclaimContext const& ctx, AccountID const& account, uint256 const& i
|
||||
* @param brokerID The LoanBroker ID to update.
|
||||
* @return The vault SLE on success, or a TER error.
|
||||
*/
|
||||
static Expected<std::shared_ptr<SLE const>, TER>
|
||||
[[nodiscard]] static Expected<std::shared_ptr<SLE const>, TER>
|
||||
preclaimUpdate(PreclaimContext const& ctx, AccountID const& account, uint256 const& brokerID)
|
||||
{
|
||||
auto const& tx = ctx.tx;
|
||||
@@ -197,9 +198,12 @@ preclaimUpdate(PreclaimContext const& ctx, AccountID const& account, uint256 con
|
||||
* @param account The transaction submitter (vault owner).
|
||||
* @return The vault SLE on success, or a TER error.
|
||||
*/
|
||||
static Expected<std::shared_ptr<SLE const>, TER>
|
||||
[[nodiscard]] static Expected<std::shared_ptr<SLE const>, TER>
|
||||
preclaimCreate(PreclaimContext const& ctx, AccountID const& account)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
ctx.tx.isFieldPresent(sfVaultID),
|
||||
"xrpl::LoanBrokerSet::preclaimCreate : VaultID is present in the transaction");
|
||||
auto const vault = readVault(ctx, account, ctx.tx[sfVaultID]);
|
||||
if (!vault)
|
||||
return vault;
|
||||
|
||||
@@ -1907,6 +1907,17 @@ class LoanBroker_test : public beast::unit_test::suite
|
||||
env(set(alice, vaultKL2.key), loanBrokerID(brokerKL.key), ter(tecNO_PERMISSION));
|
||||
}
|
||||
|
||||
// Pre-amendment: non-existent vault on update → tecNO_ENTRY
|
||||
{
|
||||
testcase("LoanBrokerSet pre-amendment: non-existent vault on update");
|
||||
Env env(*this);
|
||||
env.disableFeature(featureLendingProtocolV1_1);
|
||||
auto const [vaultID, brokerKL] = setup(env);
|
||||
|
||||
// Update with a VaultID that doesn't exist
|
||||
env(set(alice, uint256{1}), loanBrokerID(brokerKL.key), ter(tecNO_ENTRY));
|
||||
}
|
||||
|
||||
// Pre-amendment: Create without VaultID → temINVALID
|
||||
{
|
||||
testcase("LoanBrokerSet pre-amendment: create requires VaultID");
|
||||
|
||||
Reference in New Issue
Block a user