mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 20:55:48 +00:00
Add descriptions to JSON schemas and organize for documentation generation
This commit is contained in:
@@ -15,17 +15,6 @@ const utils = RippleAPI._PRIVATE.ledgerUtils;
|
||||
const ledgerClosed = require('./fixtures/rippled/ledger-close-newer');
|
||||
const schemaValidator = RippleAPI._PRIVATE.schemaValidator;
|
||||
|
||||
const orderbook = {
|
||||
base: {
|
||||
currency: 'USD',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
},
|
||||
counter: {
|
||||
currency: 'BTC',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
}
|
||||
};
|
||||
|
||||
function closeLedger(connection) {
|
||||
connection._ws.emit('message', JSON.stringify(ledgerClosed));
|
||||
}
|
||||
@@ -574,12 +563,13 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
|
||||
it('getOrderbook', function() {
|
||||
return this.api.getOrderbook(address, orderbook).then(
|
||||
return this.api.getOrderbook(address, requests.getOrderbook).then(
|
||||
_.partial(checkResult, responses.getOrderbook, 'getOrderbook'));
|
||||
});
|
||||
|
||||
it('getOrderbook - sorted so that best deals come first', function() {
|
||||
return this.api.getOrderbook(address, orderbook).then(data => {
|
||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
||||
.then(data => {
|
||||
const bidRates = data.bids.map(bid => bid.properties.makerExchangeRate);
|
||||
const askRates = data.asks.map(ask => ask.properties.makerExchangeRate);
|
||||
// makerExchangeRate = quality = takerPays.value/takerGets.value
|
||||
@@ -591,12 +581,13 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
|
||||
it('getOrderbook - currency & counterparty are correct', function() {
|
||||
return this.api.getOrderbook(address, orderbook).then(data => {
|
||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
||||
.then(data => {
|
||||
const orders = _.flatten([data.bids, data.asks]);
|
||||
_.forEach(orders, order => {
|
||||
const quantity = order.specification.quantity;
|
||||
const totalPrice = order.specification.totalPrice;
|
||||
const {base, counter} = orderbook;
|
||||
const {base, counter} = requests.getOrderbook;
|
||||
assert.strictEqual(quantity.currency, base.currency);
|
||||
assert.strictEqual(quantity.counterparty, base.counterparty);
|
||||
assert.strictEqual(totalPrice.currency, counter.currency);
|
||||
@@ -606,7 +597,8 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
|
||||
it('getOrderbook - direction is correct for bids and asks', function() {
|
||||
return this.api.getOrderbook(address, orderbook).then(data => {
|
||||
return this.api.getOrderbook(address, requests.getOrderbook)
|
||||
.then(data => {
|
||||
assert(_.every(data.bids, bid => bid.specification.direction === 'buy'));
|
||||
assert(_.every(data.asks, ask => ask.specification.direction === 'sell'));
|
||||
});
|
||||
|
||||
10
test/fixtures/requests/get-orderbook.json
vendored
Normal file
10
test/fixtures/requests/get-orderbook.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"base": {
|
||||
"currency": "USD",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"counter": {
|
||||
"currency": "BTC",
|
||||
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
}
|
||||
}
|
||||
1
test/fixtures/requests/index.js
vendored
1
test/fixtures/requests/index.js
vendored
@@ -31,6 +31,7 @@ module.exports = {
|
||||
NoPathsWithCurrencies: require('./getpaths/no-paths-with-currencies'),
|
||||
sendAll: require('./getpaths/send-all')
|
||||
},
|
||||
getOrderbook: require('./get-orderbook'),
|
||||
computeLedgerHash: {
|
||||
header: require('./compute-ledger-hash'),
|
||||
transactions: require('./compute-ledger-hash-transactions')
|
||||
|
||||
22
test/fixtures/responses/get-ledger-full.json
vendored
22
test/fixtures/responses/get-ledger-full.json
vendored
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"accepted": true,
|
||||
"closed": true,
|
||||
"stateHash": "2C23D15B6B549123FB351E4B5CDE81C564318EB845449CD43C3EA7953C4DB452",
|
||||
"closeTime": "2013-01-02T06:43:20.000Z",
|
||||
@@ -32,6 +31,27 @@
|
||||
"value": "10000"
|
||||
}
|
||||
}
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"fee": "0.00001",
|
||||
"balanceChanges": {
|
||||
"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "10000"
|
||||
}
|
||||
],
|
||||
"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-10000.00001"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"indexInLedger": 0,
|
||||
"ledgerVersion": 38129
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"accepted": true,
|
||||
"closed": true,
|
||||
"stateHash": "2FC964BBFE22DF77A132FE12B5D2B58A09226EBCA73EF2CFF5BE29E56B3315F5",
|
||||
"closeTime": "2014-01-01T00:03:30.000Z",
|
||||
@@ -17,7 +16,22 @@
|
||||
"address": "rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38",
|
||||
"sequence": 6478,
|
||||
"id": "FEEFC959B0351156F58A2275F5A6B37B07AA85CCCE2C4AF8A1342A0196A3CD4D",
|
||||
"specification": {}
|
||||
"specification": {},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"fee": "0.00001",
|
||||
"ledgerVersion": 4181996,
|
||||
"balanceChanges": {
|
||||
"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-0.00001"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"indexInLedger": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"rawTransactions": "[{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Fee\":\"10\",\"Flags\":0,\"Sequence\":6478,\"SigningPubKey\":\"02CAB6F3A798712136DB5F105A98B0DE27C99AEDB68500181706B087CF1B6D0F2D\",\"TransactionType\":\"AccountSet\",\"TxnSignature\":\"304402202144BD33CC30793455B0F90954576EEE80F13C4C73538D2AEE012564C48E522E02207A8A4AD2CF2B4DB549FB2F05D38E065B5DD1EAA386310698E5247F1BB515E99F\",\"hash\":\"FEEFC959B0351156F58A2275F5A6B37B07AA85CCCE2C4AF8A1342A0196A3CD4D\",\"metaData\":{\"AffectedNodes\":[{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"rEGy9CxMTFGXFgUHUMreTy2FbqArabGy38\",\"Balance\":\"403657865\",\"Flags\":0,\"OwnerCount\":2,\"Sequence\":6479},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"F64FAA4CAFDB9931DC06890FE30B4E29C32F7AD574FC7C3362B81265682BFAEA\",\"PreviousFields\":{\"Balance\":\"403657875\",\"Sequence\":6478},\"PreviousTxnID\":\"B257B95A637C6C396507AD0AE122161A849C701F065B67009BB939690DB74BC9\",\"PreviousTxnLgrSeq\":4181972}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"}}]"
|
||||
|
||||
1
test/fixtures/responses/get-ledger.json
vendored
1
test/fixtures/responses/get-ledger.json
vendored
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"accepted": true,
|
||||
"closed": true,
|
||||
"stateHash": "EC028EC32896D537ECCA18D18BEBE6AE99709FEFF9EF72DBD3A7819E918D8B96",
|
||||
"closeTime": "2014-09-24T21:21:50.000Z",
|
||||
|
||||
Reference in New Issue
Block a user