mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Add path test for issue #23.
This commit is contained in:
@@ -525,6 +525,11 @@ TER LedgerEntrySet::dirAdd(
|
|||||||
const uint256& uLedgerIndex,
|
const uint256& uLedgerIndex,
|
||||||
boost::function<void (SLE::ref)> fDescriber)
|
boost::function<void (SLE::ref)> fDescriber)
|
||||||
{
|
{
|
||||||
|
cLog(lsDEBUG)
|
||||||
|
<< boost::str(boost::format("dirAdd: uRootIndex=%s uLedgerIndex=%s")
|
||||||
|
% uRootIndex.ToString()
|
||||||
|
% uLedgerIndex.ToString());
|
||||||
|
|
||||||
SLE::pointer sleNode;
|
SLE::pointer sleNode;
|
||||||
STVector256 svIndexes;
|
STVector256 svIndexes;
|
||||||
SLE::pointer sleRoot = entryCache(ltDIR_NODE, uRootIndex);
|
SLE::pointer sleRoot = entryCache(ltDIR_NODE, uRootIndex);
|
||||||
|
|||||||
@@ -531,10 +531,6 @@ void LedgerMaster::pubThread()
|
|||||||
cLog(lsDEBUG) << "Publishing ledger " << l->getLedgerSeq();
|
cLog(lsDEBUG) << "Publishing ledger " << l->getLedgerSeq();
|
||||||
setFullLedger(l); // OPTIMIZEME: This is actually more work than we need to do
|
setFullLedger(l); // OPTIMIZEME: This is actually more work than we need to do
|
||||||
theApp->getOPs().pubLedger(l);
|
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.
|
// On storing meta data, delete offers that were found unfunded to prevent encountering them in future.
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedFound)
|
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedFound)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
cLog(lsINFO) << "takeOffers: found unfunded: " << uOfferIndex.ToString();
|
||||||
|
|
||||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
||||||
if (tesSUCCESS != terResult)
|
if (tesSUCCESS != terResult)
|
||||||
break;
|
break;
|
||||||
@@ -245,12 +250,16 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
// On success, delete offers that became unfunded.
|
// On success, delete offers that became unfunded.
|
||||||
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedBecame)
|
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedBecame)
|
||||||
{
|
{
|
||||||
|
cLog(lsINFO) << "takeOffers: became unfunded: " << uOfferIndex.ToString();
|
||||||
|
|
||||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
||||||
if (tesSUCCESS != terResult)
|
if (tesSUCCESS != terResult)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cLog(lsINFO) << "takeOffers< " << transToken(terResult);
|
||||||
|
|
||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -661,13 +661,13 @@ buster.testCase("More Path finding", {
|
|||||||
// Test alternative paths with qualities.
|
// 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, no_server: true }),
|
||||||
// 'setUp' : testutils.build_setup({ verbose: true }),
|
// 'setUp' : testutils.build_setup({ verbose: true }),
|
||||||
'setUp' : testutils.build_setup(),
|
'setUp' : testutils.build_setup(),
|
||||||
'tearDown' : testutils.build_teardown(),
|
'tearDown' : testutils.build_teardown(),
|
||||||
|
|
||||||
"Issue #5" :
|
"Path negative: Issue #5" :
|
||||||
function (done) {
|
function (done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@@ -691,14 +691,17 @@ buster.testCase("Path negatives", {
|
|||||||
callback);
|
callback);
|
||||||
},
|
},
|
||||||
function (callback) {
|
function (callback) {
|
||||||
self.what = "Distribute funds.";
|
self.what = "Alice sends via a path";
|
||||||
|
|
||||||
testutils.payments(self.remote,
|
self.remote.transaction()
|
||||||
{
|
.payment("alice", "bob", "55/USD/mtgox")
|
||||||
// 4. acct 2 sent acct 3 a 75 iou
|
.path_add( [ { account: "carol" } ])
|
||||||
"bob" : "75/USD/carol",
|
.on('proposed', function (m) {
|
||||||
},
|
// console.log("proposed: %s", JSON.stringify(m));
|
||||||
callback);
|
|
||||||
|
callback(m.result !== 'tesSUCCESS');
|
||||||
|
})
|
||||||
|
.submit();
|
||||||
},
|
},
|
||||||
function (callback) {
|
function (callback) {
|
||||||
self.what = "Verify balances.";
|
self.what = "Verify balances.";
|
||||||
@@ -764,6 +767,70 @@ buster.testCase("Path negatives", {
|
|||||||
buster.refute(error, self.what);
|
buster.refute(error, self.what);
|
||||||
done();
|
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
|
// vim:sw=2:sts=2:ts=8:et
|
||||||
|
|||||||
Reference in New Issue
Block a user