From df4d2ec149e6613761ffb7b3d5fc176b0ca24e7b Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Thu, 13 Dec 2012 16:55:37 -0800 Subject: [PATCH] Check field present for stOwnerCount. --- src/cpp/ripple/PaymentTransactor.cpp | 7 +++++-- test/send-test.js | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index 8c6f32d021..48db9b1e5f 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -137,7 +137,8 @@ TER PaymentTransactor::doApply() // Direct XRP payment. const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance); - const uint32 uOwnerCount = mTxn.getFieldU32(sfOwnerCount); + const bool bOwnerCount = mTxn.isFieldPresent(sfPaths); + const uint32 uOwnerCount = bOwnerCount ? mTxn.getFieldU32(sfOwnerCount) : 0; const uint64 uReserve = theConfig.FEE_ACCOUNT_RESERVE+uOwnerCount*theConfig.FEE_OWNER_RESERVE; // Make sure have enough reserve to send. @@ -145,7 +146,9 @@ TER PaymentTransactor::doApply() && saSrcXRPBalance < saDstAmount + uReserve) // Reserve is not scaled by fee. { // Vote no. However, transaction might succeed, if applied in a different order. - Log(lsINFO) << "doPayment: Delay transaction: Insufficient funds."; + Log(lsINFO) << ""; + Log(lsINFO) << boost::str(boost::format("doPayment: Delay transaction: Insufficient funds: %s / %s (%d)") + % saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve); terResult = terUNFUNDED; } diff --git a/test/send-test.js b/test/send-test.js index faceca751c..d30534519f 100644 --- a/test/send-test.js +++ b/test/send-test.js @@ -262,8 +262,9 @@ buster.testCase("Sending", { // XXX In the future add ledger_accept after partial retry is implemented in the server. buster.testCase("Sending future", { - 'setUp' : testutils.build_setup(), - 'tearDown' : testutils.build_teardown(), + 'setUp' : testutils.build_setup(), + // 'setUp' : testutils.build_setup({ verbose : true }), + 'tearDown' : testutils.build_teardown(), "direct ripple" : function (done) { @@ -670,7 +671,7 @@ buster.testCase("Indirect ripple", { }); }, - "indirect ripple with path and transfer fee" : + "//indirect ripple with path and transfer fee" : function (done) { var self = this; @@ -720,6 +721,17 @@ buster.testCase("Indirect ripple", { }) .submit(); }, +// function (callback) { +// self.what = "Display ledger"; +// +// self.remote.request_ledger('current', true) +// .on('success', function (m) { +// console.log("Ledger: %s", JSON.stringify(m, undefined, 2)); +// +// callback(); +// }) +// .request(); +// }, function (callback) { self.what = "Verify balances.";