Fix broken Vault unit tests introduced in 6adb2ec

- canSendToAccount will check if a destination tag is required _before_
  checking if the sender is the destination. This is the original
  VaultWithdraw behavior, and I want to stay consistent.
This commit is contained in:
Ed Hennis
2025-10-24 00:30:06 -04:00
parent 66b547f6fc
commit 7c45f6a673
2 changed files with 7 additions and 4 deletions

View File

@@ -730,6 +730,7 @@ checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
canSendToAccount( canSendToAccount(
AccountID const& from, AccountID const& from,
ReadView const& view, ReadView const& view,
AccountID const& to,
SLE::const_ref toSle, SLE::const_ref toSle,
bool hasDestinationTag); bool hasDestinationTag);

View File

@@ -1378,15 +1378,19 @@ checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
canSendToAccount( canSendToAccount(
AccountID const& from, AccountID const& from,
ReadView const& view, ReadView const& view,
AccountID const& to,
SLE::const_ref toSle, SLE::const_ref toSle,
bool hasDestinationTag) bool hasDestinationTag)
{ {
if (auto const ret = checkDestinationAndTag(toSle, hasDestinationTag)) if (auto const ret = checkDestinationAndTag(toSle, hasDestinationTag))
return ret; return ret;
if (from == to)
return tesSUCCESS;
if (toSle->isFlag(lsfDepositAuth)) if (toSle->isFlag(lsfDepositAuth))
{ {
if (!view.exists(keylet::depositPreauth(toSle->at(sfAccount), from))) if (!view.exists(keylet::depositPreauth(to, from)))
return tecNO_PERMISSION; return tecNO_PERMISSION;
} }
@@ -1401,10 +1405,8 @@ canSendToAccount(
bool hasDestinationTag) bool hasDestinationTag)
{ {
auto const toSle = view.read(keylet::account(to)); auto const toSle = view.read(keylet::account(to));
if (from == to)
return toSle ? (TER)tesSUCCESS : (TER)tecINTERNAL;
return canSendToAccount(from, view, toSle, hasDestinationTag); return canSendToAccount(from, view, to, toSle, hasDestinationTag);
} }
[[nodiscard]] TER [[nodiscard]] TER