mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
UT: Add test for currency conversion.
This commit is contained in:
@@ -333,5 +333,74 @@ buster.testCase("Offer tests", {
|
|||||||
done();
|
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
|
// vim:sw=2:sts=2:ts=8
|
||||||
|
|||||||
Reference in New Issue
Block a user