UT: Add helper for setting transfer rate.

This commit is contained in:
Arthur Britto
2012-11-03 13:06:55 -07:00
parent f4d4b3920d
commit 7b268647a0
3 changed files with 24 additions and 14 deletions

View File

@@ -1046,6 +1046,9 @@ Transaction.prototype.send_max = function (send_max) {
Transaction.prototype.transfer_rate = function (rate) {
this.transaction.TransferRate = Number(rate);
if (this.transaction.TransferRate < 1e9)
throw 'invalidTransferRate';
return this;
}

View File

@@ -672,15 +672,7 @@ buster.testCase("Indirect ripple", {
function (callback) {
self.what = "Set mtgox transfer rate.";
self.remote.transaction()
.account_set("mtgox")
.transfer_rate(1.1e9)
.on('proposed', function (m) {
// console.log("proposed: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS');
})
.submit();
testutils.transfer_rate(self.remote, "mtgox", 1.1e9, callback);
},
function (callback) {
self.what = "Set alice's limit with bob.";
@@ -749,12 +741,7 @@ buster.testCase("Indirect ripple", {
done();
});
},
// Max send of currency sender doesn't have.
// Direct ripple without no liqudity.
// Ripple without credit path.
// Ripple with one-way credit path.
// Transfer Fees
// Use multiple paths.
// Test with XRC at start and end.
});
// vim:sw=2:sts=2:ts=8

View File

@@ -147,6 +147,25 @@ var payment = function (remote, src, dst, amount, callback) {
.submit();
};
var transfer_rate = function (remote, src, billionths, callback) {
assert(4 === arguments.length);
remote.transaction()
.account_set(src)
.transfer_rate(billionths)
.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();
};
var verify_balance = function (remote, src, amount_json, callback) {
assert(4 === arguments.length);
var amount = Amount.from_json(amount_json);
@@ -195,6 +214,7 @@ exports.create_accounts = create_accounts;
exports.credit_limit = credit_limit;
exports.payment = payment;
exports.build_teardown = build_teardown;
exports.transfer_rate = transfer_rate;
exports.verify_balance = verify_balance;
exports.verify_balances = verify_balances;