UT: Add test for currency conversion.

This commit is contained in:
Arthur Britto
2012-11-08 15:18:05 -08:00
parent ca0ab6c01d
commit 054a16b105

View File

@@ -333,5 +333,74 @@ buster.testCase("Offer tests", {
done();
});
},
"ripple currency conversion" :
function (done) {
var self = this;
// self.remote.set_trace();
async.waterfall([
function (callback) {
self.what = "Create accounts.";
testutils.create_accounts(self.remote, "root", "10000", ["alice", "bob", "mtgox"], callback);
},
function (callback) {
self.what = "Set limits.";
testutils.credit_limits(self.remote,
{
"alice" : "100/USD/mtgox",
"bob" : "1000/USD/mtgox"
},
callback);
},
function (callback) {
self.what = "Distribute funds.";
testutils.payments(self.remote,
{
"mtgox" : "100/USD/alice"
},
callback);
},
function (callback) {
self.remote.transaction()
.offer_create("bob", "100/USD/mtgox", "500")
.on('proposed', function (m) {
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
callback(m.result != 'tesSUCCESS');
})
.submit();
},
function (callback) {
self.what = "Alice converts USD to XRC.";
self.remote.transaction()
.payment("alice", "alice", "500")
.send_max("100/USD/mtgox")
.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" : [ "0/USD/mtgox", "500" ],
"bob" : "100/USD/mtgox",
},
callback);
},
], function (error) {
buster.refute(error, self.what);
done();
});
},
});
// vim:sw=2:sts=2:ts=8