From 434855f500ebab1485720ca7edeaaab61be3ee6e Mon Sep 17 00:00:00 2001 From: seelabs Date: Tue, 7 Jun 2016 09:53:23 -0400 Subject: [PATCH] Fix sendMax path bug --- src/ripple/app/paths/impl/PaySteps.cpp | 4 +++- src/ripple/app/tests/Flow_test.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ripple/app/paths/impl/PaySteps.cpp b/src/ripple/app/paths/impl/PaySteps.cpp index e400c7462b..8b97ed3844 100644 --- a/src/ripple/app/paths/impl/PaySteps.cpp +++ b/src/ripple/app/paths/impl/PaySteps.cpp @@ -176,7 +176,9 @@ toStrand ( STPathElement::typeAll, src, curIssue.currency, curIssue.account); boost::optional 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); diff --git a/src/ripple/app/tests/Flow_test.cpp b/src/ripple/app/tests/Flow_test.cpp index 7cf83d3bf0..f19c24bfd2 100644 --- a/src/ripple/app/tests/Flow_test.cpp +++ b/src/ripple/app/tests/Flow_test.cpp @@ -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 () {