UT: Add helper for setting transfer rate.

This commit is contained in:
Arthur Britto
2012-11-03 13:06:55 -07:00
committed by Stefan Thomas
parent f5988fd66e
commit 9e36297c0e
2 changed files with 23 additions and 0 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

@@ -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;