mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
refactor: adds error response object (#1619)
* add error response object * export error response properly * type mockRippled * fix linter * fix ts * fix comments
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {setupClient, teardownClient} from '../setupClient'
|
||||
|
||||
import { setupClient, teardownClient } from '../setupClient'
|
||||
|
||||
describe('Subscription', function () {
|
||||
beforeEach(setupClient)
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Client, Wallet } from 'xrpl-local'
|
||||
import { AccountSet, SignerListSet } from 'xrpl-local/models/transactions'
|
||||
import { convertStringToHex } from 'xrpl-local/utils'
|
||||
import { sign, multisign } from 'xrpl-local/wallet/signer'
|
||||
|
||||
import { Transaction } from '../../src/models/transactions'
|
||||
|
||||
import serverUrl from './serverUrl'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { assert } from 'chai'
|
||||
import _ from 'lodash'
|
||||
|
||||
import { Client } from 'xrpl-local'
|
||||
|
||||
import serverUrl from '../serverUrl'
|
||||
|
||||
@@ -3,7 +3,10 @@ import _ from 'lodash'
|
||||
import { Server as WebSocketServer } from 'ws'
|
||||
|
||||
import type { Request } from '../src'
|
||||
import type { BaseResponse } from '../src/models/methods/baseMethod'
|
||||
import type {
|
||||
BaseResponse,
|
||||
ErrorResponse,
|
||||
} from '../src/models/methods/baseMethod'
|
||||
|
||||
import { getFreePort } from './testUtils'
|
||||
|
||||
@@ -83,6 +86,7 @@ export default function createMockRippled(port: number): MockedWebSocketServer {
|
||||
}
|
||||
|
||||
if (!mock.suppressOutput) {
|
||||
// eslint-disable-next-line no-console -- only printed out on error
|
||||
console.error(err.message)
|
||||
}
|
||||
if (request != null) {
|
||||
@@ -104,8 +108,9 @@ export default function createMockRippled(port: number): MockedWebSocketServer {
|
||||
mock.addResponse = function (
|
||||
command: string,
|
||||
response:
|
||||
| Record<string, unknown>
|
||||
| ((r: Request) => Record<string, unknown>),
|
||||
| Response
|
||||
| ErrorResponse
|
||||
| ((r: Request) => Response | ErrorResponse),
|
||||
): void {
|
||||
if (typeof command !== 'string') {
|
||||
throw new Error('command is not a string')
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyAccountDelete } from './../../src/models/transactions/accountDelete'
|
||||
import { verify } from './../../src/models/transactions'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyAccountDelete } from '../../src/models/transactions/accountDelete'
|
||||
|
||||
/**
|
||||
* AccountDelete Transaction Verification Testing.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyAccountSet } from './../../src/models/transactions/accountSet'
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyAccountSet } from '../../src/models/transactions/accountSet'
|
||||
|
||||
/**
|
||||
* AccountSet Transaction Verification Testing.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyCheckCancel } from './../../src/models/transactions/checkCancel'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyCheckCancel } from '../../src/models/transactions/checkCancel'
|
||||
|
||||
/**
|
||||
* CheckCancel Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyCheckCash } from './../../src/models/transactions/checkCash'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyCheckCash } from '../../src/models/transactions/checkCash'
|
||||
|
||||
/**
|
||||
* CheckCash Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyCheckCreate } from './../../src/models/transactions/checkCreate'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyCheckCreate } from '../../src/models/transactions/checkCreate'
|
||||
|
||||
/**
|
||||
* CheckCreate Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyDepositPreauth } from './../../src/models/transactions/depositPreauth'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyDepositPreauth } from '../../src/models/transactions/depositPreauth'
|
||||
|
||||
/**
|
||||
* DepositPreauth Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { verifyEscrowCancel } from './../../src/models/transactions/escrowCancel'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from '../../src/common/errors'
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyEscrowCancel } from '../../src/models/transactions/escrowCancel'
|
||||
|
||||
/**
|
||||
* Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyEscrowCreate } from './../../src/models/transactions/escrowCreate'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyEscrowCreate } from '../../src/models/transactions/escrowCreate'
|
||||
|
||||
/**
|
||||
* EscrowCreate Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyEscrowFinish } from './../../src/models/transactions/escrowFinish'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyEscrowFinish } from '../../src/models/transactions/escrowFinish'
|
||||
|
||||
/**
|
||||
* EscrowFinish Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyOfferCancel } from './../../src/models/transactions/offerCancel'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyOfferCancel } from '../../src/models/transactions/offerCancel'
|
||||
|
||||
/**
|
||||
* OfferCancel Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyOfferCreate } from './../../src/models/transactions/offerCreate'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyOfferCreate } from '../../src/models/transactions/offerCreate'
|
||||
|
||||
/**
|
||||
* OfferCreate Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyPaymentChannelClaim } from './../../src/models/transactions/paymentChannelClaim'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyPaymentChannelClaim } from '../../src/models/transactions/paymentChannelClaim'
|
||||
|
||||
/**
|
||||
* PaymentChannelClaim Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyPaymentChannelCreate } from './../../src/models/transactions/paymentChannelCreate'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyPaymentChannelCreate } from '../../src/models/transactions/paymentChannelCreate'
|
||||
|
||||
/**
|
||||
* PaymentChannelCreate Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyPaymentChannelFund } from './../../src/models/transactions/paymentChannelFund'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyPaymentChannelFund } from '../../src/models/transactions/paymentChannelFund'
|
||||
|
||||
/**
|
||||
* PaymentChannelFund Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyTicketCreate } from './../../src/models/transactions/ticketCreate'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyTicketCreate } from '../../src/models/transactions/ticketCreate'
|
||||
|
||||
/**
|
||||
* TicketCreate Transaction Verification Testing.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
import { verifyTrustSet } from './../../src/models/transactions/trustSet'
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from 'xrpl-local/common/errors'
|
||||
|
||||
import { verify } from '../../src/models/transactions'
|
||||
import { verifyTrustSet } from '../../src/models/transactions/trustSet'
|
||||
|
||||
/**
|
||||
* TrustSet Transaction Verification Testing.
|
||||
|
||||
Reference in New Issue
Block a user