mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -525,6 +525,11 @@ TER LedgerEntrySet::dirAdd(
|
||||
const uint256& uLedgerIndex,
|
||||
boost::function<void (SLE::ref)> fDescriber)
|
||||
{
|
||||
cLog(lsDEBUG)
|
||||
<< boost::str(boost::format("dirAdd: uRootIndex=%s uLedgerIndex=%s")
|
||||
% uRootIndex.ToString()
|
||||
% uLedgerIndex.ToString());
|
||||
|
||||
SLE::pointer sleNode;
|
||||
STVector256 svIndexes;
|
||||
SLE::pointer sleRoot = entryCache(ltDIR_NODE, uRootIndex);
|
||||
|
||||
@@ -531,10 +531,6 @@ void LedgerMaster::pubThread()
|
||||
cLog(lsDEBUG) << "Publishing ledger " << l->getLedgerSeq();
|
||||
setFullLedger(l); // OPTIMIZEME: This is actually more work than we need to do
|
||||
theApp->getOPs().pubLedger(l);
|
||||
BOOST_FOREACH(callback& c, mOnValidate)
|
||||
{
|
||||
c(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,11 +229,16 @@ TER OfferCreateTransactor::takeOffers(
|
||||
}
|
||||
}
|
||||
|
||||
cLog(lsINFO) << "takeOffers: " << transToken(terResult);
|
||||
|
||||
// On storing meta data, delete offers that were found unfunded to prevent encountering them in future.
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedFound)
|
||||
{
|
||||
|
||||
cLog(lsINFO) << "takeOffers: found unfunded: " << uOfferIndex.ToString();
|
||||
|
||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
||||
if (tesSUCCESS != terResult)
|
||||
break;
|
||||
@@ -245,12 +250,16 @@ TER OfferCreateTransactor::takeOffers(
|
||||
// On success, delete offers that became unfunded.
|
||||
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedBecame)
|
||||
{
|
||||
cLog(lsINFO) << "takeOffers: became unfunded: " << uOfferIndex.ToString();
|
||||
|
||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
||||
if (tesSUCCESS != terResult)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cLog(lsINFO) << "takeOffers< " << transToken(terResult);
|
||||
|
||||
return terResult;
|
||||
}
|
||||
|
||||
@@ -331,7 +340,7 @@ TER OfferCreateTransactor::doApply()
|
||||
{
|
||||
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
|
||||
|
||||
terResult = tecUNFUNDED;
|
||||
terResult = tecUNFUNDED_OFFER;
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult && !saTakerPays.isNative())
|
||||
|
||||
@@ -161,7 +161,7 @@ TER PaymentTransactor::doApply()
|
||||
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
|
||||
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
|
||||
|
||||
terResult = tecUNFUNDED;
|
||||
terResult = tecUNFUNDED_PAYMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,7 +19,10 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
|
||||
{ tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." },
|
||||
{ tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." },
|
||||
|
||||
{ tecUNFUNDED, "tecUNFUNDED", "Source account had insufficient balance for transaction." },
|
||||
{ tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." },
|
||||
{ tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." },
|
||||
{ tecUNFUNDED_OFFER, "tecUNFUNDED_OFFER", "Insufficient balance to fund created offer." },
|
||||
{ tecUNFUNDED_PAYMENT, "tecUNFUNDED_PAYMENT", "Insufficient XRP balance to send." },
|
||||
|
||||
{ tefFAILURE, "tefFAILURE", "Failed to apply." },
|
||||
{ tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." },
|
||||
|
||||
@@ -111,6 +111,9 @@ enum TER // aka TransactionEngineResult
|
||||
// DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data.
|
||||
tecCLAIM = 100,
|
||||
tecPATH_PARTIAL = 101,
|
||||
tecUNFUNDED_ADD = 102,
|
||||
tecUNFUNDED_OFFER = 103,
|
||||
tecUNFUNDED_PAYMENT = 104,
|
||||
tecDIR_FULL = 121,
|
||||
tecINSUF_RESERVE_LINE = 122,
|
||||
tecINSUF_RESERVE_OFFER = 123,
|
||||
@@ -119,7 +122,7 @@ enum TER // aka TransactionEngineResult
|
||||
tecNO_LINE_INSUF_RESERVE = 126,
|
||||
tecNO_LINE_REDUNDANT = 127,
|
||||
tecPATH_DRY = 128,
|
||||
tecUNFUNDED = 129,
|
||||
tecUNFUNDED = 129, // Depericated, old ambiguous unfunded.
|
||||
};
|
||||
|
||||
#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED)
|
||||
|
||||
@@ -38,29 +38,33 @@ TER WalletAddTransactor::doApply()
|
||||
return tefCREATED;
|
||||
}
|
||||
|
||||
STAmount saAmount = mTxn.getFieldAmount(sfAmount);
|
||||
STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||
// Direct XRP payment.
|
||||
|
||||
if (saSrcBalance < saAmount)
|
||||
STAmount saDstAmount = mTxn.getFieldAmount(sfAmount);
|
||||
const STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
|
||||
const uint64 uReserve = mEngine->getLedger()->getReserve(uOwnerCount);
|
||||
STAmount saPaid = mTxn.getTransactionFee();
|
||||
|
||||
// Make sure have enough reserve to send. Allow final spend to use reserve for fee.
|
||||
if (saSrcBalance + saPaid < saDstAmount + uReserve) // Reserve is not scaled by fee.
|
||||
{
|
||||
std::cerr
|
||||
<< boost::str(boost::format("WalletAdd: Delay transaction: insufficient balance: balance=%s amount=%s")
|
||||
% saSrcBalance.getText()
|
||||
% saAmount.getText())
|
||||
<< std::endl;
|
||||
// Vote no. However, transaction might succeed, if applied in a different order.
|
||||
cLog(lsINFO) << boost::str(boost::format("WalletAdd: Delay transaction: Insufficient funds: %s / %s (%d)")
|
||||
% saSrcBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
|
||||
|
||||
return tecUNFUNDED;
|
||||
return tecUNFUNDED_ADD;
|
||||
}
|
||||
|
||||
// Deduct initial balance from source account.
|
||||
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saAmount);
|
||||
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saDstAmount);
|
||||
|
||||
// Create the account.
|
||||
sleDst = mEngine->entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||
|
||||
sleDst->setFieldAccount(sfAccount, uDstAccountID);
|
||||
sleDst->setFieldU32(sfSequence, 1);
|
||||
sleDst->setFieldAmount(sfBalance, saAmount);
|
||||
sleDst->setFieldAmount(sfBalance, saDstAmount);
|
||||
sleDst->setFieldAccount(sfRegularKey, uAuthKeyID);
|
||||
|
||||
std::cerr << "WalletAdd<" << std::endl;
|
||||
|
||||
@@ -517,7 +517,7 @@ buster.testCase("Offer tests", {
|
||||
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
||||
.on('proposed', function (m) {
|
||||
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
||||
callback(m.result !== 'tecUNFUNDED');
|
||||
callback(m.result !== 'tecUNFUNDED_OFFER');
|
||||
|
||||
seq = m.tx_json.Sequence;
|
||||
})
|
||||
|
||||
@@ -661,13 +661,13 @@ buster.testCase("More Path finding", {
|
||||
// Test alternative paths with qualities.
|
||||
});
|
||||
|
||||
buster.testCase("Path negatives", {
|
||||
buster.testCase("Issues", {
|
||||
// 'setUp' : testutils.build_setup({ verbose: true, no_server: true }),
|
||||
// 'setUp' : testutils.build_setup({ verbose: true }),
|
||||
'setUp' : testutils.build_setup(),
|
||||
'tearDown' : testutils.build_teardown(),
|
||||
|
||||
"Issue #5" :
|
||||
"Path negative: Issue #5" :
|
||||
function (done) {
|
||||
var self = this;
|
||||
|
||||
@@ -691,14 +691,17 @@ buster.testCase("Path negatives", {
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Distribute funds.";
|
||||
self.what = "Alice sends via a path";
|
||||
|
||||
testutils.payments(self.remote,
|
||||
{
|
||||
// 4. acct 2 sent acct 3 a 75 iou
|
||||
"bob" : "75/USD/carol",
|
||||
},
|
||||
callback);
|
||||
self.remote.transaction()
|
||||
.payment("alice", "bob", "55/USD/mtgox")
|
||||
.path_add( [ { account: "carol" } ])
|
||||
.on('proposed', function (m) {
|
||||
// console.log("proposed: %s", JSON.stringify(m));
|
||||
|
||||
callback(m.result !== 'tesSUCCESS');
|
||||
})
|
||||
.submit();
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Verify balances.";
|
||||
@@ -764,6 +767,70 @@ buster.testCase("Path negatives", {
|
||||
buster.refute(error, self.what);
|
||||
done();
|
||||
});
|
||||
},
|
||||
|
||||
"//Path negative: Issue #23: smaller" :
|
||||
// alice -120 USD-> michael -25 USD-> amy
|
||||
// alice -25 USD-> Bill -75 USD -> Sam -100 USD-> Amy
|
||||
//
|
||||
// alice -- limit 40 --> bob
|
||||
// alice --> carol --> dan --> bob
|
||||
// Balance of 100 USD Bob - Balance of 37 USD -> Rod
|
||||
//
|
||||
function (done) {
|
||||
var self = this;
|
||||
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
self.what = "Create accounts.";
|
||||
|
||||
testutils.create_accounts(self.remote, "root", "10000.0", ["alice", "bob", "carol", "dan"], callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Set credit limits.";
|
||||
|
||||
testutils.credit_limits(self.remote,
|
||||
{
|
||||
"bob" : [ "40/USD/alice", "20/USD/dan" ],
|
||||
"dan" : [ "20/USD/carol" ],
|
||||
"carol" : [ "20/USD/alice" ],
|
||||
},
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Distribute funds.";
|
||||
|
||||
testutils.payments(self.remote,
|
||||
{
|
||||
// 4. acct 2 sent acct 3 a 75 iou
|
||||
"alice" : "55/USD/bob",
|
||||
},
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Verify balances.";
|
||||
|
||||
testutils.verify_balances(self.remote,
|
||||
{
|
||||
"bob" : [ "40/USD/alice", "15/USD/dan" ],
|
||||
},
|
||||
callback);
|
||||
},
|
||||
// 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 (error) {
|
||||
buster.refute(error, self.what);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
|
||||
@@ -481,7 +481,7 @@ buster.testCase("Reserve", {
|
||||
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
||||
.on('proposed', function (m) {
|
||||
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
||||
callback(m.result !== 'tecUNFUNDED');
|
||||
callback(m.result !== 'tecUNFUNDED_OFFER');
|
||||
|
||||
seq = m.tx_json.Sequence;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user