mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
* add apiVersion support to requests and AccountInfoResponse v1/v2 types * fix submitAndWait signature * update docker container README * update tests * fix apiVersion param in wrong position of Client.request * add integ tests * update HISTORY.md * fix request.api_version * update RIPPLED_DOCKER_IMAGE to use v2.1.0 * refactor Client.request signature * update rippled docker image * fix Client.requestAll * update rippled docker image to use v2.1.1 * update README * use import type * fix faucet; unrelated to PR * add api_version v2 support and set as default while providing support for v1 * refactor: add apiVersion to Client * resolve errors * use DeliverMax for isPartialPayment check * update fixtures * resolve lint errors * add API v1 support for isPartialPayment * update CONTRIBUTING * update accountTx JSDoc * revert deleted JSDoc comments in accountTx * update JSDoc for account_info response * only use client.apiVersion in Client.request() * add ledger_hash * remove API v1 comment from v2 model * update meta_blob JSDoc * delete second AccountTxRequest matching * add close_time_iso * set close_time_iso as optional field * add meta_blob to BaseResponse * Revert "add meta_blob to BaseResponse" This reverts commit 89794c629dc515915e28752d7c2552bfeab266a3. * use DEFAULT_API_VERSION throughout call stack * improve JSDoc explanation of ledger_index * remove this.apiVersion from getLedgerIndex * refactor Client.request() * refactor RequestManger.resolve() * add TODO to fix TxResponse type assertion * use @category ResponsesV1 for API v1 types * refactor accountTxHasPartialPayment() * remove TODO
185 lines
5.5 KiB
TypeScript
185 lines
5.5 KiB
TypeScript
import { assert } from 'chai'
|
|
import omit from 'lodash/omit'
|
|
|
|
import { AccountInfoRequest } from '../../../src'
|
|
import serverUrl from '../serverUrl'
|
|
import {
|
|
setupClient,
|
|
teardownClient,
|
|
type XrplIntegrationTestContext,
|
|
} from '../setup'
|
|
|
|
// how long before each test case times out
|
|
const TIMEOUT = 20000
|
|
|
|
describe('account_info', function () {
|
|
let testContext: XrplIntegrationTestContext
|
|
|
|
beforeEach(async () => {
|
|
testContext = await setupClient(serverUrl)
|
|
})
|
|
afterEach(async () => teardownClient(testContext))
|
|
|
|
it(
|
|
'base',
|
|
async () => {
|
|
const request: AccountInfoRequest = {
|
|
command: 'account_info',
|
|
account: testContext.wallet.classicAddress,
|
|
strict: true,
|
|
ledger_index: 'validated',
|
|
}
|
|
const response = await testContext.client.request(request)
|
|
const expected = {
|
|
id: 0,
|
|
result: {
|
|
account_data: {
|
|
Account: testContext.wallet.classicAddress,
|
|
Balance: '400000000',
|
|
Flags: 0,
|
|
LedgerEntryType: 'AccountRoot',
|
|
OwnerCount: 0,
|
|
PreviousTxnID:
|
|
'19A8211695785A3A02C1C287D93C2B049E83A9CD609825E721052D63FF4F0EC8',
|
|
PreviousTxnLgrSeq: 582,
|
|
Sequence: 283,
|
|
index:
|
|
'BD4815E6EB304136E6044F778FB68D4E464CC8DFC59B8F6CC93D90A3709AE194',
|
|
},
|
|
ledger_hash:
|
|
'F0DEEC46A7185BBB535517EE38CF2025973022D5B0532B36407F492521FDB0C6',
|
|
ledger_index: 582,
|
|
validated: true,
|
|
},
|
|
type: 'response',
|
|
}
|
|
assert.equal(response.type, expected.type)
|
|
assert.equal(response.result.validated, expected.result.validated)
|
|
assert.equal(typeof response.result.ledger_index, 'number')
|
|
assert.equal(typeof response.result.account_data.PreviousTxnID, 'string')
|
|
assert.equal(typeof response.result.account_data.index, 'string')
|
|
assert.equal(
|
|
typeof response.result.account_data.PreviousTxnLgrSeq,
|
|
'number',
|
|
)
|
|
assert.equal(typeof response.result.account_data.Sequence, 'number')
|
|
assert.deepEqual(
|
|
omit(response.result.account_data, [
|
|
'PreviousTxnID',
|
|
'PreviousTxnLgrSeq',
|
|
'Sequence',
|
|
'index',
|
|
]),
|
|
omit(expected.result.account_data, [
|
|
'PreviousTxnID',
|
|
'PreviousTxnLgrSeq',
|
|
'Sequence',
|
|
'index',
|
|
]),
|
|
)
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
|
|
it(
|
|
'uses api_version 1',
|
|
async () => {
|
|
const request: AccountInfoRequest = {
|
|
command: 'account_info',
|
|
account: testContext.wallet.classicAddress,
|
|
strict: true,
|
|
ledger_index: 'validated',
|
|
api_version: 1,
|
|
}
|
|
const response = await testContext.client.request(request)
|
|
const expected = {
|
|
id: 0,
|
|
result: {
|
|
account_data: {
|
|
Account: testContext.wallet.classicAddress,
|
|
Balance: '400000000',
|
|
Flags: 0,
|
|
LedgerEntryType: 'AccountRoot',
|
|
OwnerCount: 0,
|
|
PreviousTxnID:
|
|
'19A8211695785A3A02C1C287D93C2B049E83A9CD609825E721052D63FF4F0EC8',
|
|
PreviousTxnLgrSeq: 582,
|
|
Sequence: 283,
|
|
index:
|
|
'BD4815E6EB304136E6044F778FB68D4E464CC8DFC59B8F6CC93D90A3709AE194',
|
|
},
|
|
ledger_hash:
|
|
'F0DEEC46A7185BBB535517EE38CF2025973022D5B0532B36407F492521FDB0C6',
|
|
ledger_index: 582,
|
|
validated: true,
|
|
},
|
|
type: 'response',
|
|
}
|
|
assert.equal(response.type, expected.type)
|
|
assert.equal(response.result.validated, expected.result.validated)
|
|
assert.equal(typeof response.result.ledger_index, 'number')
|
|
assert.equal(typeof response.result.account_data.PreviousTxnID, 'string')
|
|
assert.equal(typeof response.result.account_data.index, 'string')
|
|
assert.equal(
|
|
typeof response.result.account_data.PreviousTxnLgrSeq,
|
|
'number',
|
|
)
|
|
assert.equal(typeof response.result.account_data.Sequence, 'number')
|
|
assert.deepEqual(
|
|
omit(response.result.account_data, [
|
|
'PreviousTxnID',
|
|
'PreviousTxnLgrSeq',
|
|
'Sequence',
|
|
'index',
|
|
]),
|
|
omit(expected.result.account_data, [
|
|
'PreviousTxnID',
|
|
'PreviousTxnLgrSeq',
|
|
'Sequence',
|
|
'index',
|
|
]),
|
|
)
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
|
|
it(
|
|
'signer_list using api_version 1',
|
|
async () => {
|
|
const request: AccountInfoRequest = {
|
|
command: 'account_info',
|
|
account: testContext.wallet.classicAddress,
|
|
strict: true,
|
|
ledger_index: 'validated',
|
|
signer_lists: true,
|
|
api_version: 1,
|
|
}
|
|
const response = await testContext.client.request<AccountInfoRequest, 1>(
|
|
request,
|
|
)
|
|
expect(response.result.account_data.signer_lists).toEqual([])
|
|
// @ts-expect-error -- signer_lists is expected to be undefined
|
|
expect(response.result.signer_lists).toBeUndefined()
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
|
|
it(
|
|
'signer_list using api_version 2',
|
|
async () => {
|
|
const request: AccountInfoRequest = {
|
|
command: 'account_info',
|
|
account: testContext.wallet.classicAddress,
|
|
strict: true,
|
|
ledger_index: 'validated',
|
|
signer_lists: true,
|
|
}
|
|
const response = await testContext.client.request(request)
|
|
// @ts-expect-error -- signer_lists is expected to be undefined
|
|
expect(response.result.account_data.signer_lists).toBeUndefined()
|
|
expect(response.result.signer_lists).toEqual([])
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
})
|