Add more tests of getFee (#897)

This commit is contained in:
Elliot Lee
2018-07-25 01:53:27 -07:00
committed by GitHub
parent 860f6a6cd8
commit 14704eee6b
3 changed files with 25 additions and 4 deletions

View File

@@ -1075,6 +1075,8 @@ return api.getServerInfo().then(info => {/* ... */});
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to. 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 ### Parameters
Name | Type | Description Name | Type | Description
@@ -1083,7 +1085,7 @@ cushion | number | *Optional* The fee is the product of the base fee, the `load_
### Return Value ### 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 ### Example
@@ -1092,7 +1094,7 @@ return api.getFee().then(fee => {/* ... */});
``` ```
```json ```json
"0.012" "0.000012"
``` ```
## getLedgerVersion ## getLedgerVersion

View File

@@ -4,13 +4,15 @@
Returns the estimated transaction fee for the rippled server the RippleAPI instance is connected to. 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 ### Parameters
<%- renderSchema('input/get-fee.json') %> <%- renderSchema('input/get-fee.json') %>
### Return Value ### 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 ### Example
@@ -19,5 +21,5 @@ return api.getFee().then(fee => {/* ... */});
``` ```
```json ```json
"0.012" "0.000012"
``` ```

View File

@@ -1853,6 +1853,23 @@ describe('RippleAPI', function () {
address, requests.preparePayment.normal, instructions).then( address, requests.preparePayment.normal, instructions).then(
_.partial(checkResult, expectedResponse, 'prepare')); _.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 () { it('disconnect & isConnected', function () {
assert.strictEqual(this.api.isConnected(), true); assert.strictEqual(this.api.isConnected(), true);