mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
- Parse negative amounts. - Make Amount.negate() return a new value. - Add Amount.equals(). - Rename Remote.trace() to set_trace(). - Fix request_ripple_balnce. - Add more tests to send-test.js. - Add more tests to amount-test.js. - Add helper functions create_accounts and credit_limits to testutils.js.
81 lines
2.0 KiB
JavaScript
81 lines
2.0 KiB
JavaScript
var async = require("async");
|
|
// var buster = require("buster");
|
|
|
|
var Remote = require("../js/remote.js").Remote;
|
|
var Server = require("./server.js").Server;
|
|
|
|
var config = require("./config.js");
|
|
|
|
var test_setup = function (done, host) {
|
|
var self = this;
|
|
var host = host || config.server_default;
|
|
|
|
this.store = this.store || {};
|
|
|
|
var data = this.store[host] = this.store[host] || {};
|
|
|
|
data.server = Server.from_config(host).on('started', function () {
|
|
self.remote = data.remote = Remote.from_config(host).once('ledger_closed', done).connect();
|
|
}).start();
|
|
};
|
|
|
|
var test_teardown = function (done, host) {
|
|
var host = host || config.server_default;
|
|
|
|
var data = this.store[host];
|
|
|
|
data.remote
|
|
.on('disconnected', function () {
|
|
data.server.on('stopped', done).stop();
|
|
})
|
|
.connect(false);
|
|
};
|
|
|
|
var create_accounts = function (remote, src, amount, accounts, callback) {
|
|
assert(5 === arguments.length);
|
|
|
|
async.forEachSeries(accounts, function (account, callback) {
|
|
remote.transaction()
|
|
.payment(src, account, amount)
|
|
.set_flags('CreateAccount')
|
|
.on('proposed', function (m) {
|
|
// console.log("proposed: %s", JSON.stringify(m));
|
|
|
|
callback(m.result != 'tesSUCCESS');
|
|
})
|
|
.on('error', function (m) {
|
|
// console.log("error: %s", JSON.stringify(m));
|
|
|
|
callback(m);
|
|
})
|
|
.submit();
|
|
}, callback);
|
|
};
|
|
|
|
var credit_limit = function (remote, src, amount, callback) {
|
|
assert(4 === arguments.length);
|
|
|
|
remote.transaction()
|
|
.ripple_line_set(src, amount)
|
|
.on('proposed', function (m) {
|
|
// console.log("proposed: %s", JSON.stringify(m));
|
|
|
|
// buster.assert.equals(m.result, 'tesSUCCESS');
|
|
|
|
callback(m.result != 'tesSUCCESS');
|
|
})
|
|
.on('error', function (m) {
|
|
// console.log("error: %s", JSON.stringify(m));
|
|
|
|
callback(m);
|
|
})
|
|
.submit();
|
|
};
|
|
|
|
exports.create_accounts = create_accounts;
|
|
exports.credit_limit = credit_limit;
|
|
exports.test_setup = test_setup;
|
|
exports.test_teardown = test_teardown;
|
|
|
|
// vim:sw=2:sts=2:ts=8
|