Address my review feedback on (#6017)

- Shortcut on issuer match in canTransfer.
- An asset can transfer if either trustline enabled rippling, so both
  must have it disabled for the transfer to fail with terNO_RIPPLE.
- Remove unnecessary asfDefaultRipple sets in unit tests.
- Add a new unit test helper class: testline, and a macro: THISLINE.
  When included as a parameter to Env::operator(), will include the line
  number of the transaction that didn't get the expected result. Works
  similarly to BEAST_EXPECT. I didn't do the same for the file name,
  because that can be deduced from the testcase name.
This commit is contained in:
Ed Hennis
2025-11-18 18:11:16 -05:00
parent d8b944c218
commit fd115cfc13
8 changed files with 123 additions and 50 deletions

View File

@@ -3288,11 +3288,11 @@ canTransfer(
return tesSUCCESS;
auto const issuerId = issue.getIssuer();
if (issuerId == from || issuerId == to)
return tesSUCCESS;
auto const sleIssuer = view.read(keylet::account(issuerId));
if (sleIssuer == nullptr)
return tefINTERNAL; // LCOV_EXCL_LINE
if (issuerId == from || issuerId == to)
return tesSUCCESS;
auto const isRippleDisabled = [&](AccountID account) -> bool {
// Line might not exist, but some transfers can create it. If this
@@ -3306,8 +3306,8 @@ canTransfer(
return sleIssuer->isFlag(lsfDefaultRipple) == false;
};
// Fail if rippling disabled on either trust line
if (isRippleDisabled(from) || isRippleDisabled(to))
// Fail if rippling disabled on both trust lines
if (isRippleDisabled(from) && isRippleDisabled(to))
return terNO_RIPPLE;
return tesSUCCESS;