Skip to content

Commit 995606b

Browse files
darkdarkdragonChris Clark
authored and
Chris Clark
committed
boost coverage to almost 100%
1 parent 4f86691 commit 995606b

File tree

57 files changed

+2014
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2014
-38
lines changed

docs/index.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ feeCushion | number | *Optional* Factor to multiply estimated fee by to provide
112112
proxy | uri string | *Optional* URI for HTTP/HTTPS proxy to use to connect to the rippled server.
113113
proxyAuthorization | string | *Optional* Username and password for HTTP basic authentication to the proxy in the format **username:password**.
114114
servers | array\<uri string\> | *Optional* Array of rippled servers to connect to. Currently only one server is supported.
115+
timeout | integer | *Optional* Timeout in milliseconds before considering a request to have failed.
115116
trace | boolean | *Optional* If true, log rippled requests and responses to stdout.
116117
trustedCertificates | array\<string\> | *Optional* Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.
117118

@@ -373,7 +374,8 @@ passive | boolean | *Optional* If enabled, the offer will not consume offers tha
373374
"currency": "XRP",
374375
"value": "2"
375376
},
376-
"immediateOrCancel": true
377+
"passive": true,
378+
"fillOrKill": true
377379
}
378380
```
379381

@@ -1120,7 +1122,7 @@ counterparty | object | Properties of the trustline from the perspective of the
11201122
*counterparty.* frozen | boolean | *Optional* If true, the trustline is frozen, which means that funds can only be sent to the counterparty.
11211123
*counterparty.* ripplingDisabled | boolean | *Optional* If true, payments cannot ripple through this trustline.
11221124
state | object | Properties of the trustline regarding it's current state that are not part of the specification.
1123-
*state.* balance | [value](#value) | The balance on the trustline, representing which party owes the other and by how much.
1125+
*state.* balance | [signedValue](#value) | The balance on the trustline, representing which party owes the other and by how much.
11241126

11251127
### Example
11261128

@@ -2888,7 +2890,8 @@ const order = {
28882890
"currency": "XRP",
28892891
"value": "2"
28902892
},
2891-
"immediateOrCancel": true
2893+
"passive": true,
2894+
"fillOrKill": true
28922895
};
28932896
return api.prepareOrder(address, order)
28942897
.then(prepared => {/* ... */});
@@ -2897,11 +2900,11 @@ return api.prepareOrder(address, order)
28972900

28982901
```json
28992902
{
2900-
"txJSON": "{\"Flags\":2147614720,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
2903+
"txJSON": "{\"Flags\":2147811328,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}",
29012904
"instructions": {
29022905
"fee": "0.000012",
29032906
"sequence": 23,
2904-
"maxLedgerVersion": 8820051
2907+
"maxLedgerVersion": 8819954
29052908
}
29062909
}
29072910
```

src/common/connection.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Connection extends EventEmitter {
8080
}
8181

8282
_onUnexpectedClose() {
83+
this._ws = null;
8384
this._isReady = false;
8485
this.connect().then();
8586
}
@@ -140,7 +141,8 @@ class Connection extends EventEmitter {
140141
this._proxyAuthorization, this._authorization,
141142
this._trustedCertificates);
142143
this._ws.on('message', this._onMessage.bind(this));
143-
this._ws.once('close', () => this._onUnexpectedClose);
144+
this._onUnexpectedCloseBound = this._onUnexpectedClose.bind(this);
145+
this._ws.once('close', this._onUnexpectedCloseBound);
144146
this._ws.once('open', () => this._onOpen().then(resolve, reject));
145147
}
146148
});
@@ -153,7 +155,7 @@ class Connection extends EventEmitter {
153155
} else if (this._state === WebSocket.CLOSING) {
154156
this._ws.once('close', resolve);
155157
} else {
156-
this._ws.removeListener('close', this._onUnexpectedClose);
158+
this._ws.removeListener('close', this._onUnexpectedCloseBound);
157159
this._ws.once('close', () => {
158160
this._ws = null;
159161
this._isReady = false;

src/common/schemas/input/api-options.json

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"format": "uri",
2727
"description": "URI for HTTP/HTTPS proxy to use to connect to the rippled server."
2828
},
29+
"timeout": {
30+
"type": "integer",
31+
"description": "Timeout in milliseconds before considering a request to have failed.",
32+
"minimum": 1
33+
},
2934
"proxyAuthorization": {
3035
"type": "string",
3136
"description": "Username and password for HTTP basic authentication to the proxy in the format **username:password**."

src/common/schemas/output/get-trustlines.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"state": {
3535
"properties": {
3636
"balance": {
37-
"$ref": "value",
37+
"$ref": "signedValue",
3838
"description": "The balance on the trustline, representing which party owes the other and by how much."
3939
}
4040
},

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ type APIOptions = {
5454
servers?: Array<string>,
5555
feeCushion?: number,
5656
trace?: boolean,
57-
proxy?: string
57+
proxy?: string,
58+
timeout?: number
5859
}
5960

6061
// prevent access to non-validated ledger versions

src/ledger/transactions.js

-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ function parseAccountTxTransaction(tx) {
4747
}
4848

4949
function counterpartyFilter(filters, tx: TransactionType) {
50-
if (!filters.counterparty) {
51-
return true;
52-
}
5350
if (tx.address === filters.counterparty || (
5451
tx.specification && (
5552
(tx.specification.destination &&

src/transaction/payment.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ type Payment = {
3333
}
3434

3535
function isXRPToXRPPayment(payment: Payment): boolean {
36-
const sourceCurrency = _.get(payment, 'source.maxAmount.currency');
37-
const destinationCurrency = _.get(payment, 'destination.amount.currency');
36+
const sourceCurrency = _.get(payment, 'source.maxAmount.currency',
37+
_.get(payment, 'source.amount.currency'));
38+
const destinationCurrency = _.get(payment, 'destination.amount.currency',
39+
_.get(payment, 'destination.minAmount.currency'));
3840
return sourceCurrency === 'XRP' && destinationCurrency === 'XRP';
3941
}
4042

src/transaction/trustline.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import type {Instructions, Prepare} from './types.js';
88
import type {TrustLineSpecification} from '../ledger/trustlines-types.js';
99

1010
function convertQuality(quality) {
11-
return quality === undefined ? undefined :
12-
(new BigNumber(quality)).shift(9).truncated().toNumber();
11+
return (new BigNumber(quality)).shift(9).truncated().toNumber();
1312
}
1413

1514
function createTrustlineTransaction(account: string,

0 commit comments

Comments
 (0)