Fix sendMax path bug

This commit is contained in:
seelabs
2016-06-07 09:53:23 -04:00
parent 11c4ca00d5
commit 434855f500
2 changed files with 14 additions and 1 deletions

View File

@@ -176,7 +176,9 @@ toStrand (
STPathElement::typeAll, src, curIssue.currency, curIssue.account);
boost::optional<STPathElement> sendMaxPE;
if (sendMaxIssue && sendMaxIssue->account != src)
if (sendMaxIssue && sendMaxIssue->account != src &&
(path.empty () || !path[0].isAccount () ||
path[0].getAccountID () != sendMaxIssue->account))
sendMaxPE.emplace (sendMaxIssue->account, boost::none, boost::none);
STPathElement const lastNode (dst, boost::none, boost::none);

View File

@@ -363,6 +363,17 @@ struct Flow_test : public beast::unit_test::suite
expect (r.first == tesSUCCESS);
expect (equal (r.second, D{alice, gw, usdC}));
}
{
// Check path with sendMax and node with correct sendMax already set
Env env (*this, features(featureFlowV2), features(featureOwnerPaysFee));
env.fund (XRP (10000), alice, bob, gw);
env.trust (USD (1000), alice, bob);
env.trust (EUR (1000), alice, bob);
env (pay (gw, alice, EUR (100)));
auto const path = STPath ({STPathElement (STPathElement::typeAll,
EUR.account, EUR.currency, EUR.account)});
test (env, USD, EUR.issue(), path, tesSUCCESS);
}
}
void testDirectStep ()
{