mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
UT: Add test for nexus customer to customer with and without transfer fee
This commit is contained in:
@@ -495,6 +495,118 @@ buster.testCase("Sending future", {
|
|||||||
// Ripple with one-way credit path.
|
// Ripple with one-way credit path.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buster.testCase("Nexus", {
|
||||||
|
// 'setUp' : testutils.build_setup({ verbose: true }),
|
||||||
|
'setUp' : testutils.build_setup(),
|
||||||
|
'tearDown' : testutils.build_teardown(),
|
||||||
|
|
||||||
|
"customer to customer with and without transfer fee" :
|
||||||
|
function (done) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// self.remote.set_trace();
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Create accounts.";
|
||||||
|
|
||||||
|
testutils.create_accounts(self.remote, "root", "10000.0", ["alice", "bob", "mtgox"], callback);
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Set credit limits.";
|
||||||
|
|
||||||
|
testutils.credit_limits(self.remote,
|
||||||
|
{
|
||||||
|
"alice" : "100/AUD/mtgox",
|
||||||
|
"bob" : "100/AUD/mtgox",
|
||||||
|
},
|
||||||
|
callback);
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Distribute funds.";
|
||||||
|
|
||||||
|
testutils.payments(self.remote,
|
||||||
|
{
|
||||||
|
"mtgox" : [ "1/AUD/alice" ],
|
||||||
|
},
|
||||||
|
callback);
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Verify balances.";
|
||||||
|
|
||||||
|
testutils.verify_balances(self.remote,
|
||||||
|
{
|
||||||
|
"alice" : "1/AUD/mtgox",
|
||||||
|
"mtgox" : "-1/AUD/alice",
|
||||||
|
},
|
||||||
|
callback);
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Alice sends Bob 1 AUD";
|
||||||
|
|
||||||
|
self.remote.transaction()
|
||||||
|
.payment("alice", "bob", "1/AUD/mtgox")
|
||||||
|
.on('proposed', function (m) {
|
||||||
|
// console.log("proposed: %s", JSON.stringify(m));
|
||||||
|
|
||||||
|
callback(m.result !== 'tesSUCCESS');
|
||||||
|
})
|
||||||
|
.submit();
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Verify balances 2.";
|
||||||
|
|
||||||
|
testutils.verify_balances(self.remote,
|
||||||
|
{
|
||||||
|
"alice" : "0/AUD/mtgox",
|
||||||
|
"bob" : "1/AUD/mtgox",
|
||||||
|
"mtgox" : "-1/AUD/bob",
|
||||||
|
},
|
||||||
|
callback);
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Set transfer rate.";
|
||||||
|
|
||||||
|
self.remote.transaction()
|
||||||
|
.account_set("mtgox")
|
||||||
|
.transfer_rate(1e9*1.1)
|
||||||
|
.once('proposed', function (m) {
|
||||||
|
// console.log("proposed: %s", JSON.stringify(m));
|
||||||
|
callback(m.result !== 'tesSUCCESS');
|
||||||
|
})
|
||||||
|
.submit();
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Bob sends Alice 0.5 AUD";
|
||||||
|
|
||||||
|
self.remote.transaction()
|
||||||
|
.payment("bob", "alice", "0.5/AUD/mtgox")
|
||||||
|
.send_max("0.55/AUD/mtgox") // !!! Very important.
|
||||||
|
.on('proposed', function (m) {
|
||||||
|
// console.log("proposed: %s", JSON.stringify(m));
|
||||||
|
|
||||||
|
callback(m.result !== 'tesSUCCESS');
|
||||||
|
})
|
||||||
|
.submit();
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
self.what = "Verify balances 3.";
|
||||||
|
|
||||||
|
testutils.verify_balances(self.remote,
|
||||||
|
{
|
||||||
|
"alice" : "0.5/AUD/mtgox",
|
||||||
|
"bob" : "0.45/AUD/mtgox",
|
||||||
|
"mtgox" : [ "-0.5/AUD/alice","-0.45/AUD/bob" ],
|
||||||
|
},
|
||||||
|
callback);
|
||||||
|
},
|
||||||
|
], function (error) {
|
||||||
|
buster.refute(error, self.what);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
buster.testCase("Indirect ripple", {
|
buster.testCase("Indirect ripple", {
|
||||||
// 'setUp' : testutils.build_setup({ verbose: true }),
|
// 'setUp' : testutils.build_setup({ verbose: true }),
|
||||||
'setUp' : testutils.build_setup(),
|
'setUp' : testutils.build_setup(),
|
||||||
|
|||||||
Reference in New Issue
Block a user