mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
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:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user