diff --git a/test/send-test.js b/test/send-test.js index cbc9c10133..d5f4cb9693 100644 --- a/test/send-test.js +++ b/test/send-test.js @@ -474,14 +474,13 @@ buster.testCase("Indirect ripple", { callback); }, function (callback) { - self.what = "Give alice some mtgox."; + self.what = "Distribute funds."; - testutils.payment(self.remote, "mtgox", "alice", "70/USD/mtgox", callback); - }, - function (callback) { - self.what = "Give bob some mtgox."; - - testutils.payment(self.remote, "mtgox", "bob", "50/USD/mtgox", callback); + testutils.payments(self.remote, + { + "mtgox" : [ "70/USD/alice", "50/USD/bob" ], + }, + callback); }, function (callback) { self.what = "Verify alice balance with mtgox."; @@ -544,14 +543,13 @@ buster.testCase("Indirect ripple", { callback); }, function (callback) { - self.what = "Give alice some mtgox."; + self.what = "Distribute funds."; - testutils.payment(self.remote, "mtgox", "alice", "70/USD/mtgox", callback); - }, - function (callback) { - self.what = "Give bob some mtgox."; - - testutils.payment(self.remote, "mtgox", "bob", "50/USD/mtgox", callback); + testutils.payments(self.remote, + { + "mtgox" : [ "70/USD/alice", "50/USD/bob" ], + }, + callback); }, function (callback) { self.what = "Alice sends via a path"; @@ -604,14 +602,13 @@ buster.testCase("Indirect ripple", { callback); }, function (callback) { - self.what = "Give bob some mtgox."; + self.what = "Distribute funds."; - testutils.payment(self.remote, "mtgox", "bob", "100/USD/mtgox", callback); - }, - function (callback) { - self.what = "Give carol some mtgox."; - - testutils.payment(self.remote, "mtgox", "carol", "100/USD/mtgox", callback); + testutils.payments(self.remote, + { + "mtgox" : [ "100/USD/bob", "100/USD/carol" ], + }, + callback); }, function (callback) { self.what = "Alice pays amazon via multiple paths"; @@ -672,14 +669,13 @@ buster.testCase("Indirect ripple", { callback); }, function (callback) { - self.what = "Give bob some mtgox."; + self.what = "Distribute funds."; - testutils.payment(self.remote, "mtgox", "bob", "100/USD/mtgox", callback); - }, - function (callback) { - self.what = "Give carol some mtgox."; - - testutils.payment(self.remote, "mtgox", "carol", "100/USD/mtgox", callback); + testutils.payments(self.remote, + { + "mtgox" : [ "100/USD/bob", "100/USD/carol" ], + }, + callback); }, function (callback) { self.what = "Alice pays amazon via multiple paths"; diff --git a/test/testutils.js b/test/testutils.js index 097032876b..a3a03466c8 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -171,6 +171,33 @@ var payment = function (remote, src, dst, amount, callback) { .submit(); }; +var payments = function (remote, balances, callback) { + assert(3 === arguments.length); + + var sends = []; + + for (var src in balances) { + var values_src = balances[src]; + var values = 'string' === typeof values_src ? [ values_src ] : values_src; + + for (var index in values) { + var amount_json = values[index]; + var amount = Amount.from_json(amount_json); + + sends.push( { "source" : src, "destination" : amount.issuer.to_json(), "amount" : amount_json } ); + } + } + + async.every(sends, + function (send, callback) { + payment(remote, send.source, send.destination, send.amount, + function (mismatch) { callback(!mismatch); }); + }, + function (every) { + callback(!every); + }); +}; + var transfer_rate = function (remote, src, billionths, callback) { assert(4 === arguments.length); @@ -238,6 +265,7 @@ exports.create_accounts = create_accounts; exports.credit_limit = credit_limit; exports.credit_limits = credit_limits; exports.payment = payment; +exports.payments = payments; exports.build_teardown = build_teardown; exports.transfer_rate = transfer_rate; exports.verify_balance = verify_balance;