mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +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
211 lines
6.4 KiB
TypeScript
211 lines
6.4 KiB
TypeScript
import { assert } from 'chai'
|
|
|
|
import {
|
|
AccountTxRequest,
|
|
Payment,
|
|
type TransactionMetadata,
|
|
} 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_tx', function () {
|
|
let testContext: XrplIntegrationTestContext
|
|
|
|
beforeEach(async () => {
|
|
testContext = await setupClient(serverUrl)
|
|
})
|
|
afterEach(async () => teardownClient(testContext))
|
|
|
|
it(
|
|
'base',
|
|
async () => {
|
|
const request: AccountTxRequest = {
|
|
command: 'account_tx',
|
|
account: testContext.wallet.classicAddress,
|
|
ledger_index: 'validated',
|
|
}
|
|
const response = await testContext.client.request(request)
|
|
const expected = {
|
|
result: {
|
|
account: testContext.wallet.classicAddress,
|
|
limit: 400,
|
|
transactions: [
|
|
{
|
|
tx_json: {
|
|
Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
|
DeliverMax: '400000000',
|
|
Destination: testContext.wallet.classicAddress,
|
|
Fee: '12',
|
|
Flags: 0,
|
|
LastLedgerSequence: 1753,
|
|
Sequence: 843,
|
|
SigningPubKey:
|
|
'0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020',
|
|
TransactionType: 'Payment',
|
|
TxnSignature:
|
|
'30440220693D244BC13967E3DA67BDC974096784ED03DD4ACE6F36645E5176988452AFCF02200F8AB172432913899F27EC5523829AEDAD00CC2445690400E294EDF652A85945',
|
|
date: 685747005,
|
|
hash: '2E68BC15813B4A836FAC4D80E42E6FDA6410E99AB973937DEA5E6C2E9A116BAB',
|
|
ledger_index: 1734,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
type: 'response',
|
|
}
|
|
assert.equal(response.type, expected.type)
|
|
assert.equal(response.result.account, expected.result.account)
|
|
assert.equal(
|
|
(response.result.transactions[0].meta as TransactionMetadata<Payment>)
|
|
.TransactionResult,
|
|
'tesSUCCESS',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.LastLedgerSequence,
|
|
'number',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.Sequence,
|
|
'number',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.SigningPubKey,
|
|
'string',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.TxnSignature,
|
|
'string',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.Fee,
|
|
'string',
|
|
)
|
|
assert.equal(typeof response.result.transactions[0].hash, 'string')
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx_json?.ledger_index,
|
|
'number',
|
|
)
|
|
|
|
const responseTx = response.result.transactions[0].tx_json as Payment
|
|
const expectedTx = expected.result.transactions[0].tx_json
|
|
assert.deepEqual(
|
|
[
|
|
responseTx.Flags,
|
|
responseTx.TransactionType,
|
|
responseTx.Account,
|
|
// @ts-expect-error -- DeliverMax is a valid field on Payment response
|
|
responseTx.DeliverMax,
|
|
responseTx.Destination,
|
|
],
|
|
[
|
|
expectedTx.Flags,
|
|
expectedTx.TransactionType,
|
|
expectedTx.Account,
|
|
expectedTx.DeliverMax,
|
|
expectedTx.Destination,
|
|
],
|
|
)
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
|
|
it(
|
|
'uses api_version 1',
|
|
async () => {
|
|
const request: AccountTxRequest = {
|
|
command: 'account_tx',
|
|
account: testContext.wallet.classicAddress,
|
|
ledger_index: 'validated',
|
|
api_version: 1,
|
|
}
|
|
const response = await testContext.client.request<AccountTxRequest, 1>(
|
|
request,
|
|
)
|
|
const expected = {
|
|
result: {
|
|
account: testContext.wallet.classicAddress,
|
|
limit: 400,
|
|
transactions: [
|
|
{
|
|
tx: {
|
|
Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
|
Amount: '400000000',
|
|
Destination: testContext.wallet.classicAddress,
|
|
Fee: '12',
|
|
Flags: 0,
|
|
LastLedgerSequence: 1753,
|
|
Sequence: 843,
|
|
SigningPubKey:
|
|
'0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020',
|
|
TransactionType: 'Payment',
|
|
TxnSignature:
|
|
'30440220693D244BC13967E3DA67BDC974096784ED03DD4ACE6F36645E5176988452AFCF02200F8AB172432913899F27EC5523829AEDAD00CC2445690400E294EDF652A85945',
|
|
date: 685747005,
|
|
hash: '2E68BC15813B4A836FAC4D80E42E6FDA6410E99AB973937DEA5E6C2E9A116BAB',
|
|
ledger_index: 1734,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
type: 'response',
|
|
}
|
|
assert.equal(response.type, expected.type)
|
|
assert.equal(response.result.account, expected.result.account)
|
|
assert.equal(
|
|
(response.result.transactions[0].meta as TransactionMetadata<Payment>)
|
|
.TransactionResult,
|
|
'tesSUCCESS',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx?.LastLedgerSequence,
|
|
'number',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx?.Sequence,
|
|
'number',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx?.SigningPubKey,
|
|
'string',
|
|
)
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx?.TxnSignature,
|
|
'string',
|
|
)
|
|
assert.equal(typeof response.result.transactions[0].tx?.Fee, 'string')
|
|
assert.equal(typeof response.result.transactions[0].tx?.hash, 'string')
|
|
assert.equal(
|
|
typeof response.result.transactions[0].tx?.ledger_index,
|
|
'number',
|
|
)
|
|
|
|
const responseTx = response.result.transactions[0].tx as Payment
|
|
const expectedTx = expected.result.transactions[0].tx
|
|
assert.deepEqual(
|
|
[
|
|
responseTx.Flags,
|
|
responseTx.TransactionType,
|
|
responseTx.Account,
|
|
responseTx.Amount,
|
|
responseTx.Destination,
|
|
],
|
|
[
|
|
expectedTx.Flags,
|
|
expectedTx.TransactionType,
|
|
expectedTx.Account,
|
|
expectedTx.Amount,
|
|
expectedTx.Destination,
|
|
],
|
|
)
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
})
|