mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
JS Tests: Replace one of the hard-coded fees in the testsuite. More to go.
This commit is contained in:
@@ -1651,14 +1651,16 @@ buster.testCase("Offer tfSell", {
|
|||||||
"basic sell" :
|
"basic sell" :
|
||||||
function (done) {
|
function (done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var final_create;
|
var final_create, seq_carol;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (callback) {
|
function (callback) {
|
||||||
// Provide micro amounts to compensate for fees to make results round nice.
|
// Provide micro amounts to compensate for fees to make results round nice.
|
||||||
self.what = "Create accounts.";
|
self.what = "Create accounts.";
|
||||||
|
|
||||||
testutils.create_accounts(self.remote, "root", "350.000020", ["alice", "bob", "mtgox"], callback);
|
var req_amount = self.remote.reserve(1).add(self.remote.fee_tx(20)).add(100000000);
|
||||||
|
testutils.create_accounts(self.remote, "root", req_amount.to_json(),
|
||||||
|
["alice", "bob", "mtgox"], callback);
|
||||||
},
|
},
|
||||||
function (callback) {
|
function (callback) {
|
||||||
self.what = "Set limits.";
|
self.what = "Set limits.";
|
||||||
@@ -1687,19 +1689,21 @@ buster.testCase("Offer tfSell", {
|
|||||||
.set_flags('Sell') // Should not matter at all.
|
.set_flags('Sell') // Should not matter at all.
|
||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("proposed: offer_create: %s", json.stringify(m));
|
// console.log("proposed: offer_create: %s", json.stringify(m));
|
||||||
callback(m.result !== 'tesSUCCESS');
|
if (m.result !== 'tesSUCCESS') {
|
||||||
|
throw new Error("Bob's OfferCreate tx did not succeed: "+m.result);
|
||||||
|
} else callback(null);
|
||||||
|
|
||||||
seq_carol = m.tx_json.sequence;
|
seq_carol = m.tx_json.sequence;
|
||||||
})
|
})
|
||||||
.submit();
|
.submit();
|
||||||
},
|
},
|
||||||
function (callback) {
|
function (callback) {
|
||||||
// Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available.
|
// Alice has 350 + fees - a reserve of 50 = 250 reserve = 100 available.
|
||||||
// Ask for more than available to prove reserve works.
|
// Ask for more than available to prove reserve works.
|
||||||
self.what = "Create offer alice.";
|
self.what = "Create offer alice.";
|
||||||
|
|
||||||
self.remote.transaction()
|
self.remote.transaction()
|
||||||
.offer_create("alice", "100/USD/mtgox", "100.0")
|
.offer_create("alice", "200/USD/mtgox", "200.0")
|
||||||
.set_flags('Sell') // Should not matter at all.
|
.set_flags('Sell') // Should not matter at all.
|
||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("proposed: offer_create: %s", json.stringify(m));
|
// console.log("proposed: offer_create: %s", json.stringify(m));
|
||||||
@@ -1732,7 +1736,7 @@ buster.testCase("Offer tfSell", {
|
|||||||
},
|
},
|
||||||
], function (error) {
|
], function (error) {
|
||||||
// console.log("result: error=%s", error);
|
// console.log("result: error=%s", error);
|
||||||
buster.refute(error);
|
buster.refute(error, self.what);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -1741,7 +1745,7 @@ buster.testCase("Offer tfSell", {
|
|||||||
"2x sell exceed limit" :
|
"2x sell exceed limit" :
|
||||||
function (done) {
|
function (done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var final_create;
|
var final_create, seq_carol;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (callback) {
|
function (callback) {
|
||||||
@@ -1797,7 +1801,9 @@ buster.testCase("Offer tfSell", {
|
|||||||
.set_flags('Sell')
|
.set_flags('Sell')
|
||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("proposed: offer_create: %s", json.stringify(m));
|
// console.log("proposed: offer_create: %s", json.stringify(m));
|
||||||
callback(m.result !== 'tesSUCCESS');
|
if (m.result !== 'tesSUCCESS') {
|
||||||
|
callback(new Error("Alice's OfferCreate didn't succeed: "+m.result));
|
||||||
|
} else callback(null);
|
||||||
|
|
||||||
seq_carol = m.tx_json.sequence;
|
seq_carol = m.tx_json.sequence;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -160,7 +160,9 @@ var create_accounts = function (remote, src, amount, accounts, callback) {
|
|||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("proposed: %s", JSON.stringify(m));
|
// console.log("proposed: %s", JSON.stringify(m));
|
||||||
|
|
||||||
callback(m.result != 'tesSUCCESS');
|
if (m.result != 'tesSUCCESS') {
|
||||||
|
callback(new Error("Payment to create account did not succeed."));
|
||||||
|
} else callback(null);
|
||||||
})
|
})
|
||||||
.on('error', function (m) {
|
.on('error', function (m) {
|
||||||
// console.log("error: %s", JSON.stringify(m));
|
// console.log("error: %s", JSON.stringify(m));
|
||||||
|
|||||||
Reference in New Issue
Block a user