mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
@@ -29,7 +29,6 @@ const orderbook = {
|
||||
};
|
||||
|
||||
function checkResult(expected, schemaName, response) {
|
||||
// console.log(JSON.stringify(response, null, 2));
|
||||
assert.deepEqual(response, expected);
|
||||
if (schemaName) {
|
||||
schemaValidator.schemaValidate(schemaName, response);
|
||||
@@ -202,6 +201,11 @@ describe('RippleAPI', function() {
|
||||
_.partial(checkResult, responses.getBalances, 'getBalances'));
|
||||
});
|
||||
|
||||
it('getBalanceSheet', function() {
|
||||
return this.api.getBalanceSheet(address).then(
|
||||
_.partial(checkResult, responses.getBalanceSheet, 'getBalanceSheet'));
|
||||
});
|
||||
|
||||
describe('getTransaction', () => {
|
||||
it('getTransaction - payment', function() {
|
||||
return this.api.getTransaction(hashes.VALID_TRANSACTION_HASH).then(
|
||||
|
||||
54
test/fixtures/api/responses/get-balance-sheet.json
vendored
Normal file
54
test/fixtures/api/responses/get-balance-sheet.json
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"balances": [
|
||||
{
|
||||
"counterparty": "rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ",
|
||||
"currency": "EUR",
|
||||
"value": "29826.1965999999"
|
||||
},
|
||||
{
|
||||
"counterparty": "rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ",
|
||||
"currency": "USD",
|
||||
"value": "10.0"
|
||||
},
|
||||
{
|
||||
"counterparty": "ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt",
|
||||
"currency": "USD",
|
||||
"value": "13857.70416"
|
||||
}
|
||||
],
|
||||
"assets": [
|
||||
{
|
||||
"counterparty": "r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH",
|
||||
"currency": "BTC",
|
||||
"value": "5444166510000000e-26"
|
||||
},
|
||||
{
|
||||
"counterparty": "r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH",
|
||||
"currency": "USD",
|
||||
"value": "100.0"
|
||||
},
|
||||
{
|
||||
"counterparty": "rwmUaXsWtXU4Z843xSYwgt1is97bgY8yj6",
|
||||
"currency": "BTC",
|
||||
"value": "8700000000000000e-30"
|
||||
}
|
||||
],
|
||||
"obligations": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "5908.324927635318"
|
||||
},
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "992471.7419793958"
|
||||
},
|
||||
{
|
||||
"currency": "GBP",
|
||||
"value": "4991.38706013193"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "1997134.20229482"
|
||||
}
|
||||
]
|
||||
}
|
||||
1
test/fixtures/api/responses/index.js
vendored
1
test/fixtures/api/responses/index.js
vendored
@@ -4,6 +4,7 @@ module.exports = {
|
||||
generateAddress: require('./generate-address.json'),
|
||||
getAccountInfo: require('./get-account-info.json'),
|
||||
getBalances: require('./get-balances.json'),
|
||||
getBalanceSheet: require('./get-balance-sheet.json'),
|
||||
getOrderbook: require('./get-orderbook.json'),
|
||||
getOrders: require('./get-orders.json'),
|
||||
getPaths: {
|
||||
|
||||
52
test/fixtures/api/rippled/gateway-balances.json
vendored
Normal file
52
test/fixtures/api/rippled/gateway-balances.json
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"id": 0,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"assets": {
|
||||
"r9F6wk8HkXrgYWoJ7fsv4VrUBVoqDVtzkH": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "5444166510000000e-26"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "100.0"
|
||||
}
|
||||
],
|
||||
"rwmUaXsWtXU4Z843xSYwgt1is97bgY8yj6": [
|
||||
{
|
||||
"currency": "BTC",
|
||||
"value": "8700000000000000e-30"
|
||||
}
|
||||
]
|
||||
},
|
||||
"balances": {
|
||||
"rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ": [
|
||||
{
|
||||
"currency": "EUR",
|
||||
"value": "29826.1965999999"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "10.0"
|
||||
}
|
||||
],
|
||||
"ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt": [
|
||||
{
|
||||
"currency": "USD",
|
||||
"value": "13857.70416"
|
||||
}
|
||||
]
|
||||
},
|
||||
"obligations": {
|
||||
"BTC": "5908.324927635318",
|
||||
"EUR": "992471.7419793958",
|
||||
"GBP": "4991.38706013193",
|
||||
"USD": "1997134.20229482"
|
||||
},
|
||||
"ledger_current_index": 9592219,
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
1
test/fixtures/api/rippled/index.js
vendored
1
test/fixtures/api/rippled/index.js
vendored
@@ -16,6 +16,7 @@ module.exports = {
|
||||
},
|
||||
account_offers: require('./account-offers'),
|
||||
account_tx: require('./account-tx'),
|
||||
gateway_balances: require('./gateway-balances'),
|
||||
book_offers: require('./book-offers'),
|
||||
server_info: require('./server-info'),
|
||||
server_info_error: require('./server-info-error'),
|
||||
|
||||
@@ -283,5 +283,9 @@ module.exports = function(port) {
|
||||
setTimeout(() => conn.send(response), 20);
|
||||
});
|
||||
|
||||
mock.on('request_gateway_balances', function(request, conn) {
|
||||
conn.send(createResponse(request, fixtures.gateway_balances));
|
||||
});
|
||||
|
||||
return mock;
|
||||
};
|
||||
|
||||
@@ -1966,6 +1966,22 @@ describe('Remote', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Construct gateway_balances request', function() {
|
||||
const request = remote.requestGatewayBalances({
|
||||
account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
|
||||
hotwallet: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5',
|
||||
strict: true
|
||||
});
|
||||
|
||||
assert.deepEqual(request.message, {
|
||||
command: 'gateway_balances',
|
||||
id: undefined,
|
||||
account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
|
||||
hotwallet: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5',
|
||||
strict: true
|
||||
});
|
||||
});
|
||||
|
||||
it('Construct Payment transaction', function() {
|
||||
const tx = remote.createTransaction('Payment', {
|
||||
account: TX_JSON.Account,
|
||||
|
||||
Reference in New Issue
Block a user