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(
AccountID const& from,
ReadView const& view,
AccountID const& to,
SLE::const_ref toSle,
bool hasDestinationTag);

View File

@@ -1378,15 +1378,19 @@ checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
canSendToAccount(
AccountID const& from,
ReadView const& view,
AccountID const& to,
SLE::const_ref toSle,
bool hasDestinationTag)
{
if (auto const ret = checkDestinationAndTag(toSle, hasDestinationTag))
return ret;
if (from == to)
return tesSUCCESS;
if (toSle->isFlag(lsfDepositAuth))
{
if (!view.exists(keylet::depositPreauth(toSle->at(sfAccount), from)))
if (!view.exists(keylet::depositPreauth(to, from)))
return tecNO_PERMISSION;
}
@@ -1401,10 +1405,8 @@ canSendToAccount(
bool hasDestinationTag)
{
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