mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
build: Initial linting setup (#1560)
* sets up linting config and runs `yarn lint --fix` once, so that all changes will show up correctly in future PRs. * Note that there are still a lot of linter errors.
This commit is contained in:
committed by
Mayukha Vadari
parent
12cfed5c17
commit
8b95ee5fab
@@ -1,10 +1,12 @@
|
||||
import assert from 'assert-diff'
|
||||
import binary from 'ripple-binary-codec'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const {combine: REQUEST_FIXTURES} = requests
|
||||
const {combine: RESPONSE_FIXTURES} = responses
|
||||
import assert from "assert-diff";
|
||||
import binary from "ripple-binary-codec";
|
||||
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const { combine: REQUEST_FIXTURES } = requests;
|
||||
const { combine: RESPONSE_FIXTURES } = responses;
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -12,18 +14,18 @@ const {combine: RESPONSE_FIXTURES} = responses
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'combine': async (client, address) => {
|
||||
const combined = client.combine(REQUEST_FIXTURES.setDomain)
|
||||
assertResultMatch(combined, RESPONSE_FIXTURES.single, 'sign')
|
||||
async combine(client, address) {
|
||||
const combined = client.combine(REQUEST_FIXTURES.setDomain);
|
||||
assertResultMatch(combined, RESPONSE_FIXTURES.single, "sign");
|
||||
},
|
||||
|
||||
'combine - different transactions': async (client, address) => {
|
||||
const request = [REQUEST_FIXTURES.setDomain[0]]
|
||||
const tx = binary.decode(REQUEST_FIXTURES.setDomain[0])
|
||||
tx.Flags = 0
|
||||
request.push(binary.encode(tx))
|
||||
"combine - different transactions": async (client, address) => {
|
||||
const request = [REQUEST_FIXTURES.setDomain[0]];
|
||||
const tx = binary.decode(REQUEST_FIXTURES.setDomain[0]);
|
||||
tx.Flags = 0;
|
||||
request.push(binary.encode(tx));
|
||||
assert.throws(() => {
|
||||
client.combine(request)
|
||||
}, /txJSON is not the same for all signedTransactions/)
|
||||
}
|
||||
}
|
||||
client.combine(request);
|
||||
}, /txJSON is not the same for all signedTransactions/);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import {Client} from 'xrpl-local'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { Client } from "xrpl-local";
|
||||
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -8,22 +10,22 @@ import {Client} from 'xrpl-local'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'Client - implicit server port': () => {
|
||||
new Client('wss://s1.ripple.com')
|
||||
"Client - implicit server port": () => {
|
||||
new Client("wss://s1.ripple.com");
|
||||
},
|
||||
|
||||
'Client invalid options': () => {
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
assert.throws(() => new Client({invalid: true}))
|
||||
"Client invalid options": () => {
|
||||
// @ts-expect-error - This is intentionally invalid
|
||||
assert.throws(() => new Client({ invalid: true }));
|
||||
},
|
||||
|
||||
'Client valid options': () => {
|
||||
const client = new Client('wss://s:1')
|
||||
const privateConnectionUrl = (client.connection as any)._url
|
||||
assert.deepEqual(privateConnectionUrl, 'wss://s:1')
|
||||
"Client valid options": () => {
|
||||
const client = new Client("wss://s:1");
|
||||
const privateConnectionUrl = (client.connection as any)._url;
|
||||
assert.deepEqual(privateConnectionUrl, "wss://s:1");
|
||||
},
|
||||
|
||||
'Client invalid server uri': () => {
|
||||
assert.throws(() => new Client('wss//s:1'))
|
||||
}
|
||||
}
|
||||
"Client invalid server uri": () => {
|
||||
assert.throws(() => new Client("wss//s:1"));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import {Client} from '../../src'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { Client } from "../../src";
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -8,24 +9,24 @@ import {Client} from '../../src'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'returns address for public key': async (client, address) => {
|
||||
"returns address for public key": async (client, address) => {
|
||||
assert.equal(
|
||||
Client.deriveXAddress({
|
||||
publicKey:
|
||||
'035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06',
|
||||
"035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06",
|
||||
tag: false,
|
||||
test: false
|
||||
test: false,
|
||||
}),
|
||||
'XVZVpQj8YSVpNyiwXYSqvQoQqgBttTxAZwMcuJd4xteQHyt'
|
||||
)
|
||||
"XVZVpQj8YSVpNyiwXYSqvQoQqgBttTxAZwMcuJd4xteQHyt"
|
||||
);
|
||||
assert.equal(
|
||||
Client.deriveXAddress({
|
||||
publicKey:
|
||||
'035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06',
|
||||
"035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06",
|
||||
tag: false,
|
||||
test: true
|
||||
test: true,
|
||||
}),
|
||||
'TVVrSWtmQQssgVcmoMBcFQZKKf56QscyWLKnUyiuZW8ALU4'
|
||||
)
|
||||
}
|
||||
}
|
||||
"TVVrSWtmQQssgVcmoMBcFQZKKf56QscyWLKnUyiuZW8ALU4"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -7,13 +8,13 @@ import {TestSuite} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'RippleError with data': async (client, address) => {
|
||||
const error = new client.errors.RippleError('_message_', '_data_')
|
||||
assert.strictEqual(error.toString(), "[RippleError(_message_, '_data_')]")
|
||||
"RippleError with data": async (client, address) => {
|
||||
const error = new client.errors.RippleError("_message_", "_data_");
|
||||
assert.strictEqual(error.toString(), "[RippleError(_message_, '_data_')]");
|
||||
},
|
||||
|
||||
'NotFoundError default message': async (client, address) => {
|
||||
const error = new client.errors.NotFoundError()
|
||||
assert.strictEqual(error.toString(), '[NotFoundError(Not found)]')
|
||||
}
|
||||
}
|
||||
"NotFoundError default message": async (client, address) => {
|
||||
const error = new client.errors.NotFoundError();
|
||||
assert.strictEqual(error.toString(), "[NotFoundError(Not found)]");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// import {Client} from 'xrpl-local'
|
||||
// import requests from '../fixtures/requests'
|
||||
// import responses from '../fixtures/responses'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
// function checkSortingOfOrders(orders) {
|
||||
// let previousRate = '0'
|
||||
@@ -56,7 +56,6 @@ export default <TestSuite>{
|
||||
// counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
// }
|
||||
// }
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -88,7 +87,6 @@ export default <TestSuite>{
|
||||
// assert.deepEqual(orderbook, responses.getOrderbook.normal)
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'with XRP': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// base: {
|
||||
@@ -99,7 +97,6 @@ export default <TestSuite>{
|
||||
// currency: 'XRP'
|
||||
// }
|
||||
// }
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -131,7 +128,6 @@ export default <TestSuite>{
|
||||
// assert.deepEqual(orderbook, responses.getOrderbook.withXRP)
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'sample XRP/JPY book has orders sorted correctly': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// base: {
|
||||
@@ -143,9 +139,7 @@ export default <TestSuite>{
|
||||
// issuer: 'rB3gZey7VWHYRqJHLoHDEJXJ2pEPNieKiS'
|
||||
// }
|
||||
// }
|
||||
|
||||
// const myAddress = 'rE9qNjzJXpiUbVomdv7R4xhrXVeH2oVmGR'
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -178,7 +172,6 @@ export default <TestSuite>{
|
||||
// return checkSortingOfOrders(orderbook.asks)
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'sample USD/XRP book has orders sorted correctly': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// counter: {currency: 'XRP'},
|
||||
@@ -187,9 +180,7 @@ export default <TestSuite>{
|
||||
// counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
// }
|
||||
// }
|
||||
|
||||
// const myAddress = 'rE9qNjzJXpiUbVomdv7R4xhrXVeH2oVmGR'
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -224,7 +215,6 @@ export default <TestSuite>{
|
||||
// )
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'sorted so that best deals come first': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// base: {
|
||||
@@ -236,7 +226,6 @@ export default <TestSuite>{
|
||||
// counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
// }
|
||||
// }
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -265,7 +254,6 @@ export default <TestSuite>{
|
||||
// ...directOffers,
|
||||
// ...reverseOffers
|
||||
// ])
|
||||
|
||||
// const bidRates = orderbook.bids.map(
|
||||
// (bid) => bid.properties.makerExchangeRate
|
||||
// )
|
||||
@@ -279,7 +267,6 @@ export default <TestSuite>{
|
||||
// assert.deepEqual(askRates.map((x) => Number(x)).sort(), askRates)
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'currency & counterparty are correct': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// base: {
|
||||
@@ -291,7 +278,6 @@ export default <TestSuite>{
|
||||
// counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
// }
|
||||
// }
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -320,7 +306,6 @@ export default <TestSuite>{
|
||||
// ...directOffers,
|
||||
// ...reverseOffers
|
||||
// ])
|
||||
|
||||
// const orders = [...orderbook.bids, ...orderbook.asks]
|
||||
// orders.forEach((order) => {
|
||||
// const quantity = order.specification.quantity
|
||||
@@ -333,7 +318,6 @@ export default <TestSuite>{
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
|
||||
// 'direction is correct for bids and asks': async (client, address) => {
|
||||
// const orderbookInfo = {
|
||||
// base: {
|
||||
@@ -345,7 +329,6 @@ export default <TestSuite>{
|
||||
// counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
// }
|
||||
// }
|
||||
|
||||
// await Promise.all([
|
||||
// client.request({command: 'book_offers',
|
||||
// taker_gets: orderbookInfo.base,
|
||||
@@ -374,7 +357,6 @@ export default <TestSuite>{
|
||||
// ...directOffers,
|
||||
// ...reverseOffers
|
||||
// ])
|
||||
|
||||
// assert(
|
||||
// orderbook.bids.every((bid) => bid.specification.direction === 'buy')
|
||||
// )
|
||||
@@ -383,4 +365,4 @@ export default <TestSuite>{
|
||||
// )
|
||||
// })
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import rippledAccountLines from '../fixtures/rippled/accountLines'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import rippledAccountLines from "../fixtures/rippled/accountLines";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -9,54 +9,82 @@ import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getBalances': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
const result = await client.getBalances(address)
|
||||
assertResultMatch(result, responses.getBalances, 'getBalances')
|
||||
async getBalances(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const result = await client.getBalances(address);
|
||||
assertResultMatch(result, responses.getBalances, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit': async (client, address, mockRippled) => {
|
||||
const options = {limit: 3, ledgerVersion: 123456}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
const expectedResponse = responses.getBalances.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
"getBalances - limit": async (client, address, mockRippled) => {
|
||||
const options = { limit: 3, ledgerVersion: 123456 };
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const expectedResponse = responses.getBalances.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit & currency': async (client, address, mockRippled) => {
|
||||
const options = {currency: 'USD', limit: 3}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
"getBalances - limit & currency": async (client, address, mockRippled) => {
|
||||
const options = { currency: "USD", limit: 3 };
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const expectedResponse = responses.getBalances
|
||||
.filter((item) => item.currency === 'USD')
|
||||
.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
.filter((item) => item.currency === "USD")
|
||||
.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit & currency & issuer': async (client, address, mockRippled) => {
|
||||
"getBalances - limit & currency & issuer": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
const options = {
|
||||
currency: 'USD',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
limit: 3
|
||||
}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
|
||||
currency: "USD",
|
||||
counterparty: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
limit: 3,
|
||||
};
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
|
||||
const expectedResponse = responses.getBalances
|
||||
.filter(
|
||||
(item) =>
|
||||
item.currency === 'USD' &&
|
||||
item.counterparty === 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
item.currency === "USD" &&
|
||||
item.counterparty === "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
)
|
||||
.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
}
|
||||
}
|
||||
.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from 'assert-diff'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -8,54 +9,78 @@ import {TestSuite} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getFee': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '0.000012')
|
||||
async getFee(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
|
||||
'getFee default': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
client._feeCushion = undefined
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '0.000012')
|
||||
"getFee default": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
client._feeCushion = undefined as unknown as number;
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
|
||||
'getFee - high load_factor': async (client, address, mockRippled) => {
|
||||
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.highLoadFactor)
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '2')
|
||||
"getFee - high load_factor": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.highLoadFactor
|
||||
);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "2");
|
||||
},
|
||||
|
||||
'getFee - high load_factor with custom maxFeeXRP': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.highLoadFactor)
|
||||
"getFee - high load_factor with custom maxFeeXRP": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.highLoadFactor
|
||||
);
|
||||
// Ensure that overriding with high maxFeeXRP of '51540' causes no errors.
|
||||
// (fee will actually be 51539.607552)
|
||||
client._maxFeeXRP = '51540'
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '51539.607552')
|
||||
client._maxFeeXRP = "51540";
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "51539.607552");
|
||||
},
|
||||
|
||||
'getFee custom cushion': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
client._feeCushion = 1.4
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '0.000014')
|
||||
"getFee custom cushion": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
client._feeCushion = 1.4;
|
||||
const fee = await client.getFee();
|
||||
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.
|
||||
'getFee cushion less than 1.0': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
client._feeCushion = 0.9
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '0.000009')
|
||||
"getFee cushion less than 1.0": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
client._feeCushion = 0.9;
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000009");
|
||||
},
|
||||
|
||||
'getFee reporting': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
const fee = await client.getFee()
|
||||
assert.strictEqual(fee, '0.000012')
|
||||
}
|
||||
}
|
||||
"getFee reporting": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
const fee = await client.getFee();
|
||||
assert.strictEqual(fee, "0.000012");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import assert from 'assert-diff'
|
||||
import responses from '../fixtures/responses'
|
||||
import requests from '../fixtures/requests'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {TestSuite, assertResultMatch, assertRejects} from '../testUtils'
|
||||
import { BookOffersRequest } from '../../src'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { BookOffersRequest } from "../../src";
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite, assertResultMatch, assertRejects } from "../testUtils";
|
||||
// import BigNumber from 'bignumber.js'
|
||||
|
||||
// function checkSortingOfOrders(orders) {
|
||||
@@ -41,11 +42,17 @@ import { BookOffersRequest } from '../../src'
|
||||
// }
|
||||
|
||||
function isUSD(currency: string) {
|
||||
return currency === 'USD' || currency === '0000000000000000000000005553440000000000'
|
||||
return (
|
||||
currency === "USD" ||
|
||||
currency === "0000000000000000000000005553440000000000"
|
||||
);
|
||||
}
|
||||
|
||||
function isBTC(currency: string) {
|
||||
return currency === 'BTC' || currency === '0000000000000000000000004254430000000000'
|
||||
return (
|
||||
currency === "BTC" ||
|
||||
currency === "0000000000000000000000004254430000000000"
|
||||
);
|
||||
}
|
||||
|
||||
function normalRippledResponse(request: BookOffersRequest): object {
|
||||
@@ -53,23 +60,27 @@ function normalRippledResponse(request: BookOffersRequest): object {
|
||||
isBTC(request.taker_gets.currency) &&
|
||||
isUSD(request.taker_pays.currency)
|
||||
) {
|
||||
return rippled.book_offers.fabric.requestBookOffersBidsResponse(request)
|
||||
} else if (
|
||||
return rippled.book_offers.fabric.requestBookOffersBidsResponse(request);
|
||||
}
|
||||
if (
|
||||
isUSD(request.taker_gets.currency) &&
|
||||
isBTC(request.taker_pays.currency)
|
||||
) {
|
||||
return rippled.book_offers.fabric.requestBookOffersAsksResponse(request)
|
||||
return rippled.book_offers.fabric.requestBookOffersAsksResponse(request);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
function xrpRippledResponse(request: BookOffersRequest): object {
|
||||
if (request.taker_pays.issuer === 'rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw') {
|
||||
return rippled.book_offers.xrp_usd
|
||||
} else if (
|
||||
request.taker_gets.issuer === 'rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw'
|
||||
) {
|
||||
return rippled.book_offers.usd_xrp
|
||||
if (request.taker_pays.issuer === "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw") {
|
||||
return rippled.book_offers.xrp_usd;
|
||||
}
|
||||
if (request.taker_gets.issuer === "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw") {
|
||||
return rippled.book_offers.usd_xrp;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,34 +89,34 @@ function xrpRippledResponse(request: BookOffersRequest): object {
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'normal': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, normalRippledResponse)
|
||||
async normal(client, address, mockRippled) {
|
||||
mockRippled.addResponse({ command: "book_offers" }, normalRippledResponse);
|
||||
const response = await client.getOrderbook(
|
||||
address,
|
||||
requests.getOrderbook.normal,
|
||||
{limit: 20}
|
||||
)
|
||||
assertResultMatch(response, responses.getOrderbook.normal, 'getOrderbook')
|
||||
{ limit: 20 }
|
||||
);
|
||||
assertResultMatch(response, responses.getOrderbook.normal, "getOrderbook");
|
||||
},
|
||||
|
||||
'invalid options': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, normalRippledResponse)
|
||||
"invalid options": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "book_offers" }, normalRippledResponse);
|
||||
assertRejects(
|
||||
client.getOrderbook(address, requests.getOrderbook.normal, {
|
||||
// @ts-ignore
|
||||
invalid: 'options'
|
||||
// @ts-expect-error
|
||||
invalid: "options",
|
||||
}),
|
||||
client.errors.ValidationError
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'with XRP': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, xrpRippledResponse)
|
||||
"with XRP": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "book_offers" }, xrpRippledResponse);
|
||||
const response = await client.getOrderbook(
|
||||
address,
|
||||
requests.getOrderbook.withXRP
|
||||
)
|
||||
assertResultMatch(response, responses.getOrderbook.withXRP, 'getOrderbook')
|
||||
);
|
||||
assertResultMatch(response, responses.getOrderbook.withXRP, "getOrderbook");
|
||||
},
|
||||
|
||||
// 'sample XRP/JPY book has orders sorted correctly': async (client, address, mockRippled) => {
|
||||
@@ -140,55 +151,69 @@ export default <TestSuite>{
|
||||
// },
|
||||
|
||||
// WARNING: This test fails to catch the sorting bug, issue #766
|
||||
'sorted so that best deals come first [bad test]': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, normalRippledResponse)
|
||||
"sorted so that best deals come first [bad test]": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "book_offers" }, normalRippledResponse);
|
||||
const response = await client.getOrderbook(
|
||||
address,
|
||||
requests.getOrderbook.normal
|
||||
)
|
||||
);
|
||||
const bidRates = response.bids.map(
|
||||
(bid) => bid.properties.makerExchangeRate
|
||||
)
|
||||
);
|
||||
const askRates = response.asks.map(
|
||||
(ask) => ask.properties.makerExchangeRate
|
||||
)
|
||||
);
|
||||
// makerExchangeRate = quality = takerPays.value/takerGets.value
|
||||
// so the best deal for the taker is the lowest makerExchangeRate
|
||||
// bids and asks should be sorted so that the best deals come first
|
||||
assert.deepEqual(
|
||||
bidRates.sort((x) => Number(x)),
|
||||
bidRates
|
||||
)
|
||||
);
|
||||
assert.deepEqual(
|
||||
askRates.sort((x) => Number(x)),
|
||||
askRates
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'currency & counterparty are correct': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, normalRippledResponse)
|
||||
"currency & counterparty are correct": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "book_offers" }, normalRippledResponse);
|
||||
const response = await client.getOrderbook(
|
||||
address,
|
||||
requests.getOrderbook.normal
|
||||
)
|
||||
;[...response.bids, ...response.asks].forEach((order) => {
|
||||
const quantity = order.specification.quantity
|
||||
const totalPrice = order.specification.totalPrice
|
||||
const {base, counter} = requests.getOrderbook.normal
|
||||
assert.strictEqual(quantity.currency, base.currency)
|
||||
assert.strictEqual(quantity.counterparty, base.counterparty)
|
||||
assert.strictEqual(totalPrice.currency, counter.currency)
|
||||
assert.strictEqual(totalPrice.counterparty, counter.counterparty)
|
||||
})
|
||||
);
|
||||
[...response.bids, ...response.asks].forEach((order) => {
|
||||
const quantity = order.specification.quantity;
|
||||
const totalPrice = order.specification.totalPrice;
|
||||
const { base, counter } = requests.getOrderbook.normal;
|
||||
assert.strictEqual(quantity.currency, base.currency);
|
||||
assert.strictEqual(quantity.counterparty, base.counterparty);
|
||||
assert.strictEqual(totalPrice.currency, counter.currency);
|
||||
assert.strictEqual(totalPrice.counterparty, counter.counterparty);
|
||||
});
|
||||
},
|
||||
|
||||
'direction is correct for bids and asks': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'book_offers'}, normalRippledResponse)
|
||||
"direction is correct for bids and asks": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "book_offers" }, normalRippledResponse);
|
||||
const response = await client.getOrderbook(
|
||||
address,
|
||||
requests.getOrderbook.normal
|
||||
)
|
||||
assert(response.bids.every((bid) => bid.specification.direction === 'buy'))
|
||||
assert(response.asks.every((ask) => ask.specification.direction === 'sell'))
|
||||
}
|
||||
}
|
||||
);
|
||||
assert(response.bids.every((bid) => bid.specification.direction === "buy"));
|
||||
assert(
|
||||
response.asks.every((ask) => ask.specification.direction === "sell")
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import assert from 'assert-diff'
|
||||
import { assertRejects, TestSuite } from '../testUtils'
|
||||
import requests from '../fixtures/requests'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import addresses from "../fixtures/addresses.json";
|
||||
import requests from "../fixtures/requests";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, TestSuite } from "../testUtils";
|
||||
// import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import addresses from '../fixtures/addresses.json'
|
||||
const {getPaths: REQUEST_FIXTURES} = requests
|
||||
const { getPaths: REQUEST_FIXTURES } = requests;
|
||||
// const {getPaths: RESPONSE_FIXTURES} = responses
|
||||
|
||||
const rippledResponse = rippled.path_find.generate.generateIOUPaymentPaths(
|
||||
@@ -12,7 +13,7 @@ const rippledResponse = rippled.path_find.generate.generateIOUPaymentPaths(
|
||||
REQUEST_FIXTURES.normal.source.address,
|
||||
REQUEST_FIXTURES.normal.destination.address,
|
||||
REQUEST_FIXTURES.normal.destination.amount
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -46,12 +47,12 @@ export default <TestSuite>{
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.XrpToXrp)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToXrp, 'getPaths')
|
||||
// },
|
||||
'source with issuer': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"source with issuer": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.issuer),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
);
|
||||
},
|
||||
// 'XRP 2 XRP - not enough': async (client) => {
|
||||
// return assertRejects(
|
||||
@@ -59,52 +60,52 @@ export default <TestSuite>{
|
||||
// client.errors.NotFoundError
|
||||
// )
|
||||
// },
|
||||
'invalid PathFind': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"invalid PathFind": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
assert.throws(() => {
|
||||
client.getPaths(REQUEST_FIXTURES.invalid)
|
||||
}, /Cannot specify both source.amount/)
|
||||
client.getPaths(REQUEST_FIXTURES.invalid);
|
||||
}, /Cannot specify both source.amount/);
|
||||
},
|
||||
'does not accept currency': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"does not accept currency": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NotAcceptCurrency),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
);
|
||||
},
|
||||
'no paths': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"no paths": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPaths),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
);
|
||||
},
|
||||
'no paths source amount': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"no paths source amount": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPathsSource),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
);
|
||||
},
|
||||
'no paths with source currencies': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"no paths with source currencies": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPathsWithCurrencies),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
);
|
||||
},
|
||||
'error: srcActNotFound': async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ripple_path_find'}, rippledResponse)
|
||||
"error: srcActNotFound": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ripple_path_find" }, rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths({
|
||||
...REQUEST_FIXTURES.normal,
|
||||
source: {address: addresses.NOTFOUND}
|
||||
source: { address: addresses.NOTFOUND },
|
||||
}),
|
||||
client.errors.RippleError
|
||||
)
|
||||
);
|
||||
},
|
||||
// 'send all': async (client) => {
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.sendAll)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.sendAll, 'getPaths')
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import addresses from '../fixtures/addresses.json'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled/accountLines'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const {getTrustlines: RESPONSE_FIXTURES} = responses
|
||||
import addresses from "../fixtures/addresses.json";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled/accountLines";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const { getTrustlines: RESPONSE_FIXTURES } = responses;
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,46 +11,63 @@ const {getTrustlines: RESPONSE_FIXTURES} = responses
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getTrustlines - filtered': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippled.normal)
|
||||
const options = {currency: 'USD'}
|
||||
const result = await client.getTrustlines(address, options)
|
||||
assertResultMatch(result, RESPONSE_FIXTURES.filtered, 'getTrustlines')
|
||||
"getTrustlines - filtered": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "account_lines" }, rippled.normal);
|
||||
const options = { currency: "USD" };
|
||||
const result = await client.getTrustlines(address, options);
|
||||
assertResultMatch(result, RESPONSE_FIXTURES.filtered, "getTrustlines");
|
||||
},
|
||||
|
||||
'getTrustlines - more than 400 items': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippled.manyItems)
|
||||
const options = {limit: 401}
|
||||
const result = await client.getTrustlines(address, options)
|
||||
"getTrustlines - more than 400 items": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "account_lines" }, rippled.manyItems);
|
||||
const options = { limit: 401 };
|
||||
const result = await client.getTrustlines(address, options);
|
||||
assertResultMatch(
|
||||
result,
|
||||
RESPONSE_FIXTURES.moreThan400Items,
|
||||
'getTrustlines'
|
||||
)
|
||||
"getTrustlines"
|
||||
);
|
||||
},
|
||||
|
||||
'getTrustlines - no options': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippled.normal)
|
||||
await client.getTrustlines(address)
|
||||
"getTrustlines - no options": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "account_lines" }, rippled.normal);
|
||||
await client.getTrustlines(address);
|
||||
},
|
||||
|
||||
'getTrustlines - ripplingDisabled works properly': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippled.ripplingDisabled)
|
||||
const result = await client.getTrustlines(address)
|
||||
"getTrustlines - ripplingDisabled works properly": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippled.ripplingDisabled
|
||||
);
|
||||
const result = await client.getTrustlines(address);
|
||||
assertResultMatch(
|
||||
result,
|
||||
RESPONSE_FIXTURES.ripplingDisabled,
|
||||
'getTrustlines'
|
||||
)
|
||||
"getTrustlines"
|
||||
);
|
||||
},
|
||||
|
||||
'getTrustlines - ledger version option': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippled.manyItems)
|
||||
const result = await client.getTrustlines(addresses.FOURTH_ACCOUNT, {ledgerVersion: 5})
|
||||
"getTrustlines - ledger version option": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "account_lines" }, rippled.manyItems);
|
||||
const result = await client.getTrustlines(addresses.FOURTH_ACCOUNT, {
|
||||
ledgerVersion: 5,
|
||||
});
|
||||
assertResultMatch(
|
||||
result,
|
||||
RESPONSE_FIXTURES.moreThan400Items,
|
||||
'getTrustlines'
|
||||
)
|
||||
"getTrustlines"
|
||||
);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -8,29 +9,36 @@ import rippled from '../fixtures/rippled'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'returns true when there is another page': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ledger_data'}, rippled.ledger_data.first_page)
|
||||
// @ts-ignore
|
||||
const response = await client.request({command: 'ledger_data'})
|
||||
assert(client.hasNextPage(response))
|
||||
"returns true when there is another page": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_data" },
|
||||
rippled.ledger_data.first_page
|
||||
);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
assert(client.hasNextPage(response));
|
||||
},
|
||||
|
||||
'returns false when there are no more pages': async (client, address, mockRippled) => {
|
||||
const rippledResponse = function(request: Request) : object {
|
||||
if ('marker' in request) {
|
||||
return rippled.ledger_data.last_page
|
||||
} else {
|
||||
return rippled.ledger_data.first_page
|
||||
"returns false when there are no more pages": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
const rippledResponse = function (request: Request): object {
|
||||
if ("marker" in request) {
|
||||
return rippled.ledger_data.last_page;
|
||||
}
|
||||
}
|
||||
mockRippled.addResponse({command: 'ledger_data'}, rippledResponse)
|
||||
// @ts-ignore
|
||||
const response = await client.request({command: 'ledger_data'})
|
||||
return rippled.ledger_data.first_page;
|
||||
};
|
||||
mockRippled.addResponse({ command: "ledger_data" }, rippledResponse);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await client.requestNextPage(
|
||||
// @ts-ignore
|
||||
{command: 'ledger_data'},
|
||||
{ command: "ledger_data" },
|
||||
response
|
||||
)
|
||||
assert(!client.hasNextPage(responseNextPage))
|
||||
}
|
||||
}
|
||||
);
|
||||
assert(!client.hasNextPage(responseNextPage));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -7,9 +8,9 @@ import {TestSuite} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'disconnect & isConnected': async (client, address) => {
|
||||
assert.strictEqual(client.isConnected(), true)
|
||||
await client.disconnect()
|
||||
assert.strictEqual(client.isConnected(), false)
|
||||
}
|
||||
}
|
||||
"disconnect & isConnected": async (client, address) => {
|
||||
assert.strictEqual(client.isConnected(), true);
|
||||
await client.disconnect();
|
||||
assert.strictEqual(client.isConnected(), false);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import addresses from '../fixtures/addresses.json'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import addresses from "../fixtures/addresses.json";
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
export default <TestSuite>{
|
||||
'returns true for valid address': async (client, address) => {
|
||||
assert(client.isValidAddress('rLczgQHxPhWtjkaQqn3Q6UM8AbRbbRvs5K'))
|
||||
assert(client.isValidAddress(addresses.ACCOUNT_X))
|
||||
assert(client.isValidAddress(addresses.ACCOUNT_T))
|
||||
"returns true for valid address": async (client, address) => {
|
||||
assert(client.isValidAddress("rLczgQHxPhWtjkaQqn3Q6UM8AbRbbRvs5K"));
|
||||
assert(client.isValidAddress(addresses.ACCOUNT_X));
|
||||
assert(client.isValidAddress(addresses.ACCOUNT_T));
|
||||
},
|
||||
|
||||
'returns false for invalid address': async (client, address) => {
|
||||
assert(!client.isValidAddress('foobar'))
|
||||
assert(!client.isValidAddress(addresses.ACCOUNT_X.slice(0, -1)))
|
||||
assert(!client.isValidAddress(addresses.ACCOUNT_T.slice(1)))
|
||||
}
|
||||
}
|
||||
"returns false for invalid address": async (client, address) => {
|
||||
assert(!client.isValidAddress("foobar"));
|
||||
assert(!client.isValidAddress(addresses.ACCOUNT_X.slice(0, -1)));
|
||||
assert(!client.isValidAddress(addresses.ACCOUNT_T.slice(1)));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import assert from 'assert-diff'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
export default <TestSuite>{
|
||||
'returns true for valid secret': async (client, address) => {
|
||||
assert(client.isValidSecret('snsakdSrZSLkYpCXxfRkS4Sh96PMK'))
|
||||
"returns true for valid secret": async (client, address) => {
|
||||
assert(client.isValidSecret("snsakdSrZSLkYpCXxfRkS4Sh96PMK"));
|
||||
},
|
||||
|
||||
'returns false for invalid secret': async (client, address) => {
|
||||
assert(!client.isValidSecret('foobar'))
|
||||
}
|
||||
}
|
||||
"returns false for invalid secret": async (client, address) => {
|
||||
assert(!client.isValidSecret("foobar"));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,33 +11,51 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareCheckCancel': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async prepareCheckCancel(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareCheckCancel(
|
||||
address,
|
||||
requests.prepareCheckCancel.normal
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCancel.normal, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCancel.normal, "prepare");
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareCheckCancel(
|
||||
address,
|
||||
requests.prepareCheckCancel.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCancel.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCancel.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,45 +11,72 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareCheckCash amount': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareCheckCash amount": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareCheckCash(
|
||||
address,
|
||||
requests.prepareCheckCash.amount
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCash.amount, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCash.amount, "prepare");
|
||||
},
|
||||
|
||||
'prepareCheckCash deliverMin': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareCheckCash deliverMin": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareCheckCash(
|
||||
address,
|
||||
requests.prepareCheckCash.deliverMin
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCash.deliverMin, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCash.deliverMin, "prepare");
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareCheckCash(
|
||||
address,
|
||||
requests.prepareCheckCash.amount,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCash.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCash.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,50 +11,77 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareCheckCreate': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async prepareCheckCreate(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const result = await client.prepareCheckCreate(
|
||||
address,
|
||||
requests.prepareCheckCreate.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCreate.normal, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCreate.normal, "prepare");
|
||||
},
|
||||
|
||||
'prepareCheckCreate full': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareCheckCreate full": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareCheckCreate(
|
||||
address,
|
||||
requests.prepareCheckCreate.full
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCreate.full, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCreate.full, "prepare");
|
||||
},
|
||||
|
||||
'prepareCheckCreate with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareCheckCreate with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareCheckCreate(
|
||||
address,
|
||||
requests.prepareCheckCreate.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareCheckCreate.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(result, responses.prepareCheckCreate.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,58 +11,89 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareEscrowCancellation': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async prepareEscrowCancellation(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareEscrowCancellation(
|
||||
address,
|
||||
requests.prepareEscrowCancellation.normal,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowCancellation.normal,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'prepareEscrowCancellation with memos': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareEscrowCancellation with memos": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareEscrowCancellation(
|
||||
address,
|
||||
requests.prepareEscrowCancellation.memos
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowCancellation.memos,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareEscrowCancellation(
|
||||
address,
|
||||
requests.prepareEscrowCancellation.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowCancellation.ticket,
|
||||
'prepare'
|
||||
)
|
||||
}
|
||||
}
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
export const config = {
|
||||
// TODO: The mock server right now returns a hard-coded string, no matter
|
||||
// what "Account" value you pass. We'll need it to support more accurate
|
||||
// responses before we can turn these tests on.
|
||||
skipXAddress: true
|
||||
}
|
||||
skipXAddress: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -17,64 +18,108 @@ export const config = {
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareEscrowCreation': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async prepareEscrowCreation(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const result = await client.prepareEscrowCreation(
|
||||
address,
|
||||
requests.prepareEscrowCreation.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareEscrowCreation.normal, 'prepare')
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowCreation.normal,
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'prepareEscrowCreation full': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareEscrowCreation full": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareEscrowCreation(
|
||||
address,
|
||||
requests.prepareEscrowCreation.full
|
||||
)
|
||||
assertResultMatch(result, responses.prepareEscrowCreation.full, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareEscrowCreation.full, "prepare");
|
||||
},
|
||||
|
||||
'prepareEscrowCreation - invalid': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const escrow = Object.assign({}, requests.prepareEscrowCreation.full)
|
||||
delete escrow.amount // Make invalid
|
||||
"prepareEscrowCreation - invalid": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const escrow = { ...requests.prepareEscrowCreation.full };
|
||||
delete escrow.amount; // Make invalid
|
||||
await assertRejects(
|
||||
client.prepareEscrowCreation(address, escrow),
|
||||
client.errors.ValidationError,
|
||||
'instance.escrowCreation requires property "amount"'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000396',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000396",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareEscrowCreation(
|
||||
address,
|
||||
requests.prepareEscrowCreation.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareEscrowCreation.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowCreation.ticket,
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {TestSuite, assertRejects, assertResultMatch} from '../testUtils'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite, assertRejects, assertResultMatch } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,44 +11,75 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareEscrowExecution': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async prepareEscrowExecution(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareEscrowExecution(
|
||||
address,
|
||||
requests.prepareEscrowExecution.normal,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowExecution.normal,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'prepareEscrowExecution - simple': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareEscrowExecution - simple": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareEscrowExecution(
|
||||
address,
|
||||
requests.prepareEscrowExecution.simple
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowExecution.simple,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'prepareEscrowExecution - no condition': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareEscrowExecution - no condition": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
await assertRejects(
|
||||
client.prepareEscrowExecution(
|
||||
address,
|
||||
@@ -56,14 +88,27 @@ export default <TestSuite>{
|
||||
),
|
||||
client.errors.ValidationError,
|
||||
'"condition" and "fulfillment" fields on EscrowFinish must only be specified together.'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'prepareEscrowExecution - no fulfillment': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepareEscrowExecution - no fulfillment": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
await assertRejects(
|
||||
client.prepareEscrowExecution(
|
||||
address,
|
||||
@@ -72,28 +117,37 @@ export default <TestSuite>{
|
||||
),
|
||||
client.errors.ValidationError,
|
||||
'"condition" and "fulfillment" fields on EscrowFinish must only be specified together.'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000396',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000396",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareEscrowExecution(
|
||||
address,
|
||||
requests.prepareEscrowExecution.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareEscrowExecution.ticket,
|
||||
'prepare'
|
||||
)
|
||||
}
|
||||
}
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,52 +11,88 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'buy order': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrder.buy
|
||||
const result = await client.prepareOrder(address, request)
|
||||
assertResultMatch(result, responses.prepareOrder.buy, 'prepare')
|
||||
"buy order": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrder.buy;
|
||||
const result = await client.prepareOrder(address, request);
|
||||
assertResultMatch(result, responses.prepareOrder.buy, "prepare");
|
||||
},
|
||||
|
||||
'buy order with expiration': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrder.expiration
|
||||
const response = responses.prepareOrder.expiration
|
||||
"buy order with expiration": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrder.expiration;
|
||||
const response = responses.prepareOrder.expiration;
|
||||
const result = await client.prepareOrder(
|
||||
address,
|
||||
request,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(result, response, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, response, "prepare");
|
||||
},
|
||||
|
||||
'sell order': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrder.sell
|
||||
"sell order": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrder.sell;
|
||||
const result = await client.prepareOrder(
|
||||
address,
|
||||
request,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(result, responses.prepareOrder.sell, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareOrder.sell, "prepare");
|
||||
},
|
||||
|
||||
'invalid': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = Object.assign({}, requests.prepareOrder.sell)
|
||||
delete request.direction // Make invalid
|
||||
async invalid(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = { ...requests.prepareOrder.sell };
|
||||
delete request.direction; // Make invalid
|
||||
await assertRejects(
|
||||
client.prepareOrder(
|
||||
address,
|
||||
@@ -64,21 +101,34 @@ export default <TestSuite>{
|
||||
),
|
||||
client.errors.ValidationError,
|
||||
'instance.order requires property "direction"'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrder.sell
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrder.sell;
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
const result = await client.prepareOrder(address, request, localInstructions)
|
||||
assertResultMatch(result, responses.prepareOrder.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareOrder(
|
||||
address,
|
||||
request,
|
||||
localInstructions
|
||||
);
|
||||
assertResultMatch(result, responses.prepareOrder.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,90 +11,134 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'prepareOrderCancellation': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrderCancellation.simple
|
||||
async prepareOrderCancellation(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrderCancellation.simple;
|
||||
const result = await client.prepareOrderCancellation(
|
||||
address,
|
||||
request,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareOrderCancellation.normal,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'no instructions': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrderCancellation.simple
|
||||
const result = await client.prepareOrderCancellation(address, request)
|
||||
"no instructions": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrderCancellation.simple;
|
||||
const result = await client.prepareOrderCancellation(address, request);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareOrderCancellation.noInstructions,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'with memos': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrderCancellation.withMemos
|
||||
const result = await client.prepareOrderCancellation(address, request)
|
||||
"with memos": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrderCancellation.withMemos;
|
||||
const result = await client.prepareOrderCancellation(address, request);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareOrderCancellation.withMemos,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'invalid': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = Object.assign(
|
||||
{},
|
||||
requests.prepareOrderCancellation.withMemos
|
||||
)
|
||||
delete request.orderSequence // Make invalid
|
||||
async invalid(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = {
|
||||
...requests.prepareOrderCancellation.withMemos,
|
||||
};
|
||||
delete request.orderSequence; // Make invalid
|
||||
|
||||
await assertRejects(
|
||||
client.prepareOrderCancellation(address, request),
|
||||
client.errors.ValidationError,
|
||||
'instance.orderCancellation requires property "orderSequence"'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const request = requests.prepareOrderCancellation.simple
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const request = requests.prepareOrderCancellation.simple;
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareOrderCancellation(
|
||||
address,
|
||||
request,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareOrderCancellation.ticket,
|
||||
'prepare'
|
||||
)
|
||||
}
|
||||
}
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,13 @@
|
||||
import assert from 'assert-diff'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
const {preparePaymentChannelClaim: REQUEST_FIXTURES} = requests
|
||||
const {preparePaymentChannelClaim: RESPONSE_FIXTURES} = responses
|
||||
import assert from "assert-diff";
|
||||
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
const { preparePaymentChannelClaim: REQUEST_FIXTURES } = requests;
|
||||
const { preparePaymentChannelClaim: RESPONSE_FIXTURES } = responses;
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -13,126 +15,182 @@ const {preparePaymentChannelClaim: RESPONSE_FIXTURES} = responses
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'default': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async default(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const response = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.normal, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.normal, "prepare");
|
||||
},
|
||||
|
||||
'with renew': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with renew": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const response = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.renew,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.renew, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.renew, "prepare");
|
||||
},
|
||||
|
||||
'with close': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with close": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const response = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.close,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.close, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.close, "prepare");
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const response = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.normal,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.ticket, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.ticket, "prepare");
|
||||
},
|
||||
|
||||
'rejects Promise on preparePaymentChannelClaim with renew and close': async (
|
||||
"rejects Promise on preparePaymentChannelClaim with renew and close": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
try {
|
||||
const prepared = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.full
|
||||
)
|
||||
);
|
||||
throw new Error(
|
||||
'Expected method to reject. Prepared transaction: ' +
|
||||
JSON.stringify(prepared)
|
||||
)
|
||||
`Expected method to reject. Prepared transaction: ${JSON.stringify(
|
||||
prepared
|
||||
)}`
|
||||
);
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.name, 'ValidationError')
|
||||
assert.strictEqual(err.name, "ValidationError");
|
||||
assert.strictEqual(
|
||||
err.message,
|
||||
'"renew" and "close" flags on PaymentChannelClaim are mutually exclusive'
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
'rejects Promise on preparePaymentChannelClaim with no signature': async (
|
||||
"rejects Promise on preparePaymentChannelClaim with no signature": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
try {
|
||||
const prepared = await client.preparePaymentChannelClaim(
|
||||
address,
|
||||
REQUEST_FIXTURES.noSignature
|
||||
)
|
||||
);
|
||||
throw new Error(
|
||||
'Expected method to reject. Prepared transaction: ' +
|
||||
JSON.stringify(prepared)
|
||||
)
|
||||
`Expected method to reject. Prepared transaction: ${JSON.stringify(
|
||||
prepared
|
||||
)}`
|
||||
);
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.name, 'ValidationError')
|
||||
assert.strictEqual(err.name, "ValidationError");
|
||||
assert.strictEqual(
|
||||
err.message,
|
||||
'"signature" and "publicKey" fields on PaymentChannelClaim must only be specified together.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
export const config = {
|
||||
// TODO: The mock server right now returns a hard-coded string, no matter
|
||||
// what "Account" value you pass. We'll need it to support more accurate
|
||||
// responses before we can turn these tests on.
|
||||
skipXAddress: true
|
||||
}
|
||||
skipXAddress: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -17,62 +18,93 @@ export const config = {
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'preparePaymentChannelCreate': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async preparePaymentChannelCreate(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const result = await client.preparePaymentChannelCreate(
|
||||
address,
|
||||
requests.preparePaymentChannelCreate.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelCreate.normal,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'preparePaymentChannelCreate full': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"preparePaymentChannelCreate full": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.preparePaymentChannelCreate(
|
||||
address,
|
||||
requests.preparePaymentChannelCreate.full
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelCreate.full,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'preparePaymentChannelCreate with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"preparePaymentChannelCreate with ticket": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.preparePaymentChannelCreate(
|
||||
address,
|
||||
requests.preparePaymentChannelCreate.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelCreate.ticket,
|
||||
'prepare'
|
||||
)
|
||||
}
|
||||
}
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,62 +11,89 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'preparePaymentChannelFund': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async preparePaymentChannelFund(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012'
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
};
|
||||
const result = await client.preparePaymentChannelFund(
|
||||
address,
|
||||
requests.preparePaymentChannelFund.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelFund.normal,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'preparePaymentChannelFund full': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"preparePaymentChannelFund full": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.preparePaymentChannelFund(
|
||||
address,
|
||||
requests.preparePaymentChannelFund.full
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelFund.full,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.preparePaymentChannelFund(
|
||||
address,
|
||||
requests.preparePaymentChannelFund.normal,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.preparePaymentChannelFund.ticket,
|
||||
'prepare'
|
||||
)
|
||||
}
|
||||
}
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import assert from 'assert-diff'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import assert from "assert-diff";
|
||||
|
||||
import { FormattedSettings } from "../../src/common/types/objects";
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -11,334 +14,513 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'simple test': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"simple test": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
requests.prepareSettings.domain,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.flags, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.flags, "prepare");
|
||||
},
|
||||
'no maxLedgerVersion': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"no maxLedgerVersion": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
requests.prepareSettings.domain,
|
||||
{
|
||||
maxLedgerVersion: null
|
||||
maxLedgerVersion: null as unknown as undefined,
|
||||
}
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.noMaxLedgerVersion,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'no instructions': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"no instructions": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
requests.prepareSettings.domain
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.noInstructions,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'regularKey': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'}
|
||||
async regularKey(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const regularKey = { regularKey: "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD" };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
regularKey,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.regularKey, 'prepare')
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.regularKey,
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'remove regularKey': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const regularKey = {regularKey: null}
|
||||
"remove regularKey": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const regularKey = { regularKey: null };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
regularKey,
|
||||
regularKey as unknown as FormattedSettings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.removeRegularKey,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'flag set': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {requireDestinationTag: true}
|
||||
"flag set": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { requireDestinationTag: true };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.flagSet, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.flagSet, "prepare");
|
||||
},
|
||||
'flag clear': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {requireDestinationTag: false}
|
||||
"flag clear": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { requireDestinationTag: false };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.flagClear, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.flagClear, "prepare");
|
||||
},
|
||||
'set depositAuth flag': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {depositAuth: true}
|
||||
"set depositAuth flag": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { depositAuth: true };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.flagSetDepositAuth,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'clear depositAuth flag': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {depositAuth: false}
|
||||
"clear depositAuth flag": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { depositAuth: false };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.flagClearDepositAuth,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'integer field clear': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {transferRate: null}
|
||||
"integer field clear": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { transferRate: null };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assert(response)
|
||||
assert.strictEqual(JSON.parse(response.txJSON).TransferRate, 0)
|
||||
);
|
||||
assert(response);
|
||||
assert.strictEqual(JSON.parse(response.txJSON).TransferRate, 0);
|
||||
},
|
||||
'set transferRate': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = {transferRate: 1}
|
||||
"set transferRate": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = { transferRate: 1 };
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.setTransferRate,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'set signers': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = requests.prepareSettings.signers.normal
|
||||
"set signers": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = requests.prepareSettings.signers.normal;
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.signers, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.signers, "prepare");
|
||||
},
|
||||
'signers no threshold': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = requests.prepareSettings.signers.noThreshold
|
||||
"signers no threshold": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = requests.prepareSettings.signers.noThreshold;
|
||||
try {
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
);
|
||||
throw new Error(
|
||||
'Expected method to reject. Prepared transaction: ' +
|
||||
JSON.stringify(response)
|
||||
)
|
||||
`Expected method to reject. Prepared transaction: ${JSON.stringify(
|
||||
response
|
||||
)}`
|
||||
);
|
||||
} catch (err) {
|
||||
assert.strictEqual(
|
||||
err.message,
|
||||
'instance.settings.signers requires property "threshold"'
|
||||
)
|
||||
assert.strictEqual(err.name, 'ValidationError')
|
||||
);
|
||||
assert.strictEqual(err.name, "ValidationError");
|
||||
}
|
||||
},
|
||||
'signers no weights': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = requests.prepareSettings.signers.noWeights
|
||||
"signers no weights": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = requests.prepareSettings.signers.noWeights;
|
||||
const localInstructions = {
|
||||
signersCount: 1,
|
||||
...instructionsWithMaxLedgerVersionOffset
|
||||
}
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
};
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.noWeights, 'prepare')
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.noWeights, "prepare");
|
||||
},
|
||||
'fee for multisign': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"fee for multisign": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
signersCount: 4,
|
||||
...instructionsWithMaxLedgerVersionOffset
|
||||
}
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
};
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
requests.prepareSettings.domain,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.flagsMultisign,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'no signer list': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const settings = requests.prepareSettings.noSignerEntries
|
||||
"no signer list": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const settings = requests.prepareSettings.noSignerEntries;
|
||||
const localInstructions = {
|
||||
signersCount: 1,
|
||||
...instructionsWithMaxLedgerVersionOffset
|
||||
}
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
};
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
assertResultMatch(
|
||||
response,
|
||||
responses.prepareSettings.noSignerList,
|
||||
'prepare'
|
||||
)
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
'invalid': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async invalid(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
// domain must be a string
|
||||
const settings = Object.assign({}, requests.prepareSettings.domain, {
|
||||
domain: 123
|
||||
})
|
||||
const settings = { ...requests.prepareSettings.domain, domain: 123 };
|
||||
const localInstructions = {
|
||||
signersCount: 4,
|
||||
...instructionsWithMaxLedgerVersionOffset
|
||||
}
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
localInstructions
|
||||
)
|
||||
);
|
||||
throw new Error(
|
||||
'Expected method to reject. Prepared transaction: ' +
|
||||
JSON.stringify(response)
|
||||
)
|
||||
`Expected method to reject. Prepared transaction: ${JSON.stringify(
|
||||
response
|
||||
)}`
|
||||
);
|
||||
} catch (err) {
|
||||
assert.strictEqual(
|
||||
err.message,
|
||||
'instance.settings.domain is not of a type(s) string'
|
||||
)
|
||||
assert.strictEqual(err.name, 'ValidationError')
|
||||
"instance.settings.domain is not of a type(s) string"
|
||||
);
|
||||
assert.strictEqual(err.name, "ValidationError");
|
||||
}
|
||||
},
|
||||
'offline': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
async offline(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
|
||||
const settings = requests.prepareSettings.domain
|
||||
const settings = requests.prepareSettings.domain;
|
||||
const instructions = {
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051,
|
||||
fee: '0.000012'
|
||||
}
|
||||
const result = await client.prepareSettings(address, settings, instructions)
|
||||
assertResultMatch(result, responses.prepareSettings.flags, 'prepare')
|
||||
fee: "0.000012",
|
||||
};
|
||||
const result = await client.prepareSettings(
|
||||
address,
|
||||
settings,
|
||||
instructions
|
||||
);
|
||||
assertResultMatch(result, responses.prepareSettings.flags, "prepare");
|
||||
assert.deepEqual(
|
||||
client.sign(result.txJSON, secret),
|
||||
responses.prepareSettings.signed
|
||||
)
|
||||
);
|
||||
},
|
||||
'prepare settings with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"prepare settings with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const instructions = {
|
||||
ticketSequence: 23,
|
||||
maxLedgerVersion: 8820051,
|
||||
fee: '0.000012'
|
||||
}
|
||||
fee: "0.000012",
|
||||
};
|
||||
const response = await client.prepareSettings(
|
||||
address,
|
||||
requests.prepareSettings.domain,
|
||||
instructions
|
||||
)
|
||||
assertResultMatch(response, responses.prepareSettings.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(response, responses.prepareSettings.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
// import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
// import requests from '../fixtures/requests'
|
||||
// import {ValidationError} from 'xrpl-local/common/errors'
|
||||
// import binary from 'ripple-binary-codec'
|
||||
@@ -19,48 +19,70 @@ import rippled from '../fixtures/rippled'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'creates a ticket successfully with a sequence number': async (
|
||||
"creates a ticket successfully with a sequence number": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const expected = {
|
||||
txJSON:
|
||||
'{"TransactionType":"TicketCreate", "TicketCount": 2, "Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Flags":2147483648,"LastLedgerSequence":8819954,"Sequence":23,"Fee":"12"}',
|
||||
instructions: {
|
||||
maxLedgerVersion: 8819954,
|
||||
sequence: 23,
|
||||
fee: '0.000012'
|
||||
}
|
||||
}
|
||||
const response = await client.prepareTicketCreate(address, 2)
|
||||
assertResultMatch(response, expected, 'prepare')
|
||||
fee: "0.000012",
|
||||
},
|
||||
};
|
||||
const response = await client.prepareTicketCreate(address, 2);
|
||||
assertResultMatch(response, expected, "prepare");
|
||||
},
|
||||
|
||||
'creates a ticket successfully with another ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"creates a ticket successfully with another ticket": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const expected = {
|
||||
txJSON:
|
||||
'{"TransactionType":"TicketCreate", "TicketCount": 1, "Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Flags":2147483648,"LastLedgerSequence":8819954,"Sequence": 0,"TicketSequence":23,"Fee":"12"}',
|
||||
instructions: {
|
||||
maxLedgerVersion: 8819954,
|
||||
ticketSequence: 23,
|
||||
fee: '0.000012'
|
||||
}
|
||||
}
|
||||
fee: "0.000012",
|
||||
},
|
||||
};
|
||||
const instructions = {
|
||||
maxLedgerVersion: 8819954,
|
||||
ticketSequence: 23,
|
||||
fee: '0.000012'
|
||||
}
|
||||
const response = await client.prepareTicketCreate(address, 1, instructions)
|
||||
assertResultMatch(response, expected, 'prepare')
|
||||
}
|
||||
}
|
||||
fee: "0.000012",
|
||||
};
|
||||
const response = await client.prepareTicketCreate(address, 1, instructions);
|
||||
assertResultMatch(response, expected, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../testUtils'
|
||||
const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -10,51 +11,87 @@ const instructionsWithMaxLedgerVersionOffset = {maxLedgerVersionOffset: 100}
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'simple': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async simple(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareTrustline(
|
||||
address,
|
||||
requests.prepareTrustline.simple,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(result, responses.prepareTrustline.simple, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareTrustline.simple, "prepare");
|
||||
},
|
||||
|
||||
'frozen': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async frozen(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareTrustline(
|
||||
address,
|
||||
requests.prepareTrustline.frozen
|
||||
)
|
||||
assertResultMatch(result, responses.prepareTrustline.frozen, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareTrustline.frozen, "prepare");
|
||||
},
|
||||
|
||||
'complex': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
async complex(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareTrustline(
|
||||
address,
|
||||
requests.prepareTrustline.complex,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(result, responses.prepareTrustline.complex, 'prepare')
|
||||
);
|
||||
assertResultMatch(result, responses.prepareTrustline.complex, "prepare");
|
||||
},
|
||||
|
||||
'invalid': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const trustline = Object.assign({}, requests.prepareTrustline.complex)
|
||||
delete trustline.limit // Make invalid
|
||||
async invalid(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const trustline = { ...requests.prepareTrustline.complex };
|
||||
delete trustline.limit; // Make invalid
|
||||
|
||||
await assertRejects(
|
||||
client.prepareTrustline(
|
||||
@@ -64,37 +101,59 @@ export default <TestSuite>{
|
||||
),
|
||||
client.errors.ValidationError,
|
||||
'instance.trustline requires property "limit"'
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
'xaddress-issuer': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"xaddress-issuer": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const result = await client.prepareTrustline(
|
||||
address,
|
||||
requests.prepareTrustline.issuedXAddress,
|
||||
instructionsWithMaxLedgerVersionOffset
|
||||
)
|
||||
assertResultMatch(result, responses.prepareTrustline.issuedXAddress, 'prepare')
|
||||
);
|
||||
assertResultMatch(
|
||||
result,
|
||||
responses.prepareTrustline.issuedXAddress,
|
||||
"prepare"
|
||||
);
|
||||
},
|
||||
|
||||
'with ticket': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"with ticket": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const localInstructions = {
|
||||
...instructionsWithMaxLedgerVersionOffset,
|
||||
maxFee: '0.000012',
|
||||
ticketSequence: 23
|
||||
}
|
||||
maxFee: "0.000012",
|
||||
ticketSequence: 23,
|
||||
};
|
||||
const result = await client.prepareTrustline(
|
||||
address,
|
||||
requests.prepareTrustline.simple,
|
||||
localInstructions
|
||||
)
|
||||
assertResultMatch(result, responses.prepareTrustline.ticket, 'prepare')
|
||||
}
|
||||
}
|
||||
);
|
||||
assertResultMatch(result, responses.prepareTrustline.ticket, "prepare");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {TestSuite, assertResultMatch} from '../testUtils'
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite, assertResultMatch } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -8,31 +8,41 @@ import {TestSuite, assertResultMatch} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'request account_objects': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_objects', account: address}, rippled.account_objects.normal)
|
||||
const result = await client.request({command: 'account_objects',
|
||||
account: address
|
||||
})
|
||||
"request account_objects": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_objects", account: address },
|
||||
rippled.account_objects.normal
|
||||
);
|
||||
const result = await client.request({
|
||||
command: "account_objects",
|
||||
account: address,
|
||||
});
|
||||
|
||||
assertResultMatch(
|
||||
result.result,
|
||||
responses.getAccountObjects,
|
||||
'AccountObjectsResponse'
|
||||
)
|
||||
"AccountObjectsResponse"
|
||||
);
|
||||
},
|
||||
|
||||
'request account_objects - invalid options': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_objects', account: address}, rippled.account_objects.normal)
|
||||
// @ts-ignore Intentionally no local validation of these options
|
||||
const result = await client.request({command: 'account_objects',
|
||||
"request account_objects - invalid options": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_objects", account: address },
|
||||
rippled.account_objects.normal
|
||||
);
|
||||
const result = await client.request({
|
||||
command: "account_objects",
|
||||
account: address,
|
||||
invalid: 'options'
|
||||
})
|
||||
});
|
||||
|
||||
assertResultMatch(
|
||||
result.result,
|
||||
responses.getAccountObjects,
|
||||
'AccountObjectsResponse'
|
||||
)
|
||||
}
|
||||
}
|
||||
"AccountObjectsResponse"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import assert from 'assert-diff'
|
||||
import {assertRejects, TestSuite} from '../testUtils'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import assert from "assert-diff";
|
||||
|
||||
const rippledResponse = function(request: Request) : object {
|
||||
if ('marker' in request) {
|
||||
return rippled.ledger_data.last_page
|
||||
} else {
|
||||
return rippled.ledger_data.first_page
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, TestSuite } from "../testUtils";
|
||||
|
||||
const rippledResponse = function (request: Request): object {
|
||||
if ("marker" in request) {
|
||||
return rippled.ledger_data.last_page;
|
||||
}
|
||||
}
|
||||
return rippled.ledger_data.first_page;
|
||||
};
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -16,37 +16,35 @@ const rippledResponse = function(request: Request) : object {
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'requests the next page': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ledger_data'}, rippledResponse)
|
||||
// @ts-ignore
|
||||
const response = await client.request({command: 'ledger_data'})
|
||||
"requests the next page": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({ command: "ledger_data" }, rippledResponse);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await client.requestNextPage(
|
||||
// @ts-ignore
|
||||
{command: 'ledger_data'},
|
||||
{ command: "ledger_data" },
|
||||
response
|
||||
)
|
||||
);
|
||||
assert.equal(
|
||||
// @ts-ignore
|
||||
responseNextPage.result.state[0].index,
|
||||
'000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D731'
|
||||
)
|
||||
"000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D731"
|
||||
);
|
||||
},
|
||||
|
||||
'rejects when there are no more pages': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'ledger_data'}, rippledResponse)
|
||||
// @ts-ignore
|
||||
const response = await client.request({command: 'ledger_data'})
|
||||
"rejects when there are no more pages": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({ command: "ledger_data" }, rippledResponse);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await client.requestNextPage(
|
||||
// @ts-ignore
|
||||
{command: 'ledger_data'},
|
||||
{ command: "ledger_data" },
|
||||
response
|
||||
)
|
||||
assert(!client.hasNextPage(responseNextPage))
|
||||
);
|
||||
assert(!client.hasNextPage(responseNextPage));
|
||||
await assertRejects(
|
||||
// @ts-ignore
|
||||
client.requestNextPage({command: 'ledger_data'}, responseNextPage),
|
||||
client.requestNextPage({ command: "ledger_data" }, responseNextPage),
|
||||
Error,
|
||||
'response does not have a next page'
|
||||
)
|
||||
}
|
||||
}
|
||||
"response does not have a next page"
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import assert from 'assert-diff'
|
||||
import binary from 'ripple-binary-codec'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {TestSuite} from '../testUtils'
|
||||
import * as schemaValidator from 'xrpl-local/common/schema-validator'
|
||||
import assert from "assert-diff";
|
||||
import binary from "ripple-binary-codec";
|
||||
|
||||
const {sign: REQUEST_FIXTURES} = requests
|
||||
const {sign: RESPONSE_FIXTURES} = responses
|
||||
import * as schemaValidator from "xrpl-local/common/schema-validator";
|
||||
|
||||
import requests from "../fixtures/requests";
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { TestSuite } from "../testUtils";
|
||||
|
||||
const { sign: REQUEST_FIXTURES } = requests;
|
||||
const { sign: RESPONSE_FIXTURES } = responses;
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -15,413 +17,453 @@ const {sign: RESPONSE_FIXTURES} = responses
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'sign': async (client, address) => {
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, secret)
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.normal)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
async sign(client, address) {
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, secret);
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.normal);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'sign with lowercase hex data in memo (hex should be case insensitive)': async (client, address) => {
|
||||
const secret = 'shd2nxpFD6iBRKWsRss2P4tKMWyy9';
|
||||
const lowercaseMemoTxJson = {
|
||||
"TransactionType" : "Payment",
|
||||
"Flags" : 2147483648,
|
||||
"Account" : "rwiZ3q3D3QuG4Ga2HyGdq3kPKJRGctVG8a",
|
||||
"Amount" : "10000000",
|
||||
"LastLedgerSequence": 14000999,
|
||||
"Destination" : "rUeEBYXHo8vF86Rqir3zWGRQ84W9efdAQd",
|
||||
"Fee" : "12",
|
||||
"Sequence" : 12,
|
||||
"SourceTag" : 8888,
|
||||
"DestinationTag" : 9999,
|
||||
"Memos" : [
|
||||
{
|
||||
"Memo": {
|
||||
"MemoType" :"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
|
||||
"MemoData" :"72656e74"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"sign with lowercase hex data in memo (hex should be case insensitive)":
|
||||
async (client, address) => {
|
||||
const secret = "shd2nxpFD6iBRKWsRss2P4tKMWyy9";
|
||||
const lowercaseMemoTxJson = {
|
||||
TransactionType: "Payment",
|
||||
Flags: 2147483648,
|
||||
Account: "rwiZ3q3D3QuG4Ga2HyGdq3kPKJRGctVG8a",
|
||||
Amount: "10000000",
|
||||
LastLedgerSequence: 14000999,
|
||||
Destination: "rUeEBYXHo8vF86Rqir3zWGRQ84W9efdAQd",
|
||||
Fee: "12",
|
||||
Sequence: 12,
|
||||
SourceTag: 8888,
|
||||
DestinationTag: 9999,
|
||||
Memos: [
|
||||
{
|
||||
Memo: {
|
||||
MemoType:
|
||||
"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
|
||||
MemoData: "72656e74",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const txParams = JSON.stringify(lowercaseMemoTxJson);
|
||||
const result = client.sign(txParams, secret);
|
||||
assert.deepEqual(result, {
|
||||
signedTransaction: '120000228000000023000022B8240000000C2E0000270F201B00D5A36761400000000098968068400000000000000C73210305E09ED602D40AB1AF65646A4007C2DAC17CB6CDACDE301E74FB2D728EA057CF744730450221009C00E8439E017CA622A5A1EE7643E26B4DE9C808DE2ABE45D33479D49A4CEC66022062175BE8733442FA2A4D9A35F85A57D58252AE7B19A66401FE238B36FA28E5A081146C1856D0E36019EA75C56D7E8CBA6E35F9B3F71583147FB49CD110A1C46838788CD12764E3B0F837E0DDF9EA7C1F687474703A2F2F6578616D706C652E636F6D2F6D656D6F2F67656E657269637D0472656E74E1F1',
|
||||
id: '41B9CB78D8E18A796CDD4B0BC6FB0EA19F64C4F25FDE23049197852CAB71D10D'
|
||||
})
|
||||
},
|
||||
const txParams = JSON.stringify(lowercaseMemoTxJson);
|
||||
const result = client.sign(txParams, secret);
|
||||
assert.deepEqual(result, {
|
||||
signedTransaction:
|
||||
"120000228000000023000022B8240000000C2E0000270F201B00D5A36761400000000098968068400000000000000C73210305E09ED602D40AB1AF65646A4007C2DAC17CB6CDACDE301E74FB2D728EA057CF744730450221009C00E8439E017CA622A5A1EE7643E26B4DE9C808DE2ABE45D33479D49A4CEC66022062175BE8733442FA2A4D9A35F85A57D58252AE7B19A66401FE238B36FA28E5A081146C1856D0E36019EA75C56D7E8CBA6E35F9B3F71583147FB49CD110A1C46838788CD12764E3B0F837E0DDF9EA7C1F687474703A2F2F6578616D706C652E636F6D2F6D656D6F2F67656E657269637D0472656E74E1F1",
|
||||
id: "41B9CB78D8E18A796CDD4B0BC6FB0EA19F64C4F25FDE23049197852CAB71D10D",
|
||||
});
|
||||
},
|
||||
|
||||
'sign with paths': async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
"sign with paths": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const payment = {
|
||||
source: {
|
||||
address: address,
|
||||
address,
|
||||
amount: {
|
||||
currency: 'drops',
|
||||
value: '100'
|
||||
}
|
||||
currency: "drops",
|
||||
value: "100",
|
||||
},
|
||||
},
|
||||
destination: {
|
||||
address: 'rKT4JX4cCof6LcDYRz8o3rGRu7qxzZ2Zwj',
|
||||
address: "rKT4JX4cCof6LcDYRz8o3rGRu7qxzZ2Zwj",
|
||||
minAmount: {
|
||||
currency: 'USD',
|
||||
value: '0.00004579644712312366',
|
||||
counterparty: 'rVnYNK9yuxBz4uP8zC8LEFokM2nqH3poc'
|
||||
}
|
||||
currency: "USD",
|
||||
value: "0.00004579644712312366",
|
||||
counterparty: "rVnYNK9yuxBz4uP8zC8LEFokM2nqH3poc",
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
paths: '[[{\"currency\":\"USD\",\"issuer\":\"rVnYNK9yuxBz4uP8zC8LEFokM2nqH3poc\"}]]'
|
||||
}
|
||||
const ret = await client.preparePayment(address, payment, {sequence: 1, maxLedgerVersion: 15696358})
|
||||
const result = client.sign(ret.txJSON, secret)
|
||||
paths:
|
||||
'[[{"currency":"USD","issuer":"rVnYNK9yuxBz4uP8zC8LEFokM2nqH3poc"}]]',
|
||||
};
|
||||
const ret = await client.preparePayment(address, payment, {
|
||||
sequence: 1,
|
||||
maxLedgerVersion: 15696358,
|
||||
});
|
||||
const result = client.sign(ret.txJSON, secret);
|
||||
assert.deepEqual(result, {
|
||||
signedTransaction: '12000022800200002400000001201B00EF81E661EC6386F26FC0FFFF0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461968400000000000000C6940000000000000646AD3504529A0465E2E0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D1664619732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200A693FB5CA6B21250EBDFD8CFF526EE0DF7C9E4E31EB0660692E75E6A93BF5F802203CC39463DDA21386898CA31E18AD1A6828647D65741DD637BAD71BC83E29DB9481145E7B112523F68D2F5E879DB4EAC51C6698A693048314CA6EDC7A28252DAEA6F2045B24F4D7C333E146170112300000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461900',
|
||||
id: '78874FE5F5299FEE3EA85D3CF6C1FB1F1D46BB08F716662A3E3D1F0ADE4EF796'
|
||||
})
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
signedTransaction:
|
||||
"12000022800200002400000001201B00EF81E661EC6386F26FC0FFFF0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461968400000000000000C6940000000000000646AD3504529A0465E2E0000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D1664619732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200A693FB5CA6B21250EBDFD8CFF526EE0DF7C9E4E31EB0660692E75E6A93BF5F802203CC39463DDA21386898CA31E18AD1A6828647D65741DD637BAD71BC83E29DB9481145E7B112523F68D2F5E879DB4EAC51C6698A693048314CA6EDC7A28252DAEA6F2045B24F4D7C333E146170112300000000000000000000000005553440000000000054F6F784A58F9EFB0A9EB90B83464F9D166461900",
|
||||
id: "78874FE5F5299FEE3EA85D3CF6C1FB1F1D46BB08F716662A3E3D1F0ADE4EF796",
|
||||
});
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'already signed': async (client, address) => {
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, secret)
|
||||
"already signed": async (client, address) => {
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, secret);
|
||||
assert.throws(() => {
|
||||
const tx = JSON.stringify(binary.decode(result.signedTransaction))
|
||||
client.sign(tx, secret)
|
||||
}, /txJSON must not contain "TxnSignature" or "Signers" properties/)
|
||||
const tx = JSON.stringify(binary.decode(result.signedTransaction));
|
||||
client.sign(tx, secret);
|
||||
}, /txJSON must not contain "TxnSignature" or "Signers" properties/);
|
||||
},
|
||||
|
||||
'EscrowExecution': async (client, address) => {
|
||||
const secret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'
|
||||
const result = client.sign(REQUEST_FIXTURES.escrow.txJSON, secret)
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.escrow)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
async EscrowExecution(client, address) {
|
||||
const secret = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb";
|
||||
const result = client.sign(REQUEST_FIXTURES.escrow.txJSON, secret);
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.escrow);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'signAs': async (client, address) => {
|
||||
const txJSON = REQUEST_FIXTURES.signAs
|
||||
const secret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'
|
||||
async signAs(client, address) {
|
||||
const txJSON = REQUEST_FIXTURES.signAs;
|
||||
const secret = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb";
|
||||
const signature = client.sign(JSON.stringify(txJSON), secret, {
|
||||
signAs: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
|
||||
})
|
||||
assert.deepEqual(signature, RESPONSE_FIXTURES.signAs)
|
||||
signAs: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||
});
|
||||
assert.deepEqual(signature, RESPONSE_FIXTURES.signAs);
|
||||
},
|
||||
|
||||
'withKeypair': async (client, address) => {
|
||||
async withKeypair(client, address) {
|
||||
const keypair = {
|
||||
privateKey:
|
||||
'00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A',
|
||||
"00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A",
|
||||
publicKey:
|
||||
'02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8'
|
||||
}
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, keypair)
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.normal)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8",
|
||||
};
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, keypair);
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.normal);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'withKeypair already signed': async (client, address) => {
|
||||
"withKeypair already signed": async (client, address) => {
|
||||
const keypair = {
|
||||
privateKey:
|
||||
'00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A',
|
||||
"00ACCD3309DB14D1A4FC9B1DAE608031F4408C85C73EE05E035B7DC8B25840107A",
|
||||
publicKey:
|
||||
'02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8'
|
||||
}
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, keypair)
|
||||
"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8",
|
||||
};
|
||||
const result = client.sign(REQUEST_FIXTURES.normal.txJSON, keypair);
|
||||
assert.throws(() => {
|
||||
const tx = JSON.stringify(binary.decode(result.signedTransaction))
|
||||
client.sign(tx, keypair)
|
||||
}, /txJSON must not contain "TxnSignature" or "Signers" properties/)
|
||||
const tx = JSON.stringify(binary.decode(result.signedTransaction));
|
||||
client.sign(tx, keypair);
|
||||
}, /txJSON must not contain "TxnSignature" or "Signers" properties/);
|
||||
},
|
||||
|
||||
'withKeypair EscrowExecution': async (client, address) => {
|
||||
"withKeypair EscrowExecution": async (client, address) => {
|
||||
const keypair = {
|
||||
privateKey:
|
||||
'001ACAAEDECE405B2A958212629E16F2EB46B153EEE94CDD350FDEFF52795525B7',
|
||||
"001ACAAEDECE405B2A958212629E16F2EB46B153EEE94CDD350FDEFF52795525B7",
|
||||
publicKey:
|
||||
'0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020'
|
||||
}
|
||||
const result = client.sign(REQUEST_FIXTURES.escrow.txJSON, keypair)
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.escrow)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
"0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
|
||||
};
|
||||
const result = client.sign(REQUEST_FIXTURES.escrow.txJSON, keypair);
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.escrow);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'withKeypair signAs': async (client, address) => {
|
||||
const txJSON = REQUEST_FIXTURES.signAs
|
||||
"withKeypair signAs": async (client, address) => {
|
||||
const txJSON = REQUEST_FIXTURES.signAs;
|
||||
const keypair = {
|
||||
privateKey:
|
||||
'001ACAAEDECE405B2A958212629E16F2EB46B153EEE94CDD350FDEFF52795525B7',
|
||||
"001ACAAEDECE405B2A958212629E16F2EB46B153EEE94CDD350FDEFF52795525B7",
|
||||
publicKey:
|
||||
'0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020'
|
||||
}
|
||||
"0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
|
||||
};
|
||||
const signature = client.sign(JSON.stringify(txJSON), keypair, {
|
||||
signAs: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
|
||||
})
|
||||
assert.deepEqual(signature, RESPONSE_FIXTURES.signAs)
|
||||
signAs: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||
});
|
||||
assert.deepEqual(signature, RESPONSE_FIXTURES.signAs);
|
||||
},
|
||||
|
||||
'succeeds - prepared payment': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
"succeeds - prepared payment": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const payment = await client.preparePayment(address, {
|
||||
source: {
|
||||
address: address,
|
||||
address,
|
||||
maxAmount: {
|
||||
value: '1',
|
||||
currency: 'drops'
|
||||
}
|
||||
value: "1",
|
||||
currency: "drops",
|
||||
},
|
||||
},
|
||||
destination: {
|
||||
address: 'rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r',
|
||||
address: "rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r",
|
||||
amount: {
|
||||
value: '1',
|
||||
currency: 'drops'
|
||||
}
|
||||
}
|
||||
})
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const result = client.sign(payment.txJSON, secret)
|
||||
value: "1",
|
||||
currency: "drops",
|
||||
},
|
||||
},
|
||||
});
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const result = client.sign(payment.txJSON, secret);
|
||||
const expectedResult = {
|
||||
signedTransaction:
|
||||
'12000022800000002400000017201B008694F261400000000000000168400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100A9C91D4CFAE45686146EE0B56D4C53A2E7C2D672FB834D43E0BE2D2E9106519A022075DDA2F92DE552B0C45D83D4E6D35889B3FBF51BFBBD9B25EBF70DE3C96D0D6681145E7B112523F68D2F5E879DB4EAC51C6698A693048314FDB08D07AAA0EB711793A3027304D688E10C3648',
|
||||
id: '88D6B913C66279EA31ADC25C5806C48B2D4E5680261666790A736E1961217700'
|
||||
}
|
||||
assert.deepEqual(result, expectedResult)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
"12000022800000002400000017201B008694F261400000000000000168400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D874473045022100A9C91D4CFAE45686146EE0B56D4C53A2E7C2D672FB834D43E0BE2D2E9106519A022075DDA2F92DE552B0C45D83D4E6D35889B3FBF51BFBBD9B25EBF70DE3C96D0D6681145E7B112523F68D2F5E879DB4EAC51C6698A693048314FDB08D07AAA0EB711793A3027304D688E10C3648",
|
||||
id: "88D6B913C66279EA31ADC25C5806C48B2D4E5680261666790A736E1961217700",
|
||||
};
|
||||
assert.deepEqual(result, expectedResult);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'succeeds - no flags': async (client, address) => {
|
||||
"succeeds - no flags": async (client, address) => {
|
||||
const txJSON =
|
||||
'{"TransactionType":"Payment","Account":"r45Rev1EXGxy2hAUmJPCne97KUE7qyrD3j","Destination":"rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r","Amount":"20000000","Sequence":1,"Fee":"12"}'
|
||||
const secret = 'shotKgaEotpcYsshSE39vmSnBDRim'
|
||||
const result = client.sign(txJSON, secret)
|
||||
'{"TransactionType":"Payment","Account":"r45Rev1EXGxy2hAUmJPCne97KUE7qyrD3j","Destination":"rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r","Amount":"20000000","Sequence":1,"Fee":"12"}';
|
||||
const secret = "shotKgaEotpcYsshSE39vmSnBDRim";
|
||||
const result = client.sign(txJSON, secret);
|
||||
const expectedResult = {
|
||||
signedTransaction:
|
||||
'1200002400000001614000000001312D0068400000000000000C7321022B05847086686F9D0499B13136B94AD4323EE1B67D4C429ECC987AB35ACFA34574473045022100C104B7B97C31FACA4597E7D6FCF13BD85BD11375963A62A0AC45B0061236E39802207784F157F6A98DFC85B051CDDF61CC3084C4F5750B82674801C8E9950280D1998114EE3046A5DDF8422C40DDB93F1D522BB4FE6419158314FDB08D07AAA0EB711793A3027304D688E10C3648',
|
||||
id: '0596925967F541BF332FF6756645B2576A9858414B5B363DC3D34915BE8A70D6'
|
||||
}
|
||||
const decoded = binary.decode(result.signedTransaction)
|
||||
"1200002400000001614000000001312D0068400000000000000C7321022B05847086686F9D0499B13136B94AD4323EE1B67D4C429ECC987AB35ACFA34574473045022100C104B7B97C31FACA4597E7D6FCF13BD85BD11375963A62A0AC45B0061236E39802207784F157F6A98DFC85B051CDDF61CC3084C4F5750B82674801C8E9950280D1998114EE3046A5DDF8422C40DDB93F1D522BB4FE6419158314FDB08D07AAA0EB711793A3027304D688E10C3648",
|
||||
id: "0596925967F541BF332FF6756645B2576A9858414B5B363DC3D34915BE8A70D6",
|
||||
};
|
||||
const decoded = binary.decode(result.signedTransaction);
|
||||
assert(
|
||||
decoded.Flags == null,
|
||||
`Flags = ${decoded.Flags}, should be undefined`
|
||||
)
|
||||
assert.deepEqual(result, expectedResult)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
);
|
||||
assert.deepEqual(result, expectedResult);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'sign succeeds with source.amount/destination.minAmount': async (
|
||||
"sign succeeds with source.amount/destination.minAmount": async (
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
// See also: 'preparePayment with source.amount/destination.minAmount'
|
||||
|
||||
const txJSON =
|
||||
'{"TransactionType":"Payment","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Destination":"rEX4LtGJubaUcMWCJULcy4NVxGT9ZEMVRq","Amount":{"currency":"USD","issuer":"rMaa8VLBTjwTJWA2kSme4Sqgphhr6Lr6FH","value":"999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000"},"Flags":2147614720,"SendMax":{"currency":"GBP","issuer":"rpat5TmYjDsnFSStmgTumFgXCM9eqsWPro","value":"0.1"},"DeliverMin":{"currency":"USD","issuer":"rMaa8VLBTjwTJWA2kSme4Sqgphhr6Lr6FH","value":"0.1248548562296331"},"Sequence":23,"LastLedgerSequence":8820051,"Fee":"12"}'
|
||||
const secret = 'shotKgaEotpcYsshSE39vmSnBDRim'
|
||||
const result = client.sign(txJSON, secret)
|
||||
'{"TransactionType":"Payment","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Destination":"rEX4LtGJubaUcMWCJULcy4NVxGT9ZEMVRq","Amount":{"currency":"USD","issuer":"rMaa8VLBTjwTJWA2kSme4Sqgphhr6Lr6FH","value":"999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000"},"Flags":2147614720,"SendMax":{"currency":"GBP","issuer":"rpat5TmYjDsnFSStmgTumFgXCM9eqsWPro","value":"0.1"},"DeliverMin":{"currency":"USD","issuer":"rMaa8VLBTjwTJWA2kSme4Sqgphhr6Lr6FH","value":"0.1248548562296331"},"Sequence":23,"LastLedgerSequence":8820051,"Fee":"12"}';
|
||||
const secret = "shotKgaEotpcYsshSE39vmSnBDRim";
|
||||
const result = client.sign(txJSON, secret);
|
||||
const expectedResult = {
|
||||
signedTransaction:
|
||||
'12000022800200002400000017201B0086955361EC6386F26FC0FFFF0000000000000000000000005553440000000000DC596C88BCDE4E818D416FCDEEBF2C8656BADC9A68400000000000000C69D4438D7EA4C6800000000000000000000000000047425000000000000C155FFE99C8C91F67083CEFFDB69EBFE76348CA6AD4446F8C5D8A5E0B0000000000000000000000005553440000000000DC596C88BCDE4E818D416FCDEEBF2C8656BADC9A7321022B05847086686F9D0499B13136B94AD4323EE1B67D4C429ECC987AB35ACFA34574473045022100D9634523D8E232D4A7807A71856023D82AC928FA29848571B820867898413B5F022041AC00EC1F81A26A6504EBF844A38CC3204694EF2CC1A97A87632721631F93DA81145E7B112523F68D2F5E879DB4EAC51C6698A6930483149F500E50C2F016CA01945E5A1E5846B61EF2D376',
|
||||
id: '1C558AA9B926C24FB6BBD6950B2DB1350A83F9F12E4385208867907019761A2D'
|
||||
}
|
||||
const decoded = binary.decode(result.signedTransaction)
|
||||
"12000022800200002400000017201B0086955361EC6386F26FC0FFFF0000000000000000000000005553440000000000DC596C88BCDE4E818D416FCDEEBF2C8656BADC9A68400000000000000C69D4438D7EA4C6800000000000000000000000000047425000000000000C155FFE99C8C91F67083CEFFDB69EBFE76348CA6AD4446F8C5D8A5E0B0000000000000000000000005553440000000000DC596C88BCDE4E818D416FCDEEBF2C8656BADC9A7321022B05847086686F9D0499B13136B94AD4323EE1B67D4C429ECC987AB35ACFA34574473045022100D9634523D8E232D4A7807A71856023D82AC928FA29848571B820867898413B5F022041AC00EC1F81A26A6504EBF844A38CC3204694EF2CC1A97A87632721631F93DA81145E7B112523F68D2F5E879DB4EAC51C6698A6930483149F500E50C2F016CA01945E5A1E5846B61EF2D376",
|
||||
id: "1C558AA9B926C24FB6BBD6950B2DB1350A83F9F12E4385208867907019761A2D",
|
||||
};
|
||||
const decoded = binary.decode(result.signedTransaction);
|
||||
assert(
|
||||
decoded.Flags === 2147614720,
|
||||
`Flags = ${decoded.Flags}, should be 2147614720`
|
||||
)
|
||||
assert.deepEqual(result, expectedResult)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
);
|
||||
assert.deepEqual(result, expectedResult);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'throws when encoded tx does not match decoded tx - prepared payment': async (
|
||||
"throws when encoded tx does not match decoded tx - prepared payment": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const payment = await client.preparePayment(address, {
|
||||
source: {
|
||||
address: address,
|
||||
address,
|
||||
maxAmount: {
|
||||
value: '1.1234567',
|
||||
currency: 'drops'
|
||||
}
|
||||
value: "1.1234567",
|
||||
currency: "drops",
|
||||
},
|
||||
},
|
||||
destination: {
|
||||
address: 'rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r',
|
||||
address: "rQ3PTWGLCbPz8ZCicV5tCX3xuymojTng5r",
|
||||
amount: {
|
||||
value: '1.1234567',
|
||||
currency: 'drops'
|
||||
}
|
||||
}
|
||||
})
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
value: "1.1234567",
|
||||
currency: "drops",
|
||||
},
|
||||
},
|
||||
});
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
assert.throws(() => {
|
||||
client.sign(payment.txJSON, secret)
|
||||
}, /^Error: 1\.1234567 is an illegal amount/)
|
||||
client.sign(payment.txJSON, secret);
|
||||
}, /^Error: 1\.1234567 is an illegal amount/);
|
||||
},
|
||||
|
||||
'throws when encoded tx does not match decoded tx - prepared order': async (
|
||||
"throws when encoded tx does not match decoded tx - prepared order": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
mockRippled.addResponse({command: 'fee'}, rippled.fee)
|
||||
mockRippled.addResponse({command: 'ledger_current'}, rippled.ledger_current)
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse(
|
||||
{ command: "server_info" },
|
||||
rippled.server_info.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "fee" }, rippled.fee);
|
||||
mockRippled.addResponse(
|
||||
{ command: "ledger_current" },
|
||||
rippled.ledger_current
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
const order = {
|
||||
direction: 'sell',
|
||||
direction: "sell",
|
||||
quantity: {
|
||||
currency: 'USD',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '3.140000'
|
||||
currency: "USD",
|
||||
counterparty: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
value: "3.140000",
|
||||
},
|
||||
totalPrice: {
|
||||
currency: 'XRP',
|
||||
value: '31415'
|
||||
}
|
||||
}
|
||||
const prepared = await client.prepareOrder(address, order, {sequence: 123})
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
currency: "XRP",
|
||||
value: "31415",
|
||||
},
|
||||
};
|
||||
const prepared = await client.prepareOrder(address, order, {
|
||||
sequence: 123,
|
||||
});
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
try {
|
||||
client.sign(prepared.txJSON, secret)
|
||||
return Promise.reject(new Error('client.sign should have thrown'))
|
||||
client.sign(prepared.txJSON, secret);
|
||||
return await Promise.reject(new Error("client.sign should have thrown"));
|
||||
} catch (error) {
|
||||
assert.equal(error.name, 'ValidationError')
|
||||
assert.equal(error.name, "ValidationError");
|
||||
assert.equal(
|
||||
error.message,
|
||||
'Serialized transaction does not match original txJSON. See `error.data`'
|
||||
)
|
||||
"Serialized transaction does not match original txJSON. See `error.data`"
|
||||
);
|
||||
assert.deepEqual(error.data.diff, {
|
||||
TakerGets: {
|
||||
value: '3.14'
|
||||
}
|
||||
})
|
||||
value: "3.14",
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
'throws when encoded tx does not match decoded tx - AccountSet': async (
|
||||
"throws when encoded tx does not match decoded tx - AccountSet": async (
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const request = {
|
||||
// TODO: This fails when address is X-address
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"6578616D706C652E636F6D","LastLedgerSequence":8820051,"Fee":"1.2","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: '0.0000012',
|
||||
fee: "0.0000012",
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051
|
||||
}
|
||||
}
|
||||
maxLedgerVersion: 8820051,
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(() => {
|
||||
client.sign(request.txJSON, secret)
|
||||
}, /Error: 1\.2 is an illegal amount/)
|
||||
client.sign(request.txJSON, secret);
|
||||
}, /Error: 1\.2 is an illegal amount/);
|
||||
},
|
||||
|
||||
'throws when encoded tx does not match decoded tx - higher fee': async (
|
||||
"throws when encoded tx does not match decoded tx - higher fee": async (
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const request = {
|
||||
// TODO: This fails when address is X-address
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Domain":"6578616D706C652E636F6D","LastLedgerSequence":8820051,"Fee":"1123456.7","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: '1.1234567',
|
||||
fee: "1.1234567",
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051
|
||||
}
|
||||
}
|
||||
maxLedgerVersion: 8820051,
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(() => {
|
||||
client.sign(request.txJSON, secret)
|
||||
}, /Error: 1123456\.7 is an illegal amount/)
|
||||
client.sign(request.txJSON, secret);
|
||||
}, /Error: 1123456\.7 is an illegal amount/);
|
||||
},
|
||||
|
||||
'throws when Fee exceeds maxFeeXRP (in drops)': async (client, address) => {
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
"throws when Fee exceeds maxFeeXRP (in drops)": async (client, address) => {
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const request = {
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"${address}","Domain":"6578616D706C652E636F6D","LastLedgerSequence":8820051,"Fee":"2010000","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: '2.01',
|
||||
fee: "2.01",
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051
|
||||
}
|
||||
}
|
||||
maxLedgerVersion: 8820051,
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(() => {
|
||||
client.sign(request.txJSON, secret)
|
||||
}, /Fee" should not exceed "2000000"\. To use a higher fee, set `maxFeeXRP` in the Client constructor\./)
|
||||
client.sign(request.txJSON, secret);
|
||||
}, /Fee" should not exceed "2000000"\. To use a higher fee, set `maxFeeXRP` in the Client constructor\./);
|
||||
},
|
||||
|
||||
'throws when Fee exceeds maxFeeXRP (in drops) - custom maxFeeXRP': async (
|
||||
"throws when Fee exceeds maxFeeXRP (in drops) - custom maxFeeXRP": async (
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
client._maxFeeXRP = '1.9'
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
client._maxFeeXRP = "1.9";
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const request = {
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"${address}","Domain":"6578616D706C652E636F6D","LastLedgerSequence":8820051,"Fee":"2010000","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: '2.01',
|
||||
fee: "2.01",
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051
|
||||
}
|
||||
}
|
||||
maxLedgerVersion: 8820051,
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(() => {
|
||||
client.sign(request.txJSON, secret)
|
||||
}, /Fee" should not exceed "1900000"\. To use a higher fee, set `maxFeeXRP` in the Client constructor\./)
|
||||
client.sign(request.txJSON, secret);
|
||||
}, /Fee" should not exceed "1900000"\. To use a higher fee, set `maxFeeXRP` in the Client constructor\./);
|
||||
},
|
||||
|
||||
'permits fee exceeding 2000000 drops when maxFeeXRP is higher than 2 XRP': async (
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
client._maxFeeXRP = '2.1'
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
const request = {
|
||||
// TODO: This fails when address is X-address
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","LastLedgerSequence":8820051,"Fee":"2010000","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: '2.01',
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051
|
||||
}
|
||||
}
|
||||
"permits fee exceeding 2000000 drops when maxFeeXRP is higher than 2 XRP":
|
||||
async (client, address) => {
|
||||
client._maxFeeXRP = "2.1";
|
||||
const secret = "shsWGZcmZz6YsWWmcnpfr6fLTdtFV";
|
||||
const request = {
|
||||
// TODO: This fails when address is X-address
|
||||
txJSON: `{"Flags":2147483648,"TransactionType":"AccountSet","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","LastLedgerSequence":8820051,"Fee":"2010000","Sequence":23,"SigningPubKey":"02F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D8"}`,
|
||||
instructions: {
|
||||
fee: "2.01",
|
||||
sequence: 23,
|
||||
maxLedgerVersion: 8820051,
|
||||
},
|
||||
};
|
||||
|
||||
const result = client.sign(request.txJSON, secret)
|
||||
const result = client.sign(request.txJSON, secret);
|
||||
|
||||
const expectedResponse = {
|
||||
signedTransaction:
|
||||
'12000322800000002400000017201B008695536840000000001EAB90732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200203F219F5371D2C6506888B1B02B27E74998F7A42D412C32FE319AC1A5B8DEF02205959A1B02253ACCCE542759E9886466C56D16B04676FA492AD34AA0E877E91F381145E7B112523F68D2F5E879DB4EAC51C6698A69304',
|
||||
id: '061D5593E0A117F389826419CAC049A73C7CFCA65A20B788781D41240143D864'
|
||||
}
|
||||
const expectedResponse = {
|
||||
signedTransaction:
|
||||
"12000322800000002400000017201B008695536840000000001EAB90732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200203F219F5371D2C6506888B1B02B27E74998F7A42D412C32FE319AC1A5B8DEF02205959A1B02253ACCCE542759E9886466C56D16B04676FA492AD34AA0E877E91F381145E7B112523F68D2F5E879DB4EAC51C6698A69304",
|
||||
id: "061D5593E0A117F389826419CAC049A73C7CFCA65A20B788781D41240143D864",
|
||||
};
|
||||
|
||||
assert.deepEqual(result, expectedResponse)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
assert.deepEqual(result, expectedResponse);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
"sign with ticket": async (client, address) => {
|
||||
const secret = "sn7n5R1cR5Y3fRFkuWXA94Ts1frVJ";
|
||||
const result = client.sign(REQUEST_FIXTURES.ticket.txJSON, secret);
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.ticket);
|
||||
schemaValidator.schemaValidate("sign", result);
|
||||
},
|
||||
|
||||
'sign with ticket': async (client, address) => {
|
||||
const secret = 'sn7n5R1cR5Y3fRFkuWXA94Ts1frVJ'
|
||||
const result = client.sign(REQUEST_FIXTURES.ticket.txJSON, secret)
|
||||
assert.deepEqual(result, RESPONSE_FIXTURES.ticket)
|
||||
schemaValidator.schemaValidate('sign', result)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user