mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 11:15:48 +00:00
Removes methods that were just rippled wrappers (#1550)
* remove getAccountInfo * remove getAccountObjects * remove getBalanceSheet (gateway_balances) * remove getLedger * remove getOrders (account_orders) * remove getPaymentChannel (ledger_entry) * remove getTransaction(s) (tx/account_tx) * remove getSettings (account_info) * remove getServerInfo (server_info) * fix integ tests * remove submit (also deprecated) * fix integ tests * add TODO
This commit is contained in:
@@ -17,7 +17,7 @@ function cancelOrder(orderSequence) {
|
||||
return api.prepareOrderCancellation(address, {orderSequence}, instructions)
|
||||
.then(prepared => {
|
||||
const signing = api.sign(prepared.txJSON, secret);
|
||||
return api.submit(signing.signedTransaction);
|
||||
return api.request({command: 'submit', tx_blob: signing.signedTransaction});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,6 @@ api.connect().then(() => {
|
||||
console.log('Payment transaction prepared...');
|
||||
const {signedTransaction} = api.sign(prepared.txJSON, secret);
|
||||
console.log('Payment transaction signed...');
|
||||
api.submit(signedTransaction).then(quit, fail);
|
||||
api.request({command: 'submit', tx_blob: signedTransaction}).then(quit, fail);
|
||||
});
|
||||
}).catch(fail);
|
||||
|
||||
@@ -26,6 +26,6 @@ api.connect().then(() => {
|
||||
console.log('Ticket transaction prepared...');
|
||||
const {signedTransaction} = api.sign(prepared.txJSON, secret);
|
||||
console.log('Ticket transaction signed...');
|
||||
api.submit(signedTransaction).then(quit, fail);
|
||||
api.request({command: 'submit', tx_blob: signedTransaction}).then(quit, fail);
|
||||
});
|
||||
}).catch(fail);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {Client} from '../../dist/npm'
|
||||
import { TransactionMetadata } from '../../src/models/common/transaction'
|
||||
|
||||
const client = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
|
||||
@@ -6,10 +7,13 @@ getTransaction()
|
||||
|
||||
async function getTransaction() {
|
||||
await client.connect()
|
||||
const ledger = await client.getLedger({includeTransactions: true})
|
||||
const ledger = await client.request({command: 'ledger', transactions: true})
|
||||
console.log(ledger)
|
||||
const tx = await client.getTransaction(ledger.transactionHashes[0])
|
||||
const tx = await client.request({
|
||||
command: 'tx',
|
||||
transaction: ledger.result.ledger.transactions[0] as string
|
||||
})
|
||||
console.log(tx)
|
||||
console.log('deliveredAmount:', tx.outcome.deliveredAmount)
|
||||
console.log('deliveredAmount:', (tx.result.meta as TransactionMetadata).DeliveredAmount)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {Client} from '../../dist/npm'
|
||||
import { AccountFlags } from '../../dist/npm/common/constants'
|
||||
|
||||
const client = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
|
||||
@@ -7,7 +8,11 @@ parseAccountFlags()
|
||||
async function parseAccountFlags() {
|
||||
await client.connect()
|
||||
const account_info = await client.request({command: 'account_info', account: 'rKsdkGhyZH6b2Zzd5hNnEqSv2wpznn4n6N'})
|
||||
const flags = client.parseAccountFlags(account_info.result.account_data.Flags)
|
||||
console.log(JSON.stringify(flags, null, 2))
|
||||
const flags = account_info.result.account_data.Flags
|
||||
for (const flagName in AccountFlags) {
|
||||
if (flags & AccountFlags[flagName]) {
|
||||
console.log(`${flagName} enabled`)
|
||||
}
|
||||
}
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
@@ -100,16 +100,16 @@ async function performPayments(payments) {
|
||||
finalResults.push({
|
||||
id: signed.id
|
||||
})
|
||||
const result = await client.submit(signed.signedTransaction)
|
||||
const response = await client.request({command: 'submit', tx_blob: signed.signedTransaction})
|
||||
|
||||
// Most of the time we'll get 'tesSUCCESS' or (after many submissions) 'terQUEUED'
|
||||
console.log(`tx ${i} - tentative: ${result.resultCode}`)
|
||||
console.log(`tx ${i} - tentative: ${response.result.engine_result}`)
|
||||
|
||||
const txFinalizedPromise = new Promise<void>((resolve) => {
|
||||
const ledgerClosedCallback = async (event: LedgerClosedEvent) => {
|
||||
let status
|
||||
try {
|
||||
status = await client.getTransaction(signed.id)
|
||||
status = await client.request({command: 'tx', transaction: signed.id})
|
||||
} catch (e) {
|
||||
// Typical error when the tx hasn't been validated yet:
|
||||
if (e.name !== 'MissingLedgerHistoryError') {
|
||||
|
||||
@@ -13,7 +13,6 @@ class BroadcastClient extends Client {
|
||||
|
||||
// exposed for testing
|
||||
this._clients = clients
|
||||
|
||||
this.getMethodNames().forEach((name) => {
|
||||
this[name] = function () {
|
||||
// eslint-disable-line no-loop-func
|
||||
@@ -59,9 +58,11 @@ class BroadcastClient extends Client {
|
||||
|
||||
getMethodNames() {
|
||||
const methodNames: string[] = []
|
||||
const Client = this._clients[0]
|
||||
for (const name of Object.getOwnPropertyNames(Client)) {
|
||||
if (typeof Client[name] === 'function') {
|
||||
const firstClient = this._clients[0]
|
||||
const methods = Object.getOwnPropertyNames(firstClient)
|
||||
methods.push(...Object.getOwnPropertyNames(Object.getPrototypeOf(firstClient)))
|
||||
for (const name of methods) {
|
||||
if (typeof firstClient[name] === 'function' && name !== 'constructor') {
|
||||
methodNames.push(name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,10 @@ import { Connection, ConnectionUserOptions } from './connection'
|
||||
import {
|
||||
formatLedgerClose
|
||||
} from './utils'
|
||||
import getTransaction from '../ledger/transaction'
|
||||
import getTransactions from '../ledger/transactions'
|
||||
import getTrustlines from '../ledger/trustlines'
|
||||
import getBalances from '../ledger/balances'
|
||||
import getBalanceSheet from '../ledger/balance-sheet'
|
||||
import getPaths from '../ledger/pathfind'
|
||||
import getOrders from '../ledger/orders'
|
||||
import {getOrderbook, formatBidsAndAsks} from '../ledger/orderbook'
|
||||
import {getSettings, parseAccountFlags} from '../ledger/settings'
|
||||
import getAccountInfo from '../ledger/accountinfo'
|
||||
import getAccountObjects from '../ledger/accountobjects'
|
||||
import getPaymentChannel from '../ledger/payment-channel'
|
||||
import preparePayment from '../transaction/payment'
|
||||
import prepareTrustline from '../transaction/trustline'
|
||||
import prepareOrder from '../transaction/order'
|
||||
@@ -42,13 +34,11 @@ import prepareSettings from '../transaction/settings'
|
||||
import prepareTicketCreate from '../transaction/ticket'
|
||||
import {sign} from '../transaction/sign'
|
||||
import combine from '../transaction/combine'
|
||||
import submit from '../transaction/submit'
|
||||
import { generateAddress, generateXAddress } from '../offline/utils'
|
||||
import {deriveKeypair, deriveAddress, deriveXAddress} from '../offline/derive'
|
||||
import computeLedgerHash from '../offline/ledgerhash'
|
||||
import signPaymentChannelClaim from '../offline/sign-payment-channel-claim'
|
||||
import verifyPaymentChannelClaim from '../offline/verify-payment-channel-claim'
|
||||
import getLedger from '../ledger/ledger'
|
||||
import {
|
||||
Request,
|
||||
Response,
|
||||
@@ -125,7 +115,7 @@ import RangeSet from './rangeset'
|
||||
import * as ledgerUtils from '../ledger/utils'
|
||||
import * as transactionUtils from '../transaction/utils'
|
||||
import * as schemaValidator from '../common/schema-validator'
|
||||
import {getServerInfo, getFee} from '../common/serverinfo'
|
||||
import {getFee} from '../common/fee'
|
||||
import {ensureClassicAddress} from '../common'
|
||||
import {clamp} from '../ledger/utils'
|
||||
import {TransactionJSON, Instructions, Prepare} from '../transaction/types'
|
||||
@@ -426,27 +416,16 @@ class Client extends EventEmitter {
|
||||
await this.connection.disconnect()
|
||||
}
|
||||
|
||||
getServerInfo = getServerInfo
|
||||
getFee = getFee
|
||||
|
||||
async getLedgerVersion(): Promise<number> {
|
||||
return this.connection.getLedgerVersion()
|
||||
}
|
||||
|
||||
getTransaction = getTransaction
|
||||
getTransactions = getTransactions
|
||||
getTrustlines = getTrustlines
|
||||
getBalances = getBalances
|
||||
getBalanceSheet = getBalanceSheet
|
||||
getPaths = getPaths
|
||||
getOrderbook = getOrderbook
|
||||
getOrders = getOrders
|
||||
getSettings = getSettings
|
||||
getAccountInfo = getAccountInfo
|
||||
getAccountObjects = getAccountObjects
|
||||
getPaymentChannel = getPaymentChannel
|
||||
getLedger = getLedger
|
||||
parseAccountFlags = parseAccountFlags
|
||||
|
||||
preparePayment = preparePayment
|
||||
prepareTrustline = prepareTrustline
|
||||
@@ -466,8 +445,6 @@ class Client extends EventEmitter {
|
||||
sign = sign
|
||||
combine = combine
|
||||
|
||||
submit = submit // @deprecated Use client.request({command: 'submit', tx_blob: signedTransaction }) instead
|
||||
|
||||
deriveKeypair = deriveKeypair // @deprecated Invoke from top-level package instead
|
||||
deriveAddress = deriveAddress // @deprecated Invoke from top-level package instead
|
||||
computeLedgerHash = computeLedgerHash // @deprecated Invoke from top-level package instead
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import _ from 'lodash'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import {Client} from '..'
|
||||
import { ServerInfoResponse } from '../models/methods'
|
||||
|
||||
function getServerInfo(this: Client): Promise<ServerInfoResponse> {
|
||||
return this.request({command: 'server_info'})
|
||||
}
|
||||
|
||||
// This is a public API that can be called directly.
|
||||
// This is not used by the `prepare*` methods. See `src/transaction/utils.ts`
|
||||
@@ -17,7 +12,7 @@ async function getFee(this: Client, cushion?: number): Promise<string> {
|
||||
cushion = 1.2
|
||||
}
|
||||
|
||||
const serverInfo = (await this.getServerInfo()).result.info
|
||||
const serverInfo = (await this.request({command: "server_info"})).result.info
|
||||
const baseFeeXrp = new BigNumber(serverInfo.validated_ledger.base_fee_xrp)
|
||||
if (serverInfo.load_factor == null) {
|
||||
// https://github.com/ripple/rippled/issues/3812#issuecomment-816871100
|
||||
@@ -31,4 +26,4 @@ async function getFee(this: Client, cushion?: number): Promise<string> {
|
||||
return new BigNumber(fee.toFixed(6)).toString(10)
|
||||
}
|
||||
|
||||
export {getServerInfo, getFee}
|
||||
export {getFee}
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as constants from './constants'
|
||||
import * as errors from './errors'
|
||||
import * as validate from './validate'
|
||||
import * as serverInfo from './serverinfo'
|
||||
import {xAddressToClassicAddress, isValidXAddress} from 'ripple-address-codec'
|
||||
|
||||
export function ensureClassicAddress(account: string): string {
|
||||
@@ -24,7 +23,7 @@ export function ensureClassicAddress(account: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export {constants, errors, validate, serverInfo}
|
||||
export {constants, errors, validate}
|
||||
export {
|
||||
dropsToXrp,
|
||||
xrpToDrops,
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import {
|
||||
validate,
|
||||
ensureClassicAddress
|
||||
} from '../common'
|
||||
import {Client} from '..'
|
||||
import { AccountInfoResponse } from '../models/methods'
|
||||
|
||||
export type GetAccountInfoOptions = {
|
||||
ledgerVersion?: number
|
||||
}
|
||||
|
||||
export default async function getAccountInfo(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: GetAccountInfoOptions = {}
|
||||
): Promise<AccountInfoResponse> {
|
||||
// 1. Validate
|
||||
validate.getAccountInfo({address, options})
|
||||
|
||||
// Only support retrieving account info without a tag,
|
||||
// since account info is not distinguished by tag.
|
||||
address = ensureClassicAddress(address)
|
||||
|
||||
// 2. Make Request
|
||||
return await this.request({command: 'account_info',
|
||||
account: address,
|
||||
ledger_index: options.ledgerVersion || 'validated'
|
||||
})
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import {Client} from '..'
|
||||
import {
|
||||
GetAccountObjectsOptions
|
||||
} from '../common/types/commands/account_objects'
|
||||
import {AccountObjectsResponse} from '../models/methods'
|
||||
|
||||
export default async function getAccountObjects(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: GetAccountObjectsOptions = {}
|
||||
): Promise<AccountObjectsResponse> {
|
||||
// Don't validate the options so that new types can be passed
|
||||
// through to rippled. rippled validates requests.
|
||||
|
||||
// Make Request
|
||||
const response = await this.request({
|
||||
command: 'account_objects',
|
||||
account: address,
|
||||
type: options.type,
|
||||
ledger_hash: options.ledgerHash,
|
||||
ledger_index: options.ledgerIndex,
|
||||
limit: options.limit,
|
||||
marker: options.marker
|
||||
})
|
||||
// Return Response
|
||||
return response
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import * as _ from 'lodash'
|
||||
import {validate} from '../common'
|
||||
import {Amount} from '../common/types/objects'
|
||||
import {ensureLedgerVersion} from './utils'
|
||||
import {Client} from '..'
|
||||
import { GatewayBalancesResponse } from '../models/methods'
|
||||
|
||||
export type BalanceSheetOptions = {
|
||||
excludeAddresses?: Array<string>
|
||||
ledgerVersion?: number
|
||||
}
|
||||
|
||||
export type GetBalanceSheet = {
|
||||
balances?: Array<Amount>
|
||||
assets?: Array<Amount>
|
||||
obligations?: Array<{
|
||||
currency: string
|
||||
value: string
|
||||
}>
|
||||
}
|
||||
|
||||
function formatBalanceSheet(balanceSheet: GatewayBalancesResponse): GetBalanceSheet {
|
||||
const result: GetBalanceSheet = {}
|
||||
|
||||
if (balanceSheet.result.balances != null) {
|
||||
result.balances = []
|
||||
Object.entries(balanceSheet.result.balances).forEach(entry => {
|
||||
const [counterparty, balances] = entry;
|
||||
balances.forEach((balance) => {
|
||||
result.balances.push(Object.assign({counterparty}, balance))
|
||||
})
|
||||
})
|
||||
}
|
||||
if (balanceSheet.result.assets != null) {
|
||||
result.assets = []
|
||||
Object.entries(balanceSheet.result.assets).forEach(([counterparty, assets]) => {
|
||||
assets.forEach((balance) => {
|
||||
result.assets.push(Object.assign({counterparty}, balance))
|
||||
})
|
||||
})
|
||||
}
|
||||
if (balanceSheet.result.obligations != null) {
|
||||
result.obligations = Object.entries(balanceSheet.result.obligations as {[key: string]: string}).map(
|
||||
([currency, value]) => ({currency, value})
|
||||
)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async function getBalanceSheet(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: BalanceSheetOptions = {}
|
||||
): Promise<GetBalanceSheet> {
|
||||
// 1. Validate
|
||||
validate.getBalanceSheet({address, options})
|
||||
options = await ensureLedgerVersion.call(this, options)
|
||||
// 2. Make Request
|
||||
const response = await this.request({command: 'gateway_balances',
|
||||
account: address,
|
||||
strict: true,
|
||||
hotwallet: options.excludeAddresses,
|
||||
ledger_index: options.ledgerVersion
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return formatBalanceSheet(response)
|
||||
}
|
||||
|
||||
export default getBalanceSheet
|
||||
@@ -1,31 +0,0 @@
|
||||
import {validate} from '../common'
|
||||
import {FormattedLedger, parseLedger} from './parse/ledger'
|
||||
import {Client} from '..'
|
||||
|
||||
export type GetLedgerOptions = {
|
||||
ledgerHash?: string
|
||||
ledgerVersion?: number
|
||||
includeAllData?: boolean
|
||||
includeTransactions?: boolean
|
||||
includeState?: boolean
|
||||
}
|
||||
|
||||
async function getLedger(
|
||||
this: Client,
|
||||
options: GetLedgerOptions = {}
|
||||
): Promise<FormattedLedger> {
|
||||
// 1. Validate
|
||||
validate.getLedger({options})
|
||||
// 2. Make Request
|
||||
const response = await this.request({command: 'ledger',
|
||||
ledger_hash: options.ledgerHash,
|
||||
ledger_index: options.ledgerVersion || 'validated',
|
||||
expand: options.includeAllData,
|
||||
transactions: options.includeTransactions,
|
||||
accounts: options.includeState
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return parseLedger(response.result.ledger)
|
||||
}
|
||||
|
||||
export default getLedger
|
||||
@@ -1,41 +0,0 @@
|
||||
import * as _ from 'lodash'
|
||||
import {validate} from '../common'
|
||||
import {FormattedAccountOrder, parseAccountOrder} from './parse/account-order'
|
||||
import {Client} from '..'
|
||||
import {AccountOffersResponse} from '../models/methods'
|
||||
|
||||
export type GetOrdersOptions = {
|
||||
limit?: number
|
||||
ledgerVersion?: number
|
||||
}
|
||||
|
||||
function formatResponse(
|
||||
address: string,
|
||||
responses: AccountOffersResponse[]
|
||||
): FormattedAccountOrder[] {
|
||||
let orders: FormattedAccountOrder[] = []
|
||||
for (const response of responses) {
|
||||
const offers = response.result.offers.map((offer) => {
|
||||
return parseAccountOrder(address, offer)
|
||||
})
|
||||
orders = orders.concat(offers)
|
||||
}
|
||||
return _.sortBy(orders, (order) => order.properties.sequence)
|
||||
}
|
||||
|
||||
export default async function getOrders(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: GetOrdersOptions = {}
|
||||
): Promise<FormattedAccountOrder[]> {
|
||||
// 1. Validate
|
||||
validate.getOrders({address, options})
|
||||
// 2. Make Request
|
||||
const responses = await this._requestAll({command: 'account_offers',
|
||||
account: address,
|
||||
ledger_index: options.ledgerVersion || (await this.getLedgerVersion()),
|
||||
limit: options.limit
|
||||
})
|
||||
// 3. Return Formatted Response, from the perspective of `address`
|
||||
return formatResponse(address, responses)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as _ from 'lodash'
|
||||
import {removeUndefined, rippleTimeToISO8601} from '../../common'
|
||||
import parseTransaction from './transaction'
|
||||
import {Ledger} from '../../models/ledger'
|
||||
import { TransactionAndMetadata } from '../../models/transactions'
|
||||
|
||||
export type FormattedLedger = {
|
||||
// TODO: properties in type don't match response object. Fix!
|
||||
@@ -22,10 +22,10 @@ export type FormattedLedger = {
|
||||
stateHashes?: Array<string>
|
||||
}
|
||||
|
||||
function parseTransactionWrapper(ledgerVersion, tx) {
|
||||
function parseTransactionWrapper(ledgerVersion: number, tx: TransactionAndMetadata) {
|
||||
// renames metaData to meta and adds ledger_index
|
||||
const transaction = Object.assign({}, _.omit(tx, 'metaData'), {
|
||||
meta: tx.metaData,
|
||||
const transaction = Object.assign({}, _.omit(tx, 'metadata'), {
|
||||
meta: tx.metadata,
|
||||
ledger_index: ledgerVersion
|
||||
})
|
||||
const result = parseTransaction(transaction, true)
|
||||
@@ -35,15 +35,15 @@ function parseTransactionWrapper(ledgerVersion, tx) {
|
||||
return result
|
||||
}
|
||||
|
||||
function parseTransactions(transactions, ledgerVersion) {
|
||||
function parseTransactions(transactions: string[] | TransactionAndMetadata[], ledgerVersion: number) {
|
||||
if (_.isEmpty(transactions)) {
|
||||
return {}
|
||||
}
|
||||
if (typeof transactions[0] === 'string') {
|
||||
return {transactionHashes: transactions}
|
||||
return {transactionHashes: transactions as unknown as string[]}
|
||||
}
|
||||
return {
|
||||
transactions: transactions.map(
|
||||
transactions: (transactions as unknown as TransactionAndMetadata[]).map(
|
||||
_.partial(parseTransactionWrapper, ledgerVersion)
|
||||
)
|
||||
}
|
||||
@@ -64,7 +64,7 @@ function parseState(state) {
|
||||
* @returns {FormattedLedger} formatted ledger
|
||||
* @throws RangeError: Invalid time value (rippleTimeToISO8601)
|
||||
*/
|
||||
export function parseLedger(ledger: Ledger): FormattedLedger {
|
||||
export function parseLedger(ledger): FormattedLedger {
|
||||
const ledgerVersion = parseInt(ledger.ledger_index, 10)
|
||||
return removeUndefined(
|
||||
Object.assign(
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import {
|
||||
parsePaymentChannel,
|
||||
FormattedPaymentChannel
|
||||
} from './parse/payment-channel'
|
||||
import {validate, errors} from '../common'
|
||||
import {Client} from '..'
|
||||
import {LedgerEntryResponse} from '../models/methods'
|
||||
const NotFoundError = errors.NotFoundError
|
||||
|
||||
function formatResponse(
|
||||
response: LedgerEntryResponse
|
||||
): FormattedPaymentChannel {
|
||||
if (
|
||||
response.result.node == null ||
|
||||
response.result.node.LedgerEntryType !== 'PayChannel'
|
||||
) {
|
||||
throw new NotFoundError('Payment channel ledger entry not found')
|
||||
}
|
||||
return parsePaymentChannel(response.result.node)
|
||||
}
|
||||
|
||||
async function getPaymentChannel(
|
||||
this: Client,
|
||||
id: string
|
||||
): Promise<FormattedPaymentChannel> {
|
||||
// 1. Validate
|
||||
validate.getPaymentChannel({id})
|
||||
// 2. Make Request
|
||||
const response = await this.request({command: 'ledger_entry',
|
||||
index: id,
|
||||
binary: false,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return formatResponse(response)
|
||||
}
|
||||
|
||||
export default getPaymentChannel
|
||||
@@ -1,58 +0,0 @@
|
||||
import parseFields from './parse/fields'
|
||||
import {validate, constants, ensureClassicAddress} from '../common'
|
||||
import {FormattedSettings} from '../common/types/objects'
|
||||
import {Client} from '..'
|
||||
import {AccountInfoResponse} from '../models/methods'
|
||||
import {Settings} from '../common/constants'
|
||||
|
||||
const AccountFlags = constants.AccountFlags
|
||||
|
||||
export type SettingsOptions = {
|
||||
ledgerVersion?: number | 'validated' | 'closed' | 'current'
|
||||
}
|
||||
|
||||
export function parseAccountFlags(
|
||||
value: number,
|
||||
options: {excludeFalse?: boolean} = {}
|
||||
): Settings {
|
||||
const settings = {}
|
||||
for (const flagName in AccountFlags) {
|
||||
if (value & AccountFlags[flagName]) {
|
||||
settings[flagName] = true
|
||||
} else {
|
||||
if (!options.excludeFalse) {
|
||||
settings[flagName] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
return settings
|
||||
}
|
||||
|
||||
function formatSettings(response: AccountInfoResponse) {
|
||||
const data = response.result.account_data
|
||||
const parsedFlags = parseAccountFlags(data.Flags, {excludeFalse: true})
|
||||
const parsedFields = parseFields(data)
|
||||
return Object.assign({}, parsedFlags, parsedFields)
|
||||
}
|
||||
|
||||
export async function getSettings(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: SettingsOptions = {}
|
||||
): Promise<FormattedSettings> {
|
||||
// 1. Validate
|
||||
validate.getSettings({address, options})
|
||||
|
||||
// Only support retrieving settings without a tag,
|
||||
// since settings do not distinguish by tag.
|
||||
address = ensureClassicAddress(address)
|
||||
|
||||
// 2. Make Request
|
||||
const response = await this.request({command: 'account_info',
|
||||
account: address,
|
||||
ledger_index: options.ledgerVersion || 'validated',
|
||||
signer_lists: true
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return formatSettings(response)
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
import * as utils from './utils'
|
||||
import parseTransaction from './parse/transaction'
|
||||
import {validate, errors} from '../common'
|
||||
import {Connection} from '../client'
|
||||
import {FormattedTransactionType} from '../transaction/types'
|
||||
import {RippledError} from '../common/errors'
|
||||
import {Client} from '..'
|
||||
import { LedgerRequest } from '../models/methods'
|
||||
|
||||
export type TransactionOptions = {
|
||||
minLedgerVersion?: number
|
||||
maxLedgerVersion?: number
|
||||
includeRawTransaction?: boolean
|
||||
}
|
||||
|
||||
type TransactionResponse = FormattedTransactionType & {
|
||||
hash: string
|
||||
ledger_index: number
|
||||
meta: any
|
||||
validated?: boolean
|
||||
}
|
||||
|
||||
function attachTransactionDate(
|
||||
client: Client,
|
||||
tx: any
|
||||
): Promise<TransactionResponse> {
|
||||
if (tx.result.date) {
|
||||
return Promise.resolve(tx)
|
||||
}
|
||||
|
||||
const ledgerVersion = tx.result.ledger_index || tx.result.LedgerSequence
|
||||
|
||||
if (!ledgerVersion) {
|
||||
return new Promise(() => {
|
||||
const error = new errors.NotFoundError(
|
||||
'Transaction has not been validated yet; try again later'
|
||||
)
|
||||
error.data = {
|
||||
details: '(ledger_index and LedgerSequence not found in tx)'
|
||||
}
|
||||
throw error
|
||||
})
|
||||
}
|
||||
|
||||
const request: LedgerRequest = {
|
||||
command: 'ledger',
|
||||
ledger_index: ledgerVersion
|
||||
}
|
||||
|
||||
return client
|
||||
.request(request)
|
||||
.then((data) => {
|
||||
const close_time = data.result.ledger.close_time
|
||||
if (typeof close_time === 'number') {
|
||||
return {...tx, result: {...tx.result, date: close_time}}
|
||||
}
|
||||
throw new errors.UnexpectedError('Ledger missing close_time')
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error instanceof errors.UnexpectedError) {
|
||||
throw error
|
||||
}
|
||||
throw new errors.NotFoundError('Transaction ledger not found')
|
||||
})
|
||||
}
|
||||
|
||||
function isTransactionInRange(tx: any, options: TransactionOptions) {
|
||||
return (
|
||||
(!options.minLedgerVersion ||
|
||||
tx.result.ledger_index >= options.minLedgerVersion) &&
|
||||
(!options.maxLedgerVersion || tx.result.ledger_index <= options.maxLedgerVersion)
|
||||
)
|
||||
}
|
||||
|
||||
function convertError(
|
||||
connection: Connection,
|
||||
options: TransactionOptions,
|
||||
error: RippledError
|
||||
): Promise<Error> {
|
||||
let shouldUseNotFoundError = false
|
||||
if (
|
||||
(error.data && error.data.error === 'txnNotFound') ||
|
||||
error.message === 'txnNotFound'
|
||||
) {
|
||||
shouldUseNotFoundError = true
|
||||
}
|
||||
|
||||
// In the future, we should deprecate this error, instead passing through the one from rippled.
|
||||
const _error = shouldUseNotFoundError
|
||||
? new errors.NotFoundError('Transaction not found')
|
||||
: error
|
||||
|
||||
if (_error instanceof errors.NotFoundError) {
|
||||
return utils
|
||||
.hasCompleteLedgerRange(
|
||||
connection,
|
||||
options.minLedgerVersion,
|
||||
options.maxLedgerVersion
|
||||
)
|
||||
.then((hasCompleteLedgerRange) => {
|
||||
if (!hasCompleteLedgerRange) {
|
||||
return utils
|
||||
.isPendingLedgerVersion(connection, options.maxLedgerVersion)
|
||||
.then((isPendingLedgerVersion) => {
|
||||
return isPendingLedgerVersion
|
||||
? new errors.PendingLedgerVersionError()
|
||||
: new errors.MissingLedgerHistoryError()
|
||||
})
|
||||
}
|
||||
return _error
|
||||
})
|
||||
}
|
||||
return Promise.resolve(_error)
|
||||
}
|
||||
|
||||
function formatResponse(
|
||||
options: TransactionOptions,
|
||||
tx: any
|
||||
): FormattedTransactionType {
|
||||
if (tx.result.validated !== true || !isTransactionInRange(tx, options)) {
|
||||
throw new errors.NotFoundError('Transaction not found')
|
||||
}
|
||||
return parseTransaction(tx.result, options.includeRawTransaction)
|
||||
}
|
||||
|
||||
async function getTransaction(
|
||||
this: Client,
|
||||
id: string,
|
||||
options: TransactionOptions = {}
|
||||
): Promise<FormattedTransactionType> {
|
||||
validate.getTransaction({id, options})
|
||||
const _options = await utils.ensureLedgerVersion.call(this, options)
|
||||
try {
|
||||
const tx = await this.request({command: 'tx',
|
||||
transaction: id,
|
||||
binary: false
|
||||
})
|
||||
const txWithDate = await attachTransactionDate(this, tx)
|
||||
return formatResponse(_options, txWithDate)
|
||||
} catch (error) {
|
||||
throw await convertError(this.connection, _options, error)
|
||||
}
|
||||
}
|
||||
|
||||
export default getTransaction
|
||||
@@ -1,221 +0,0 @@
|
||||
import * as _ from 'lodash'
|
||||
import binary from 'ripple-binary-codec'
|
||||
import {computeTransactionHash} from '../common/hashes'
|
||||
import * as utils from './utils'
|
||||
import parseTransaction from './parse/transaction'
|
||||
import getTransaction from './transaction'
|
||||
import {validate, errors, ensureClassicAddress} from '../common'
|
||||
import {FormattedTransactionType} from '../transaction/types'
|
||||
import {Client} from '..'
|
||||
import {Connection} from '../client'
|
||||
import { AccountTxRequest } from '../models/methods'
|
||||
|
||||
export type TransactionsOptions = {
|
||||
start?: string
|
||||
limit?: number
|
||||
minLedgerVersion?: number
|
||||
maxLedgerVersion?: number
|
||||
earliestFirst?: boolean
|
||||
excludeFailures?: boolean
|
||||
initiated?: boolean
|
||||
counterparty?: string
|
||||
types?: Array<string>
|
||||
includeRawTransactions?: boolean
|
||||
binary?: boolean
|
||||
startTx?: FormattedTransactionType
|
||||
}
|
||||
|
||||
export type GetTransactionsResponse = Array<FormattedTransactionType>
|
||||
|
||||
function parseBinaryTransaction(transaction) {
|
||||
const tx = binary.decode(transaction.tx_blob)
|
||||
tx.hash = computeTransactionHash(tx)
|
||||
tx.ledger_index = transaction.ledger_index
|
||||
return {
|
||||
tx: tx,
|
||||
meta: binary.decode(transaction.meta),
|
||||
validated: transaction.validated
|
||||
}
|
||||
}
|
||||
|
||||
function parseAccountTxTransaction(tx, includeRawTransaction: boolean) {
|
||||
const _tx = tx.tx_blob ? parseBinaryTransaction(tx) : tx
|
||||
// rippled uses a different response format for 'account_tx' than 'tx'
|
||||
return parseTransaction(
|
||||
Object.assign({}, _tx.tx, {meta: _tx.meta, validated: _tx.validated}),
|
||||
includeRawTransaction
|
||||
)
|
||||
}
|
||||
|
||||
function counterpartyFilter(filters, tx: FormattedTransactionType) {
|
||||
if (tx.address === filters.counterparty) {
|
||||
return true
|
||||
}
|
||||
const specification: any = tx.specification
|
||||
if (
|
||||
specification &&
|
||||
((specification.destination &&
|
||||
specification.destination.address === filters.counterparty) ||
|
||||
specification.counterparty === filters.counterparty)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function transactionFilter(
|
||||
address: string,
|
||||
filters: TransactionsOptions,
|
||||
tx: FormattedTransactionType
|
||||
) {
|
||||
if (filters.excludeFailures && tx.outcome.result !== 'tesSUCCESS') {
|
||||
return false
|
||||
}
|
||||
if (filters.types && !filters.types.includes(tx.type)) {
|
||||
return false
|
||||
}
|
||||
if (filters.initiated === true && tx.address !== address) {
|
||||
return false
|
||||
}
|
||||
if (filters.initiated === false && tx.address === address) {
|
||||
return false
|
||||
}
|
||||
if (filters.counterparty && !counterpartyFilter(filters, tx)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function orderFilter(
|
||||
options: TransactionsOptions,
|
||||
tx: FormattedTransactionType
|
||||
) {
|
||||
return (
|
||||
!options.startTx ||
|
||||
(options.earliestFirst
|
||||
? utils.compareTransactions(tx, options.startTx) > 0
|
||||
: utils.compareTransactions(tx, options.startTx) < 0)
|
||||
)
|
||||
}
|
||||
|
||||
function formatPartialResponse(
|
||||
address: string,
|
||||
options: TransactionsOptions,
|
||||
data
|
||||
) {
|
||||
const parse = (tx) =>
|
||||
parseAccountTxTransaction(tx, options.includeRawTransactions)
|
||||
return {
|
||||
marker: data.result.marker,
|
||||
results: data.result.transactions
|
||||
.filter((tx) => tx.validated)
|
||||
.map(parse)
|
||||
.filter(_.partial(transactionFilter, address, options))
|
||||
.filter(_.partial(orderFilter, options))
|
||||
}
|
||||
}
|
||||
|
||||
function getAccountTx(
|
||||
connection: Connection,
|
||||
address: string,
|
||||
options: TransactionsOptions,
|
||||
marker: string,
|
||||
limit: number
|
||||
) {
|
||||
const request: AccountTxRequest = {
|
||||
command: 'account_tx',
|
||||
account: address,
|
||||
// -1 is equivalent to earliest available validated ledger
|
||||
ledger_index_min: options.minLedgerVersion || -1,
|
||||
// -1 is equivalent to most recent available validated ledger
|
||||
ledger_index_max: options.maxLedgerVersion || -1,
|
||||
forward: options.earliestFirst,
|
||||
binary: options.binary,
|
||||
limit: utils.clamp(limit, 10, 400),
|
||||
marker: marker
|
||||
}
|
||||
|
||||
return connection
|
||||
.request(request)
|
||||
.then((response) => formatPartialResponse(address, options, response))
|
||||
}
|
||||
|
||||
function checkForLedgerGaps(
|
||||
connection: Connection,
|
||||
options: TransactionsOptions,
|
||||
transactions: GetTransactionsResponse
|
||||
) {
|
||||
let {minLedgerVersion, maxLedgerVersion} = options
|
||||
|
||||
// if we reached the limit on number of transactions, then we can shrink
|
||||
// the required ledger range to only guarantee that there are no gaps in
|
||||
// the range of ledgers spanned by those transactions
|
||||
if (options.limit && transactions.length === options.limit) {
|
||||
if (options.earliestFirst) {
|
||||
maxLedgerVersion = transactions[transactions.length-1]!.outcome.ledgerVersion
|
||||
} else {
|
||||
minLedgerVersion = transactions[transactions.length-1]!.outcome.ledgerVersion
|
||||
}
|
||||
}
|
||||
|
||||
return utils
|
||||
.hasCompleteLedgerRange(connection, minLedgerVersion, maxLedgerVersion)
|
||||
.then((hasCompleteLedgerRange) => {
|
||||
if (!hasCompleteLedgerRange) {
|
||||
throw new errors.MissingLedgerHistoryError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function formatResponse(
|
||||
connection: Connection,
|
||||
options: TransactionsOptions,
|
||||
transactions: GetTransactionsResponse
|
||||
) {
|
||||
const sortedTransactions = options.earliestFirst
|
||||
? transactions.sort(utils.compareTransactions)
|
||||
: transactions.sort(utils.compareTransactions).reverse()
|
||||
return checkForLedgerGaps(connection, options, sortedTransactions).then(
|
||||
() => sortedTransactions
|
||||
)
|
||||
}
|
||||
|
||||
function getTransactionsInternal(
|
||||
connection: Connection,
|
||||
address: string,
|
||||
options: TransactionsOptions
|
||||
): Promise<GetTransactionsResponse> {
|
||||
const getter = _.partial(getAccountTx, connection, address, options)
|
||||
const format = _.partial(formatResponse, connection, options)
|
||||
return utils.getRecursive(getter, options.limit).then(format)
|
||||
}
|
||||
|
||||
function getTransactions(
|
||||
this: Client,
|
||||
address: string,
|
||||
options: TransactionsOptions = {}
|
||||
): Promise<GetTransactionsResponse> {
|
||||
validate.getTransactions({address, options})
|
||||
|
||||
// Only support retrieving transactions without a tag,
|
||||
// since we currently do not filter transactions based
|
||||
// on tag. Apps must interpret and use tags
|
||||
// independently, filtering transactions if needed.
|
||||
address = ensureClassicAddress(address)
|
||||
|
||||
const defaults = {maxLedgerVersion: -1}
|
||||
if (options.start) {
|
||||
return getTransaction.call(this, options.start).then((tx) => {
|
||||
const ledgerVersion = tx.outcome.ledgerVersion
|
||||
const bound = options.earliestFirst
|
||||
? {minLedgerVersion: ledgerVersion}
|
||||
: {maxLedgerVersion: ledgerVersion}
|
||||
const startOptions = Object.assign({}, defaults, options, {startTx: tx}, bound)
|
||||
return getTransactionsInternal(this.connection, address, startOptions)
|
||||
})
|
||||
}
|
||||
const newOptions = Object.assign({}, defaults, options)
|
||||
return getTransactionsInternal(this.connection, address, newOptions)
|
||||
}
|
||||
|
||||
export default getTransactions
|
||||
@@ -1,4 +1,5 @@
|
||||
import { LedgerEntry } from ".";
|
||||
import { Transaction } from "../transactions";
|
||||
|
||||
export interface Ledger {
|
||||
account_hash: string
|
||||
@@ -14,5 +15,5 @@ export interface Ledger {
|
||||
parent_hash: string
|
||||
total_coins: string
|
||||
transaction_hash: string
|
||||
transactions?: any[] // TODO: Retype this once we have transaction types
|
||||
transactions?: Transaction[]
|
||||
}
|
||||
|
||||
@@ -30,9 +30,14 @@ interface LedgerQueueData {
|
||||
max_spend_drops?: string
|
||||
}
|
||||
|
||||
interface BinaryLedger extends Omit<Omit<Ledger, 'transactions'>, 'accountState'> {
|
||||
accountState?: string[]
|
||||
transactions?: string[]
|
||||
}
|
||||
|
||||
export interface LedgerResponse extends BaseResponse {
|
||||
result: {
|
||||
ledger: Ledger
|
||||
ledger: Ledger | BinaryLedger
|
||||
ledger_hash: string
|
||||
ledger_index: number
|
||||
queue_data?: (LedgerQueueData | string)[]
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// Deprecated - use client.request instead:
|
||||
// const response = await client.request({
|
||||
// command: 'submit',
|
||||
// tx_blob: signedTransaction,
|
||||
// fail_hard: failHard
|
||||
// });
|
||||
|
||||
import * as utils from './utils'
|
||||
import {validate} from '../common'
|
||||
import {Client} from '..'
|
||||
|
||||
export interface FormattedSubmitResponse {
|
||||
resultCode: string
|
||||
resultMessage: string
|
||||
}
|
||||
|
||||
function isImmediateRejection(engineResult: string): boolean {
|
||||
// note: "tel" errors mean the local server refused to process the
|
||||
// transaction *at that time*, but it could potentially buffer the
|
||||
// transaction and then process it at a later time, for example
|
||||
// if the required fee changes (this does not occur at the time of
|
||||
// this writing, but it could change in the future)
|
||||
// all other error classes can potentially result in transaction validation
|
||||
return engineResult.startsWith('tem')
|
||||
}
|
||||
|
||||
function formatSubmitResponse(response): FormattedSubmitResponse {
|
||||
const data = {
|
||||
// @deprecated
|
||||
resultCode: response.engine_result,
|
||||
// @deprecated
|
||||
resultMessage: response.engine_result_message,
|
||||
engine_result: response.engine_result,
|
||||
engine_result_code: response.engine_result_code,
|
||||
engine_result_message: response.engine_result_message,
|
||||
tx_blob: response.tx_blob,
|
||||
tx_json: response.tx_json
|
||||
}
|
||||
if (isImmediateRejection(response.engine_result)) {
|
||||
throw new utils.common.errors.RippledError('Submit failed', data)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// @deprecated Use client.request({ command: 'submit' tx_blob: signedTransaction }) instead
|
||||
async function submit(
|
||||
this: Client,
|
||||
signedTransaction: string,
|
||||
failHard?: boolean
|
||||
): Promise<FormattedSubmitResponse> {
|
||||
// 1. Validate
|
||||
validate.submit({signedTransaction})
|
||||
// 2. Make Request
|
||||
const response = await this.request({command: 'submit',
|
||||
tx_blob: signedTransaction,
|
||||
...(failHard ? {fail_hard: failHard} : {})
|
||||
})
|
||||
// 3. Return Formatted Response
|
||||
return formatSubmitResponse(response.result)
|
||||
}
|
||||
|
||||
export default submit
|
||||
@@ -26,7 +26,7 @@ describe('BroadcastClient', function () {
|
||||
this.mocks.forEach((mock) => mock.expect(Object.assign({}, expected)))
|
||||
assert(this.client.isConnected())
|
||||
return this.client
|
||||
.getServerInfo()
|
||||
.request({command: "server_info"})
|
||||
.then(response => {
|
||||
return checkResult(responses.getServerInfo, response.result.info)
|
||||
})
|
||||
|
||||
@@ -4,6 +4,10 @@ import responses from '../../fixtures/responses'
|
||||
import {assertResultMatch, TestSuite} from '../../utils'
|
||||
const {computeLedgerHash: REQUEST_FIXTURES} = requests
|
||||
|
||||
function getNewLedger() {
|
||||
return JSON.parse(JSON.stringify(responses.getLedger.full))
|
||||
}
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
@@ -11,18 +15,12 @@ const {computeLedgerHash: REQUEST_FIXTURES} = requests
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'given corrupt data - should fail': async (client, address) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeState: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 38129
|
||||
}
|
||||
const ledger = await client.getLedger(request)
|
||||
assert.strictEqual(
|
||||
// @ts-ignore
|
||||
ledger.transactions[0].rawTransaction,
|
||||
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
|
||||
)
|
||||
const ledger = getNewLedger()
|
||||
// assert.strictEqual(
|
||||
// // @ts-ignore
|
||||
// ledger.transactions[0].rawTransaction,
|
||||
// '{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
|
||||
// )
|
||||
// @ts-ignore - Change Amount to 12000000000
|
||||
ledger.transactions[0].rawTransaction =
|
||||
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"12000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
|
||||
@@ -54,18 +52,12 @@ export default <TestSuite>{
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeState: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 38129
|
||||
}
|
||||
const ledger = await client.getLedger(request)
|
||||
assert.strictEqual(
|
||||
// @ts-ignore
|
||||
ledger.transactions[0].rawTransaction,
|
||||
'{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
|
||||
)
|
||||
const ledger = getNewLedger()
|
||||
// assert.strictEqual(
|
||||
// // @ts-ignore
|
||||
// ledger.transactions[0].rawTransaction,
|
||||
// '{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Amount":"10000000000","Destination":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Fee":"10","Flags":0,"Sequence":62,"SigningPubKey":"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E","TransactionType":"Payment","TxnSignature":"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639","hash":"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF","meta":{"AffectedNodes":[{"CreatedNode":{"LedgerEntryType":"AccountRoot","LedgerIndex":"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E","NewFields":{"Account":"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj","Balance":"10000000000","Sequence":1}}},{"ModifiedNode":{"FinalFields":{"Account":"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV","Balance":"981481999380","Flags":0,"OwnerCount":0,"Sequence":63},"LedgerEntryType":"AccountRoot","LedgerIndex":"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A","PreviousFields":{"Balance":"991481999390","Sequence":62},"PreviousTxnID":"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F","PreviousTxnLgrSeq":31317}}],"TransactionIndex":0,"TransactionResult":"tesSUCCESS"},"ledger_index":38129}'
|
||||
// )
|
||||
// Delete rawTransaction
|
||||
// @ts-ignore - Delete rawTransaction
|
||||
delete ledger.transactions[0].rawTransaction
|
||||
@@ -91,13 +83,7 @@ export default <TestSuite>{
|
||||
client,
|
||||
address
|
||||
) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeState: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 38129
|
||||
}
|
||||
const ledger = await client.getLedger(request)
|
||||
const ledger = getNewLedger()
|
||||
assert.strictEqual(
|
||||
// @ts-ignore
|
||||
ledger.transactions[0].rawTransaction,
|
||||
@@ -136,14 +122,8 @@ export default <TestSuite>{
|
||||
},
|
||||
|
||||
'wrong hash': async (client, address) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeState: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 38129
|
||||
}
|
||||
const ledger = await client.getLedger(request)
|
||||
assertResultMatch(ledger, responses.getLedger.full, 'getLedger')
|
||||
const ledger = getNewLedger()
|
||||
assertResultMatch(ledger, getNewLedger(), 'getLedger')
|
||||
const newLedger = {
|
||||
...ledger,
|
||||
parentCloseTime: ledger.closeTime,
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import assert from 'assert'
|
||||
import _ from 'lodash'
|
||||
import responses from '../../fixtures/rippled'
|
||||
import {assertRejects, TestSuite} from '../../utils'
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getAccountInfo': async (client, address) => {
|
||||
const response = await client.getAccountInfo(address)
|
||||
assert.deepEqual(
|
||||
_.omit(response, 'id'),
|
||||
_.omit(responses.account_info.normal, 'id'),
|
||||
)
|
||||
},
|
||||
|
||||
'getAccountInfo - options undefined': async (client, address) => {
|
||||
const response = await client.getAccountInfo(address, undefined)
|
||||
assert.deepEqual(
|
||||
_.omit(response, 'id'),
|
||||
_.omit(responses.account_info.normal, 'id'),
|
||||
)
|
||||
},
|
||||
|
||||
'getAccountInfo - invalid options': async (client, address) => {
|
||||
await assertRejects(
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
client.getAccountInfo(address, {invalid: 'options'}),
|
||||
client.errors.ValidationError
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import responses from '../../fixtures/responses'
|
||||
import {TestSuite, assertResultMatch} from '../../utils'
|
||||
const {getAccountObjects: RESPONSE_FIXTURES} = responses
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getAccountObjects': async (client, address) => {
|
||||
const result = await client.getAccountObjects(address)
|
||||
assertResultMatch(result.result, RESPONSE_FIXTURES, 'AccountObjectsResponse')
|
||||
},
|
||||
|
||||
'getAccountObjects - invalid options': async (client, address) => {
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
const result = await client.getAccountObjects(address, {invalid: 'options'})
|
||||
assertResultMatch(result.result, RESPONSE_FIXTURES, 'AccountObjectsResponse')
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getBalanceSheet': async (client, address) => {
|
||||
await client.getBalanceSheet(address)
|
||||
},
|
||||
|
||||
'getBalanceSheet - invalid options': async (client, address) => {
|
||||
await assertRejects(
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
client.getBalanceSheet(address, {invalid: 'options'}),
|
||||
client.errors.ValidationError
|
||||
)
|
||||
},
|
||||
|
||||
'getBalanceSheet - empty': async (client, address) => {
|
||||
const options = {ledgerVersion: 123456}
|
||||
const result = await client.getBalanceSheet(address, options)
|
||||
assertResultMatch(result, {}, 'getBalanceSheet')
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
import assert from 'assert-diff'
|
||||
import {assertResultMatch, TestSuite} from '../../utils'
|
||||
import responses from '../../fixtures/responses'
|
||||
const {getLedger: RESPONSE_FIXTURES} = responses
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'simple test': async (client) => {
|
||||
const response = await client.getLedger()
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.header, 'getLedger')
|
||||
},
|
||||
'by hash': async (client) => {
|
||||
const response = await client.getLedger({
|
||||
ledgerHash:
|
||||
'15F20E5FA6EA9770BBFFDBD62787400960B04BE32803B20C41F117F41C13830D'
|
||||
})
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.headerByHash, 'getLedger')
|
||||
},
|
||||
'future ledger version': async (client) => {
|
||||
const response = await client.getLedger({ledgerVersion: 14661789})
|
||||
assert(!!response)
|
||||
},
|
||||
'with state as hashes': async (client) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeAllData: false,
|
||||
includeState: true,
|
||||
ledgerVersion: 6
|
||||
}
|
||||
const response = await client.getLedger(request)
|
||||
assertResultMatch(
|
||||
response,
|
||||
RESPONSE_FIXTURES.withStateAsHashes,
|
||||
'getLedger'
|
||||
)
|
||||
},
|
||||
'with settings transaction': async (client) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 4181996
|
||||
}
|
||||
const response = await client.getLedger(request)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.withSettingsTx, 'getLedger')
|
||||
},
|
||||
'with partial payment': async (client) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 22420574
|
||||
}
|
||||
const response = await client.getLedger(request)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.withPartial, 'getLedger')
|
||||
},
|
||||
'pre 2014 with partial payment': async (client) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 100001
|
||||
}
|
||||
const response = await client.getLedger(request)
|
||||
assertResultMatch(
|
||||
response,
|
||||
RESPONSE_FIXTURES.pre2014withPartial,
|
||||
'getLedger'
|
||||
)
|
||||
},
|
||||
'full, then computeLedgerHash': async (client) => {
|
||||
const request = {
|
||||
includeTransactions: true,
|
||||
includeState: true,
|
||||
includeAllData: true,
|
||||
ledgerVersion: 38129
|
||||
}
|
||||
const response = await client.getLedger(request)
|
||||
assertResultMatch(response, RESPONSE_FIXTURES.full, 'getLedger')
|
||||
const ledger = {
|
||||
...response,
|
||||
parentCloseTime: response.closeTime
|
||||
}
|
||||
const hash = client.computeLedgerHash(ledger, {computeTreeHashes: true})
|
||||
assert.strictEqual(
|
||||
hash,
|
||||
'E6DB7365949BF9814D76BCC730B01818EB9136A89DB224F3F9F5AAE4569D758E'
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import responses from '../../fixtures/responses'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getOrders': async (client, address) => {
|
||||
const result = await client.getOrders(address)
|
||||
assertResultMatch(result, responses.getOrders, 'getOrders')
|
||||
},
|
||||
|
||||
'getOrders - limit': async (client, address) => {
|
||||
const result = await client.getOrders(address, {limit: 20})
|
||||
assertResultMatch(result, responses.getOrders, 'getOrders')
|
||||
},
|
||||
|
||||
'getOrders - invalid options': async (client, address) => {
|
||||
await assertRejects(
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
client.getOrders(address, {invalid: 'options'}),
|
||||
client.errors.ValidationError
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import responses from '../../fixtures/responses'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
|
||||
const {getPaymentChannel: RESPONSE_FIXTURES} = responses
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getPaymentChannel': async (client, address) => {
|
||||
const channelId =
|
||||
'E30E709CF009A1F26E0E5C48F7AA1BFB79393764F15FB108BDC6E06D3CBD8415'
|
||||
const result = await client.getPaymentChannel(channelId)
|
||||
assertResultMatch(result, RESPONSE_FIXTURES.normal, 'getPaymentChannel')
|
||||
},
|
||||
|
||||
'getPaymentChannel - full': async (client, address) => {
|
||||
const channelId =
|
||||
'D77CD4713AA08195E6B6D0E5BC023DA11B052EBFF0B5B22EDA8AE85345BCF661'
|
||||
const result = await client.getPaymentChannel(channelId)
|
||||
assertResultMatch(result, RESPONSE_FIXTURES.full, 'getPaymentChannel')
|
||||
},
|
||||
|
||||
'getPaymentChannel - not found': async (client, address) => {
|
||||
const channelId =
|
||||
'DFA557EA3497585BFE83F0F97CC8E4530BBB99967736BB95225C7F0C13ACE708'
|
||||
await assertRejects(
|
||||
client.getPaymentChannel(channelId),
|
||||
client.errors.RippledError,
|
||||
'entryNotFound'
|
||||
)
|
||||
},
|
||||
|
||||
'getPaymentChannel - wrong type': async (client, address) => {
|
||||
const channelId =
|
||||
'8EF9CCB9D85458C8D020B3452848BBB42EAFDDDB69A93DD9D1223741A4CA562B'
|
||||
await assertRejects(
|
||||
client.getPaymentChannel(channelId),
|
||||
client.errors.NotFoundError,
|
||||
'Payment channel ledger entry not found'
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import assert from 'assert-diff'
|
||||
import responses from '../../fixtures/responses'
|
||||
import {assertResultMatch, TestSuite, assertRejects} from '../../utils'
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'default': async (client, address) => {
|
||||
const serverInfo = await client.getServerInfo()
|
||||
assertResultMatch(serverInfo.result.info, responses.getServerInfo, 'getServerInfo')
|
||||
},
|
||||
|
||||
'error': async (client, address) => {
|
||||
client.connection.request({
|
||||
// @ts-ignore TODO: resolve
|
||||
command: 'config',
|
||||
data: {returnErrorOnServerInfo: true}
|
||||
})
|
||||
try {
|
||||
await client.getServerInfo()
|
||||
throw new Error('Should throw NetworkError')
|
||||
} catch (err) {
|
||||
assert(err instanceof client.errors.RippledError)
|
||||
assert.equal(err.message, 'You are placing too much load on the server.')
|
||||
assert.equal(err.data.error, 'slowDown')
|
||||
}
|
||||
},
|
||||
|
||||
'no validated ledger': async (client, address) => {
|
||||
client.connection.request({
|
||||
// @ts-ignore TODO: resolve
|
||||
command: 'config',
|
||||
data: {serverInfoWithoutValidated: true}
|
||||
})
|
||||
const serverInfo = await client.getServerInfo()
|
||||
assert.strictEqual(serverInfo.result.info.network_ledger, 'waiting')
|
||||
},
|
||||
|
||||
'getServerInfo - offline': async (client, address) => {
|
||||
await client.disconnect()
|
||||
return assertRejects(client.getServerInfo(), client.errors.NotConnectedError)
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import responses from '../../fixtures/responses'
|
||||
import {assertRejects, assertResultMatch, TestSuite} from '../../utils'
|
||||
const {getSettings: RESPONSE_FIXTURES} = responses
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getSettings': async (client, address) => {
|
||||
const result = await client.getSettings(address)
|
||||
assertResultMatch(result, RESPONSE_FIXTURES, 'getSettings')
|
||||
},
|
||||
|
||||
'getSettings - options undefined': async (client, address) => {
|
||||
const result = await client.getSettings(address, undefined)
|
||||
assertResultMatch(result, RESPONSE_FIXTURES, 'getSettings')
|
||||
},
|
||||
|
||||
'getSettings - invalid options': async (client, address) => {
|
||||
await assertRejects(
|
||||
// @ts-ignore - This is intentionally invalid
|
||||
client.getSettings(address, {invalid: 'options'}),
|
||||
client.errors.ValidationError
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,508 +0,0 @@
|
||||
// import assert from 'assert-diff'
|
||||
import {
|
||||
MissingLedgerHistoryError,
|
||||
NotFoundError,
|
||||
// UnexpectedError
|
||||
} from 'xrpl-local/common/errors'
|
||||
import {PendingLedgerVersionError} from '../../../src/common/errors'
|
||||
import hashes from '../../fixtures/hashes.json'
|
||||
// import responses from '../../fixtures/responses'
|
||||
import ledgerClosed from '../../fixtures/rippled/ledger-close-newer.json'
|
||||
import {assertRejects, TestSuite} from '../../utils'
|
||||
// const {getTransaction: RESPONSE_FIXTURES} = responses
|
||||
|
||||
function closeLedger(connection) {
|
||||
connection._ws.emit('message', JSON.stringify(ledgerClosed))
|
||||
}
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
// 'payment': async (client, address) => {
|
||||
// const response = await client.getTransaction(hashes.VALID_TRANSACTION_HASH)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.payment, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'payment - include raw transaction': async (client, address) => {
|
||||
// const options = {
|
||||
// includeRawTransaction: true
|
||||
// }
|
||||
// const response = await client.getTransaction(
|
||||
// hashes.VALID_TRANSACTION_HASH,
|
||||
// options
|
||||
// )
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentIncludeRawTransaction,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'settings': async (client, address) => {
|
||||
// const hash =
|
||||
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.settings, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'settings - include raw transaction': async (client, address) => {
|
||||
// const hash =
|
||||
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
|
||||
// const options = {
|
||||
// includeRawTransaction: true
|
||||
// }
|
||||
// const expected = Object.assign({}, RESPONSE_FIXTURES.settings) // Avoid mutating test fixture
|
||||
// expected.rawTransaction =
|
||||
// '{"Account":"rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe","Fee":"10","Flags":2147483648,"Sequence":1,"SetFlag":2,"SigningPubKey":"03EA3ADCA632F125EC2CC4F7F6A82DE0DCE2B65290CAC1F22242C5163F0DA9652D","TransactionType":"AccountSet","TxnSignature":"3045022100DE8B666B1A31EA65011B0F32130AB91A5747E32FA49B3054CEE8E8362DBAB98A022040CF0CF254677A8E5CD04C59CA2ED7F6F15F7E184641BAE169C561650967B226","date":460832270,"hash":"4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B","inLedger":8206418,"ledger_index":8206418,"meta":{"AffectedNodes":[{"ModifiedNode":{"FinalFields":{"Account":"rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe","Balance":"29999990","Flags":786432,"OwnerCount":0,"Sequence":2},"LedgerEntryType":"AccountRoot","LedgerIndex":"3F5072C4875F32ED770DAF3610A716600ED7C7BB0348FADC7A98E011BB2CD36F","PreviousFields":{"Balance":"30000000","Flags":4194304,"Sequence":1},"PreviousTxnID":"3FB0350A3742BBCC0D8AA3C5247D1AEC01177D0A24D9C34762BAA2FEA8AD88B3","PreviousTxnLgrSeq":8206397}}],"TransactionIndex":5,"TransactionResult":"tesSUCCESS"},"validated":true}'
|
||||
// const response = await client.getTransaction(hash, options)
|
||||
// assertResultMatch(response, expected, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'order': async (client, address) => {
|
||||
// const hash =
|
||||
// '10A6FB4A66EE80BED46AAE4815D7DC43B97E944984CCD5B93BCF3F8538CABC51'
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.order, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'order with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_OFFER_CREATE_TRANSACTION_HASH
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.orderWithMemo, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'sell order': async (client, address) => {
|
||||
// const hash =
|
||||
// '458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.orderSell, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'order cancellation': async (client, address) => {
|
||||
// const hash =
|
||||
// '809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E'
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.orderCancellation,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'order with expiration cancellation': async (client, address) => {
|
||||
// const hash =
|
||||
// '097B9491CC76B64831F1FEA82EAA93BCD728106D90B65A072C933888E946C40B'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.orderWithExpirationCancellation,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'order cancellation with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_ORDER_CANCELLATION_TRANSACTION_HASH
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.orderCancellationWithMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'trustline set': async (client, address) => {
|
||||
// const hash =
|
||||
// '635A0769BD94710A1F6A76CDE65A3BC661B20B798807D1BBBDADCEA26420538D'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.trustline, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'trustline frozen off': async (client, address) => {
|
||||
// const hash =
|
||||
// 'FE72FAD0FA7CA904FB6C633A1666EDF0B9C73B2F5A4555D37EEF2739A78A531B'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.trustlineFrozenOff,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'trustline no quality': async (client, address) => {
|
||||
// const hash =
|
||||
// 'BAF1C678323C37CCB7735550C379287667D8288C30F83148AD3C1CB019FC9002'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.trustlineNoQuality,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'trustline add memo': async (client, address) => {
|
||||
// const hash =
|
||||
// '9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.trustlineAddMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'not validated': async (client, address) => {
|
||||
// const hash =
|
||||
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10'
|
||||
// await assertRejects(
|
||||
// client.getTransaction(hash),
|
||||
// NotFoundError,
|
||||
// 'Transaction not found'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'tracking on': async (client, address) => {
|
||||
// const hash =
|
||||
// '8925FC8844A1E930E2CC76AD0A15E7665AFCC5425376D548BB1413F484C31B8C'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.trackingOn, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'tracking off': async (client, address) => {
|
||||
// const hash =
|
||||
// 'C8C5E20DFB1BF533D0D81A2ED23F0A3CBD1EF2EE8A902A1D760500473CC9C582'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.trackingOff, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'set regular key': async (client, address) => {
|
||||
// const hash =
|
||||
// '278E6687C1C60C6873996210A6523564B63F2844FB1019576C157353B1813E60'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.setRegularKey,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
'not found in range': async (client, address) => {
|
||||
const hash =
|
||||
'809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E'
|
||||
const options = {
|
||||
minLedgerVersion: 32570,
|
||||
maxLedgerVersion: 32571
|
||||
}
|
||||
await assertRejects(client.getTransaction(hash, options), NotFoundError)
|
||||
},
|
||||
|
||||
'not found by hash': async (client, address) => {
|
||||
const hash = hashes.NOTFOUND_TRANSACTION_HASH
|
||||
|
||||
await assertRejects(client.getTransaction(hash), NotFoundError)
|
||||
},
|
||||
|
||||
'missing ledger history': async (client, address) => {
|
||||
const hash = hashes.NOTFOUND_TRANSACTION_HASH
|
||||
// make gaps in history
|
||||
closeLedger(client.connection)
|
||||
|
||||
await assertRejects(client.getTransaction(hash), MissingLedgerHistoryError)
|
||||
},
|
||||
|
||||
'missing ledger history with ledger range': async (client, address) => {
|
||||
const hash = hashes.NOTFOUND_TRANSACTION_HASH
|
||||
const options = {
|
||||
minLedgerVersion: 32569,
|
||||
maxLedgerVersion: 32571
|
||||
}
|
||||
await assertRejects(
|
||||
client.getTransaction(hash, options),
|
||||
MissingLedgerHistoryError
|
||||
)
|
||||
},
|
||||
|
||||
'not found - future maxLedgerVersion': async (client, address) => {
|
||||
const hash = hashes.NOTFOUND_TRANSACTION_HASH
|
||||
const options = {
|
||||
maxLedgerVersion: 99999999999
|
||||
}
|
||||
await assertRejects(
|
||||
client.getTransaction(hash, options),
|
||||
PendingLedgerVersionError,
|
||||
"maxLedgerVersion is greater than server's most recent validated ledger"
|
||||
)
|
||||
},
|
||||
|
||||
'transaction not validated': async (client, address) => {
|
||||
const hash =
|
||||
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA11'
|
||||
await assertRejects(
|
||||
client.getTransaction(hash),
|
||||
NotFoundError,
|
||||
/Transaction has not been validated yet/
|
||||
)
|
||||
},
|
||||
|
||||
// 'transaction ledger not found': async (client, address) => {
|
||||
// const hash =
|
||||
// '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA12'
|
||||
// await assertRejects(
|
||||
// client.getTransaction(hash),
|
||||
// NotFoundError,
|
||||
// /ledger not found/
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'ledger missing close time': async (client, address) => {
|
||||
// const hash =
|
||||
// '0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A04'
|
||||
// closeLedger(client.connection)
|
||||
// await assertRejects(client.getTransaction(hash), UnexpectedError)
|
||||
// },
|
||||
|
||||
// Checks
|
||||
// 'CheckCreate': async (client, address) => {
|
||||
// const hash =
|
||||
// '605A2E2C8E48AECAF5C56085D1AEAA0348DC838CE122C9188F94EB19DA05C2FE'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCreate, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'CheckCreate with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_CHECK_CREATE_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCreateWithMemo, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'CheckCancel': async (client, address) => {
|
||||
// const hash =
|
||||
// 'B4105D1B2D83819647E4692B7C5843D674283F669524BD50C9614182E3A12CD4'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCancel, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'CheckCancel with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_CHECK_CANCEL_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCancelWithMemo, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'CheckCash': async (client, address) => {
|
||||
// const hash =
|
||||
// '8321208465F70BA52C28BCC4F646BAF3B012BA13B57576C0336F42D77E3E0749'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCash, 'getTransaction')
|
||||
// },
|
||||
|
||||
// 'CheckCash with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_CHECK_CASH_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.checkCashWithMemo, 'getTransaction')
|
||||
// },
|
||||
|
||||
// Escrows
|
||||
// 'EscrowCreation': async (client, address) => {
|
||||
// const hash =
|
||||
// '144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE1'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.escrowCreation,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'EscrowCancellation': async (client, address) => {
|
||||
// const hash =
|
||||
// 'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.escrowCancellation,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'EscrowExecution': async (client, address) => {
|
||||
// const options = {
|
||||
// minLedgerVersion: 10,
|
||||
// maxLedgerVersion: 15
|
||||
// }
|
||||
// const hash =
|
||||
// 'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD136993B'
|
||||
// const response = await client.getTransaction(hash, options)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.escrowExecution,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'EscrowExecution simple': async (client, address) => {
|
||||
// const hash =
|
||||
// 'CC5277137B3F25EE8B86259C83CB0EAADE818505E4E9BCBF19B1AC6FD1369931'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.escrowExecutionSimple,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelCreate': async (client, address) => {
|
||||
// const hash =
|
||||
// '0E9CA3AB1053FC0C1CBAA75F636FE1EC92F118C7056BBEF5D63E4C116458A16D'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelCreate,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelCreate with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_CREATE_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelCreateWithMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelFund': async (client, address) => {
|
||||
// const hash =
|
||||
// 'CD053D8867007A6A4ACB7A432605FE476D088DCB515AFFC886CF2B4EB6D2AE8B'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelFund,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelFund with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_FUND_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelFundWithMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelClaim': async (client, address) => {
|
||||
// const hash =
|
||||
// '81B9ECAE7195EB6E8034AEDF44D8415A7A803E14513FDBB34FA984AB37D59563'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelClaim,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'PaymentChannelClaim with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_PAYMENT_CHANNEL_CLAIM_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.paymentChannelClaimWithMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'AccountDelete': async (client, address) => {
|
||||
// const hash =
|
||||
// 'EC2AB14028DC84DE525470AB4DAAA46358B50A8662C63804BFF38244731C0CB9'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.accountDelete,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'AccountDelete with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_ACCOUNT_DELETE_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.accountDeleteWithMemo,
|
||||
// 'getTransaction'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'no Meta': async (client, address) => {
|
||||
// const hash =
|
||||
// 'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assert.deepEqual(response, RESPONSE_FIXTURES.noMeta)
|
||||
// },
|
||||
|
||||
// 'Unrecognized transaction type': async (client, address) => {
|
||||
// const hash =
|
||||
// 'AFB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA11'
|
||||
// closeLedger(client.connection)
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assert.strictEqual(
|
||||
// // @ts-ignore
|
||||
// response.specification.UNAVAILABLE,
|
||||
// 'Unrecognized transaction type.'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'amendment': async (client, address) => {
|
||||
// const hash =
|
||||
// 'A971B83ABED51D83749B73F3C1AAA627CD965AFF74BE8CD98299512D6FB0658F'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.amendment)
|
||||
// },
|
||||
|
||||
// 'feeUpdate': async (client, address) => {
|
||||
// const hash =
|
||||
// 'C6A40F56127436DCD830B1B35FF939FD05B5747D30D6542572B7A835239817AF'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.feeUpdate)
|
||||
// },
|
||||
|
||||
// 'feeUpdate with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_FEE_UPDATE_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.feeUpdateWithMemo)
|
||||
// },
|
||||
|
||||
// 'order with one memo': async (client, address) => {
|
||||
// const hash =
|
||||
// '995570FE1E40F42DF56BFC80503BA9E3C1229619C61A1C279A76BC0805036D74'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.withMemo)
|
||||
// },
|
||||
|
||||
// 'order with more than one memo': async (client, address) => {
|
||||
// const hash =
|
||||
// '995570FE1E40F42DF56BFC80503BA9E3C1229619C61A1C279A76BC0805036D73'
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.withMemos)
|
||||
// },
|
||||
|
||||
// 'ticketCreate with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_TICKET_CREATE_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.ticketCreateWithMemo)
|
||||
// },
|
||||
|
||||
// 'depositPreauth with memo': async (client, address) => {
|
||||
// const hash = hashes.WITH_MEMOS_DEPOSIT_PREAUTH_TRANSACTION_HASH
|
||||
// const response = await client.getTransaction(hash)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.depositPreauthWithMemo)
|
||||
// }
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
// import {Client} from 'xrpl-local'
|
||||
// import assert from 'assert-diff'
|
||||
import { TestSuite, assertRejects} from '../../utils'
|
||||
// import responses from '../../fixtures/responses'
|
||||
import hashes from '../../fixtures/hashes.json'
|
||||
// import addresses from '../../fixtures/addresses.json'
|
||||
// const utils = Client._PRIVATE.ledgerUtils
|
||||
// const {getTransactions: RESPONSE_FIXTURES} = responses
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
// 'default': async (client, address) => {
|
||||
// const options = {types: ['payment', 'order'], initiated: true, limit: 2}
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.normal, 'getTransactions')
|
||||
// },
|
||||
|
||||
// 'include raw transactions': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: true,
|
||||
// limit: 2,
|
||||
// includeRawTransactions: true
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// assertResultMatch(
|
||||
// response,
|
||||
// RESPONSE_FIXTURES.includeRawTransactions,
|
||||
// 'getTransactions'
|
||||
// )
|
||||
// },
|
||||
|
||||
// 'earliest first': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: true,
|
||||
// limit: 2,
|
||||
// earliestFirst: true
|
||||
// }
|
||||
// const expected = Array.from(RESPONSE_FIXTURES.normal as any[]).sort(
|
||||
// utils.compareTransactions
|
||||
// )
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assertResultMatch(response, expected, 'getTransactions')
|
||||
// },
|
||||
|
||||
// 'earliest first with start option': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: true,
|
||||
// limit: 2,
|
||||
// start: hashes.VALID_TRANSACTION_HASH,
|
||||
// earliestFirst: true
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// assert.strictEqual(response.length, 0)
|
||||
// },
|
||||
|
||||
// 'gap': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: true,
|
||||
// limit: 2,
|
||||
// maxLedgerVersion: 348858000
|
||||
// }
|
||||
// return assertRejects(
|
||||
// client.getTransactions(address, options),
|
||||
// client.errors.MissingLedgerHistoryError
|
||||
// )
|
||||
// },
|
||||
|
||||
'tx not found': async (client, address) => {
|
||||
const options = {
|
||||
types: ['payment', 'order'],
|
||||
initiated: true,
|
||||
limit: 2,
|
||||
start: hashes.NOTFOUND_TRANSACTION_HASH,
|
||||
counterparty: address
|
||||
}
|
||||
return assertRejects(
|
||||
client.getTransactions(address, options),
|
||||
client.errors.NotFoundError
|
||||
)
|
||||
},
|
||||
|
||||
// 'filters': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: true,
|
||||
// limit: 10,
|
||||
// excludeFailures: true,
|
||||
// counterparty: addresses.ISSUER
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assert.strictEqual(response.length, 10)
|
||||
// response.forEach((t) => assert(t.type === 'payment' || t.type === 'order'))
|
||||
// response.forEach((t) => assert(t.outcome.result === 'tesSUCCESS'))
|
||||
// },
|
||||
|
||||
// 'filters for incoming': async (client, address) => {
|
||||
// const options = {
|
||||
// types: ['payment', 'order'],
|
||||
// initiated: false,
|
||||
// limit: 10,
|
||||
// excludeFailures: true,
|
||||
// counterparty: addresses.ISSUER
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assert.strictEqual(response.length, 10)
|
||||
// response.forEach((t) => assert(t.type === 'payment' || t.type === 'order'))
|
||||
// response.forEach((t) => assert(t.outcome.result === 'tesSUCCESS'))
|
||||
// },
|
||||
|
||||
// this is the case where core.RippleError just falls
|
||||
// through the client to the user
|
||||
'error': async (client, address) => {
|
||||
const options = {types: ['payment', 'order'], initiated: true, limit: 13}
|
||||
return assertRejects(
|
||||
client.getTransactions(address, options),
|
||||
client.errors.RippleError
|
||||
)
|
||||
},
|
||||
|
||||
// TODO: this doesn't test much, just that it doesn't crash
|
||||
// 'getTransactions with start option': async (client, address) => {
|
||||
// const options = {
|
||||
// start: hashes.VALID_TRANSACTION_HASH,
|
||||
// earliestFirst: false,
|
||||
// limit: 2
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.normal, 'getTransactions')
|
||||
// },
|
||||
|
||||
// 'start transaction with zero ledger version': async (client, address) => {
|
||||
// const options = {
|
||||
// start: '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA13',
|
||||
// limit: 1
|
||||
// }
|
||||
// const response = await client.getTransactions(address, options)
|
||||
// hack(response)
|
||||
// assertResultMatch(response, [], 'getTransactions')
|
||||
// },
|
||||
|
||||
// 'no options': async (client, address) => {
|
||||
// const response = await client.getTransactions(addresses.OTHER_ACCOUNT)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.one, 'getTransactions')
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// This test relies on the binary (hex string) format, but computed fields like `date`
|
||||
// are not available in this format. To support this field, we need to 'hack' it into
|
||||
// the expected response. Long term, a better approach would be to use/test the json
|
||||
// format responses, instead of the binary.
|
||||
// function hack(response) {
|
||||
// response.forEach((element) => {
|
||||
// element.outcome.timestamp = '2019-04-01T07:39:01.000Z'
|
||||
// })
|
||||
// }
|
||||
@@ -1,19 +0,0 @@
|
||||
// import responses from '../../fixtures/responses'
|
||||
import {TestSuite} from '../../utils'
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
// 'submit': async (client, address) => {
|
||||
// const result = await client.submit(responses.sign.normal.signedTransaction)
|
||||
// assertResultMatch(result, responses.submit, 'submit')
|
||||
// },
|
||||
|
||||
// 'submit - failure': async (client, address) => {
|
||||
// await assertRejects(client.submit('BAD'), client.errors.RippledError)
|
||||
// // assert.strictEqual(error.data.resultCode, 'temBAD_FEE')
|
||||
// }
|
||||
}
|
||||
@@ -182,7 +182,7 @@ describe('Connection', function () {
|
||||
data: {disconnectOnServerInfo: true}
|
||||
})
|
||||
return this.client
|
||||
.getServerInfo()
|
||||
.request({command: "server_info"})
|
||||
.then(() => {
|
||||
assert(false, 'Should throw DisconnectedError')
|
||||
})
|
||||
@@ -211,7 +211,7 @@ describe('Connection', function () {
|
||||
callback({message: 'not connected'})
|
||||
}
|
||||
return this.client
|
||||
.getServerInfo()
|
||||
.request({command: "server_info"})
|
||||
.then(() => {
|
||||
assert(false, 'Should throw DisconnectedError')
|
||||
})
|
||||
|
||||
83
test/fixtures/responses/get-ledger-full.json
vendored
83
test/fixtures/responses/get-ledger-full.json
vendored
@@ -11,46 +11,51 @@
|
||||
"transactionHash": "DB83BF807416C5B3499A73130F843CF615AB8E797D79FE7D330ADF1BFA93951A",
|
||||
"transactions": [
|
||||
{
|
||||
"type": "payment",
|
||||
"address": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||
"sequence": 62,
|
||||
"id": "3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF",
|
||||
"specification": {
|
||||
"source": {
|
||||
"address": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||
"maxAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "10000"
|
||||
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||
"Amount": "10000000000",
|
||||
"Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
|
||||
"Fee": "10",
|
||||
"Flags": 0,
|
||||
"Sequence": 62,
|
||||
"SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E",
|
||||
"TransactionType": "Payment",
|
||||
"TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639",
|
||||
"hash": "3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF",
|
||||
"metaData": {
|
||||
"AffectedNodes": [
|
||||
{
|
||||
"CreatedNode": {
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E",
|
||||
"NewFields": {
|
||||
"Account": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
|
||||
"Balance": "10000000000",
|
||||
"Sequence": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||
"Balance": "981481999380",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 0,
|
||||
"Sequence": 63
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A",
|
||||
"PreviousFields": {
|
||||
"Balance": "991481999390",
|
||||
"Sequence": 62
|
||||
},
|
||||
"PreviousTxnID": "2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F",
|
||||
"PreviousTxnLgrSeq": 31317
|
||||
}
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"address": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj"
|
||||
}
|
||||
},
|
||||
"outcome": {
|
||||
"result": "tesSUCCESS",
|
||||
"fee": "0.00001",
|
||||
"deliveredAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "10000"
|
||||
},
|
||||
"balanceChanges": {
|
||||
"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "10000"
|
||||
}
|
||||
],
|
||||
"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV": [
|
||||
{
|
||||
"currency": "XRP",
|
||||
"value": "-10000.00001"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderbookChanges": {},
|
||||
"indexInLedger": 0,
|
||||
"ledgerVersion": 38129
|
||||
],
|
||||
"TransactionIndex": 0,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"rawTransaction": "{\"Account\":\"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV\",\"Amount\":\"10000000000\",\"Destination\":\"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj\",\"Fee\":\"10\",\"Flags\":0,\"Sequence\":62,\"SigningPubKey\":\"034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E\",\"TransactionType\":\"Payment\",\"TxnSignature\":\"3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639\",\"hash\":\"3B1A4E1C9BB6A7208EB146BCDB86ECEA6068ED01466D933528CA2B4C64F753EF\",\"meta\":{\"AffectedNodes\":[{\"CreatedNode\":{\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"4C6ACBD635B0F07101F7FA25871B0925F8836155462152172755845CE691C49E\",\"NewFields\":{\"Account\":\"rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj\",\"Balance\":\"10000000000\",\"Sequence\":1}}},{\"ModifiedNode\":{\"FinalFields\":{\"Account\":\"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV\",\"Balance\":\"981481999380\",\"Flags\":0,\"OwnerCount\":0,\"Sequence\":63},\"LedgerEntryType\":\"AccountRoot\",\"LedgerIndex\":\"B33FDD5CF3445E1A7F2BE9B06336BEBD73A5E3EE885D3EF93F7E3E2992E46F1A\",\"PreviousFields\":{\"Balance\":\"991481999390\",\"Sequence\":62},\"PreviousTxnID\":\"2485FDC606352F1B0785DA5DE96FB9DBAF43EB60ECBB01B7F6FA970F512CDA5F\",\"PreviousTxnLgrSeq\":31317}}],\"TransactionIndex\":0,\"TransactionResult\":\"tesSUCCESS\"},\"ledger_index\":38129}"
|
||||
}
|
||||
|
||||
@@ -22,15 +22,19 @@ function acceptLedger(client) {
|
||||
return client.connection.request({command: 'ledger_accept'})
|
||||
}
|
||||
|
||||
function verifyTransaction(testcase, hash, type, options, txData, address) {
|
||||
function verifyTransaction(testcase, hash, type, options, txData, account) {
|
||||
console.log('VERIFY...')
|
||||
return testcase.client
|
||||
.getTransaction(hash, options)
|
||||
.then((data) => {
|
||||
assert(data && data.outcome)
|
||||
assert.strictEqual(data.type, type)
|
||||
assert.strictEqual(data.address, address)
|
||||
assert.strictEqual(data.outcome.result, 'tesSUCCESS')
|
||||
.request({
|
||||
command: 'tx',
|
||||
transaction: hash,
|
||||
min_ledger: options.minLedgerVersion,
|
||||
max_ledger: options.maxLedgerVersion
|
||||
}).then((data) => {
|
||||
assert(data && data.result)
|
||||
assert.strictEqual(data.result.TransactionType, type)
|
||||
assert.strictEqual(data.result.Account, account)
|
||||
assert.strictEqual(data.result.meta.TransactionResult, 'tesSUCCESS')
|
||||
if (testcase.transactions != null) {
|
||||
testcase.transactions.push(hash)
|
||||
}
|
||||
@@ -48,7 +52,7 @@ function verifyTransaction(testcase, hash, type, options, txData, address) {
|
||||
type,
|
||||
options,
|
||||
txData,
|
||||
address
|
||||
account
|
||||
).then(resolve, reject),
|
||||
INTERVAL
|
||||
)
|
||||
@@ -74,15 +78,15 @@ function testTransaction(
|
||||
const signedData = testcase.client.sign(txJSON, secret)
|
||||
console.log('PREPARED...')
|
||||
return testcase.client
|
||||
.submit(signedData.signedTransaction)
|
||||
.then((data) =>
|
||||
.request({command: 'submit', tx_blob: signedData.signedTransaction})
|
||||
.then((response) =>
|
||||
testcase.test.title.indexOf('multisign') !== -1
|
||||
? acceptLedger(testcase.client).then(() => data)
|
||||
: data
|
||||
? acceptLedger(testcase.client).then(() => response)
|
||||
: response
|
||||
)
|
||||
.then((data) => {
|
||||
.then((response) => {
|
||||
console.log('SUBMITTED...')
|
||||
assert.strictEqual(data.resultCode, 'tesSUCCESS')
|
||||
assert.strictEqual(response.result.engine_result, 'tesSUCCESS')
|
||||
const options = {
|
||||
minLedgerVersion: lastClosedLedgerVersion,
|
||||
maxLedgerVersion: txData.LastLedgerSequence
|
||||
@@ -137,7 +141,7 @@ function makeTrustLine(testcase, address, secret) {
|
||||
if (address === wallet.getAddress()) {
|
||||
testcase.transactions.push(signed.id)
|
||||
}
|
||||
return client.submit(signed.signedTransaction)
|
||||
return client.request({command: 'submit', tx_blob: signed.signedTransaction})
|
||||
})
|
||||
.then(() => ledgerAccept(client))
|
||||
return trust
|
||||
@@ -147,7 +151,7 @@ function makeOrder(client, address, specification, secret) {
|
||||
return client
|
||||
.prepareOrder(address, specification)
|
||||
.then((data) => client.sign(data.txJSON, secret))
|
||||
.then((signed) => client.submit(signed.signedTransaction))
|
||||
.then((signed) => client.request({command: 'submit', tx_blob: signed.signedTransaction}))
|
||||
.then(() => ledgerAccept(client))
|
||||
}
|
||||
|
||||
@@ -163,7 +167,7 @@ function setupAccounts(testcase) {
|
||||
return client
|
||||
.prepareSettings(masterAccount, {defaultRipple: true})
|
||||
.then((data) => client.sign(data.txJSON, masterSecret))
|
||||
.then((signed) => client.submit(signed.signedTransaction))
|
||||
.then((signed) => client.request({command: 'submit', tx_blob: signed.signedTransaction}))
|
||||
.then(() => ledgerAccept(client))
|
||||
})
|
||||
.then(() =>
|
||||
@@ -254,16 +258,6 @@ describe('integration tests', function () {
|
||||
beforeEach(_.partial(setup, serverUrl))
|
||||
afterEach(teardown)
|
||||
|
||||
it('settings', function () {
|
||||
return this.client.getLedgerVersion().then((ledgerVersion) => {
|
||||
return this.client
|
||||
.prepareSettings(address, requests.prepareSettings.domain, instructions)
|
||||
.then((prepared) =>
|
||||
testTransaction(this, 'settings', ledgerVersion, prepared)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('trustline', function () {
|
||||
return this.client.getLedgerVersion().then((ledgerVersion) => {
|
||||
return this.client
|
||||
@@ -273,7 +267,7 @@ describe('integration tests', function () {
|
||||
instructions
|
||||
)
|
||||
.then((prepared) =>
|
||||
testTransaction(this, 'trustline', ledgerVersion, prepared)
|
||||
testTransaction(this, 'TrustSet', ledgerVersion, prepared)
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -294,7 +288,7 @@ describe('integration tests', function () {
|
||||
return this.client
|
||||
.preparePayment(address, paymentSpecification, instructions)
|
||||
.then((prepared) =>
|
||||
testTransaction(this, 'payment', ledgerVersion, prepared)
|
||||
testTransaction(this, 'Payment', ledgerVersion, prepared)
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -312,24 +306,38 @@ describe('integration tests', function () {
|
||||
value: '0.0002'
|
||||
}
|
||||
}
|
||||
const expectedOrder = {
|
||||
flags: 0,
|
||||
quality: "1.185",
|
||||
taker_gets: '200',
|
||||
taker_pays: {
|
||||
currency: 'USD',
|
||||
value: '237',
|
||||
issuer: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
|
||||
}
|
||||
}
|
||||
return this.client.getLedgerVersion().then((ledgerVersion) => {
|
||||
return this.client
|
||||
.prepareOrder(address, orderSpecification, instructions)
|
||||
.then((prepared) =>
|
||||
testTransaction(this, 'order', ledgerVersion, prepared)
|
||||
testTransaction(this, 'OfferCreate', ledgerVersion, prepared)
|
||||
)
|
||||
.then((result) => {
|
||||
const txData = JSON.parse(result.txJSON)
|
||||
return this.client.getOrders(address).then((orders) => {
|
||||
return this.client.request({
|
||||
command: 'account_offers',
|
||||
account: address
|
||||
}).then(response => response.result.offers)
|
||||
.then((orders) => {
|
||||
assert(orders && orders.length > 0)
|
||||
const createdOrder = (
|
||||
orders.filter((order) => {
|
||||
return order.properties.sequence === txData.Sequence
|
||||
return order.seq === txData.Sequence
|
||||
})
|
||||
)[0]
|
||||
assert(createdOrder)
|
||||
assert.strictEqual(createdOrder.properties.maker, address)
|
||||
assert.deepEqual(createdOrder.specification, orderSpecification)
|
||||
delete createdOrder.seq
|
||||
assert.deepEqual(createdOrder, expectedOrder)
|
||||
return txData
|
||||
})
|
||||
})
|
||||
@@ -343,7 +351,7 @@ describe('integration tests', function () {
|
||||
.then((prepared) =>
|
||||
testTransaction(
|
||||
this,
|
||||
'orderCancellation',
|
||||
'OfferCancel',
|
||||
ledgerVersion,
|
||||
prepared
|
||||
)
|
||||
@@ -356,12 +364,6 @@ describe('integration tests', function () {
|
||||
assert(this.client.isConnected())
|
||||
})
|
||||
|
||||
it('getServerInfo', function () {
|
||||
return this.client.getServerInfo().then((data) => {
|
||||
assert(data && data.result.info.pubkey_node)
|
||||
})
|
||||
})
|
||||
|
||||
it('getFee', function () {
|
||||
return this.client.getFee().then((fee) => {
|
||||
assert.strictEqual(typeof fee, 'string')
|
||||
@@ -377,19 +379,6 @@ describe('integration tests', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('getTransactions', function () {
|
||||
const options = {
|
||||
initiated: true,
|
||||
minLedgerVersion: this.startLedgerVersion
|
||||
}
|
||||
return this.client
|
||||
.getTransactions(address, options)
|
||||
.then((transactionsData) => {
|
||||
assert(transactionsData)
|
||||
assert.strictEqual(transactionsData.length, this.transactions.length)
|
||||
})
|
||||
})
|
||||
|
||||
it('getTrustlines', function () {
|
||||
const fixture = requests.prepareTrustline.simple
|
||||
const { currency, counterparty } = fixture
|
||||
@@ -414,13 +403,6 @@ describe('integration tests', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('getSettings', function () {
|
||||
return this.client.getSettings(address).then((data) => {
|
||||
assert(data)
|
||||
assert.strictEqual(data.domain, requests.prepareSettings.domain.domain)
|
||||
})
|
||||
})
|
||||
|
||||
it('getOrderbook', function () {
|
||||
const orderbook = {
|
||||
base: {
|
||||
@@ -545,7 +527,7 @@ describe('integration tests - standalone rippled', function () {
|
||||
.then((prepared) => {
|
||||
return testTransaction(
|
||||
this,
|
||||
'settings',
|
||||
'SignerListSet',
|
||||
ledgerVersion,
|
||||
prepared,
|
||||
address,
|
||||
@@ -576,15 +558,15 @@ describe('integration tests - standalone rippled', function () {
|
||||
signed2.signedTransaction
|
||||
])
|
||||
return this.client
|
||||
.submit(combined.signedTransaction)
|
||||
.request({command: 'submit', tx_blob: combined.signedTransaction})
|
||||
.then((response) => acceptLedger(this.client).then(() => response))
|
||||
.then((response) => {
|
||||
assert.strictEqual(response.resultCode, 'tesSUCCESS')
|
||||
assert.strictEqual(response.result.engine_result, 'tesSUCCESS')
|
||||
const options = {minLedgerVersion}
|
||||
return verifyTransaction(
|
||||
this,
|
||||
combined.id,
|
||||
'settings',
|
||||
'AccountSet',
|
||||
options,
|
||||
{},
|
||||
address
|
||||
|
||||
@@ -36,8 +36,9 @@ function pay(client, from, to, amount, secret, currency = 'XRP', counterparty) {
|
||||
.then(data => client.sign(data.txJSON, secret))
|
||||
.then(signed => {
|
||||
id = signed.id;
|
||||
return client.submit(signed.signedTransaction);
|
||||
return client.request({command: 'submit', tx_blob: signed.signedTransaction});
|
||||
})
|
||||
// TODO: add better error handling here
|
||||
.then(() => ledgerAccept(client))
|
||||
.then(() => id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user