From 14704eee6b5bf251f0da3b16e7e40f9f9bb8e21d Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 25 Jul 2018 01:53:27 -0700 Subject: [PATCH] Add more tests of getFee (#897) --- docs/index.md | 6 ++++-- docs/src/getFee.md.ejs | 6 ++++-- test/api-test.js | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 74fc22bb..c670988e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1075,6 +1075,8 @@ return api.getServerInfo().then(info => {/* ... */}); Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to. +This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`. + ### Parameters Name | Type | Description @@ -1083,7 +1085,7 @@ cushion | number | *Optional* The fee is the product of the base fee, the `load_ ### Return Value -This method returns a promise that resolves with a string encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP. +This method returns a promise that resolves with a string-encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP. ### Example @@ -1092,7 +1094,7 @@ return api.getFee().then(fee => {/* ... */}); ``` ```json -"0.012" +"0.000012" ``` ## getLedgerVersion diff --git a/docs/src/getFee.md.ejs b/docs/src/getFee.md.ejs index 7e40289b..057550f0 100644 --- a/docs/src/getFee.md.ejs +++ b/docs/src/getFee.md.ejs @@ -4,13 +4,15 @@ Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to. +This will use the [feeCushion parameter](#parameters) provided to the RippleAPI constructor, or the default value of `1.2`. + ### Parameters <%- renderSchema('input/get-fee.json') %> ### Return Value -This method returns a promise that resolves with a string encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP. +This method returns a promise that resolves with a string-encoded floating point value representing the estimated fee to submit a transaction, expressed in XRP. ### Example @@ -19,5 +21,5 @@ return api.getFee().then(fee => {/* ... */}); ``` ```json -"0.012" +"0.000012" ``` diff --git a/test/api-test.js b/test/api-test.js index 9a45ecfc..4c5db4df 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -1853,6 +1853,23 @@ describe('RippleAPI', function () { address, requests.preparePayment.normal, instructions).then( _.partial(checkResult, expectedResponse, 'prepare')); }); + + it('getFee custom cushion', function () { + this.api._feeCushion = 1.4; + return this.api.getFee().then(fee => { + assert.strictEqual(fee, '0.000014'); + }); + }); + + // This is not recommended since it may result in attempting to pay + // less than the base fee. However, this test verifies + // the existing behavior. + it('getFee cushion less than 1.0', function () { + this.api._feeCushion = 0.9; + return this.api.getFee().then(fee => { + assert.strictEqual(fee, '0.000009'); + }); + }); it('disconnect & isConnected', function () { assert.strictEqual(this.api.isConnected(), true);