mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 08:25:51 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
var path = require("path");
|
||||
|
||||
// Where to find the binary.
|
||||
exports.rippled = path.join(process.cwd(), "build/rippled");
|
||||
exports.rippled = path.resolve("build/rippled");
|
||||
|
||||
exports.server_default = "alpha";
|
||||
|
||||
@@ -534,5 +534,87 @@ buster.testCase("Offer tests", {
|
||||
done();
|
||||
});
|
||||
},
|
||||
|
||||
"ripple cross currency payment" :
|
||||
// alice --> [XRP --> carol --> USD/mtgox] --> bob
|
||||
|
||||
function (done) {
|
||||
var self = this;
|
||||
var seq;
|
||||
|
||||
// self.remote.set_trace();
|
||||
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
self.what = "Create accounts.";
|
||||
|
||||
testutils.create_accounts(self.remote, "root", "10000", ["alice", "bob", "carol", "mtgox"], callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Set limits.";
|
||||
|
||||
testutils.credit_limits(self.remote,
|
||||
{
|
||||
"carol" : "1000/USD/mtgox",
|
||||
"bob" : "2000/USD/mtgox"
|
||||
},
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Distribute funds.";
|
||||
|
||||
testutils.payments(self.remote,
|
||||
{
|
||||
"mtgox" : "500/USD/carol"
|
||||
},
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Create offer.";
|
||||
|
||||
self.remote.transaction()
|
||||
.offer_create("carol", "500", "50/USD/mtgox")
|
||||
.on('proposed', function (m) {
|
||||
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
||||
callback(m.result !== 'tesSUCCESS');
|
||||
|
||||
seq = m.tx_json.Sequence;
|
||||
})
|
||||
.submit();
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Alice send USD/mtgox converting from XRP.";
|
||||
|
||||
self.remote.transaction()
|
||||
.payment("alice", "bob", "25/USD/mtgox")
|
||||
.send_max("333")
|
||||
.on('proposed', function (m) {
|
||||
// console.log("proposed: %s", JSON.stringify(m));
|
||||
|
||||
callback(m.result !== 'tesSUCCESS');
|
||||
})
|
||||
.submit();
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Verify balances.";
|
||||
|
||||
testutils.verify_balances(self.remote,
|
||||
{
|
||||
// "alice" : [ "500" ],
|
||||
"bob" : "25/USD/mtgox",
|
||||
"carol" : "475/USD/mtgox",
|
||||
},
|
||||
callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Verify offer consumed.";
|
||||
|
||||
testutils.verify_offer_not_found(self.remote, "bob", seq, callback);
|
||||
},
|
||||
], function (error) {
|
||||
buster.refute(error, self.what);
|
||||
done();
|
||||
});
|
||||
},
|
||||
});
|
||||
// vim:sw=2:sts=2:ts=8
|
||||
|
||||
@@ -15,11 +15,34 @@ var serverDelay = 1500;
|
||||
|
||||
buster.testRunner.timeout = 5000;
|
||||
|
||||
/*
|
||||
buster.testCase("Simple", {
|
||||
'setUp' : testutils.build_setup({no_server: true}), //
|
||||
'tearDown' : testutils.build_teardown(),
|
||||
|
||||
"simple." :
|
||||
function (done) { buster.assert(1);
|
||||
|
||||
this.remote.transaction()
|
||||
.payment('root', 'alice', "10000")
|
||||
.on('success', function (r) {
|
||||
done();
|
||||
}).submit();
|
||||
|
||||
this.remote.transaction()
|
||||
.payment('root', 'alice', "20000")
|
||||
.on('success', function (r) {
|
||||
done();
|
||||
}).submit();
|
||||
|
||||
}
|
||||
}); */
|
||||
|
||||
buster.testCase("Sending", {
|
||||
'setUp' : testutils.build_setup(),
|
||||
'tearDown' : testutils.build_teardown(),
|
||||
|
||||
"send XRP to non-existant account without create." :
|
||||
"send XRP to non-existent account without create." :
|
||||
function (done) {
|
||||
var self = this;
|
||||
var ledgers = 20;
|
||||
@@ -77,12 +100,12 @@ buster.testCase("Sending", {
|
||||
},
|
||||
|
||||
// Also test transaction becomes lost after terNO_DST.
|
||||
"credit_limit to non-existant account = terNO_DST" :
|
||||
"credit_limit to non-existent account = terNO_DST" :
|
||||
function (done) {
|
||||
this.remote.transaction()
|
||||
.ripple_line_set("root", "100/USD/alice")
|
||||
.on('proposed', function (m) {
|
||||
// console.log("proposed: %s", JSON.stringify(m));
|
||||
//console.log("proposed: %s", JSON.stringify(m));
|
||||
|
||||
buster.assert.equals(m.result, 'terNO_DST');
|
||||
|
||||
@@ -102,7 +125,7 @@ buster.testCase("Sending", {
|
||||
testutils.create_accounts(self.remote, "root", "10000", ["alice", "bob", "mtgox"], callback);
|
||||
},
|
||||
function (callback) {
|
||||
self.what = "Check a non-existant credit limit.";
|
||||
self.what = "Check a non-existent credit limit.";
|
||||
|
||||
self.remote.request_ripple_balance("alice", "mtgox", "USD", 'CURRENT')
|
||||
.on('ripple_state', function (m) {
|
||||
|
||||
@@ -52,7 +52,7 @@ Server.prototype.once = function (e, c) {
|
||||
};
|
||||
|
||||
Server.prototype.serverPath = function() {
|
||||
return "tmp/server/" + this.name;
|
||||
return path.resolve("tmp/server", this.name);
|
||||
};
|
||||
|
||||
Server.prototype.configPath = function() {
|
||||
|
||||
@@ -22,7 +22,7 @@ var account_dump = function (remote, account, callback) {
|
||||
.ledger_hash(remote.ledger_hash())
|
||||
.account_root("root")
|
||||
.on('success', function (r) {
|
||||
console.log("account_root: %s", JSON.stringify(r, undefined, 2));
|
||||
//console.log("account_root: %s", JSON.stringify(r, undefined, 2));
|
||||
|
||||
callback();
|
||||
})
|
||||
@@ -106,7 +106,10 @@ var build_setup = function (opts, host) {
|
||||
* @param host {String} Identifier for the host configuration to be used.
|
||||
*/
|
||||
var build_teardown = function (host) {
|
||||
|
||||
return function (done) {
|
||||
|
||||
|
||||
host = host || config.server_default;
|
||||
|
||||
var data = this.store[host];
|
||||
@@ -114,16 +117,22 @@ var build_teardown = function (host) {
|
||||
|
||||
async.series([
|
||||
function disconnectWebsocketStep(callback) {
|
||||
|
||||
data.remote
|
||||
.on('disconnected', callback)
|
||||
.connect(false);
|
||||
},
|
||||
function stopServerStep(callback) {
|
||||
if (opts.no_server) return callback();
|
||||
|
||||
if (opts.no_server)
|
||||
{
|
||||
|
||||
return callback();
|
||||
}
|
||||
|
||||
data.server.on('stopped', callback).stop();
|
||||
}
|
||||
], done);
|
||||
], done);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -265,16 +274,16 @@ var verify_balance = function (remote, src, amount_json, callback) {
|
||||
else {
|
||||
remote.request_ripple_balance(src, amount.issuer().to_json(), amount.currency().to_json(), 'CURRENT')
|
||||
.once('ripple_state', function (m) {
|
||||
// console.log("BALANCE: %s", JSON.stringify(m));
|
||||
// console.log("account_balance: %s", m.account_balance.to_text_full());
|
||||
// console.log("account_limit: %s", m.account_limit.to_text_full());
|
||||
// console.log("issuer_balance: %s", m.issuer_balance.to_text_full());
|
||||
// console.log("issuer_limit: %s", m.issuer_limit.to_text_full());
|
||||
// console.log("BALANCE: %s", JSON.stringify(m));
|
||||
// console.log("account_balance: %s", m.account_balance.to_text_full());
|
||||
// console.log("account_limit: %s", m.account_limit.to_text_full());
|
||||
// console.log("issuer_balance: %s", m.issuer_balance.to_text_full());
|
||||
// console.log("issuer_limit: %s", m.issuer_limit.to_text_full());
|
||||
|
||||
var account_balance = Amount.from_json(m.account_balance);
|
||||
|
||||
if (!account_balance.equals(amount)) {
|
||||
console.log("verify_balance: failed: %s vs %s is %s", src, amount_json, amount.to_text_full());
|
||||
console.log("verify_balance: failed: %s vs %s is %s: %s", src, account_balance.to_text_full(), amount.to_text_full(), account_balance.not_equals_why(amount));
|
||||
}
|
||||
|
||||
callback(!account_balance.equals(amount));
|
||||
|
||||
@@ -2,6 +2,7 @@ var buster = require("buster");
|
||||
|
||||
var Server = require("./server.js").Server;
|
||||
var Remote = require("../src/js/remote.js").Remote;
|
||||
var config = require("./config.js");
|
||||
|
||||
require("../src/js/remote.js").config = require("./config.js");
|
||||
|
||||
@@ -9,10 +10,10 @@ buster.testRunner.timeout = 5000;
|
||||
|
||||
buster.testCase("WebSocket connection", {
|
||||
'setUp' :
|
||||
function (done) { server = Server.from_config("alpha").on('started', done).start(); },
|
||||
function (done) { if (config.servers.alpha.no_server) done(); else server = Server.from_config("alpha").on('started', done).start(); },
|
||||
|
||||
'tearDown' :
|
||||
function (done) { server.on('stopped', done).stop(); },
|
||||
function (done) { if (config.servers.alpha.no_server) done(); else server.on('stopped', done).stop(); },
|
||||
|
||||
"websocket connect and disconnect" :
|
||||
function (done) {
|
||||
|
||||
Reference in New Issue
Block a user