mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 15:45:48 +00:00
Lints top-level test files (#1594)
* lint broadcastClient * lint client * fix most of connection * remove unused files * lint mockRippled * lint mockRippledTest * lint runClientTests * lint setupClient * lint setupClientWeb * lint shamap * lint testUtils * resolve tsc issues * Fix tests * lint rest of connection * respond to comments
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types -- Necessary for test setup */
|
||||
import { Client, BroadcastClient } from 'xrpl-local'
|
||||
|
||||
import { PortResponse } from './mockRippled'
|
||||
|
||||
const port = 34371
|
||||
const defaultPort = 34371
|
||||
const baseUrl = 'ws://testripple.circleci.com:'
|
||||
|
||||
async function setup(this: any, port_ = port) {
|
||||
const tclient = new Client(baseUrl + port_)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Needed for setup
|
||||
async function setupClient(this: any, port = defaultPort): Promise<void> {
|
||||
const tclient = new Client(`${baseUrl}${port}`)
|
||||
return tclient
|
||||
.connect()
|
||||
.then(async () => {
|
||||
@@ -15,9 +17,11 @@ async function setup(this: any, port_ = port) {
|
||||
data: { openOnOtherPort: true },
|
||||
})
|
||||
})
|
||||
.then(async (got) => {
|
||||
.then(async (got: unknown) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.client = new Client(baseUrl + (got as PortResponse).result.port)
|
||||
this.client = new Client(
|
||||
`${baseUrl}${(got as PortResponse).result.port}`,
|
||||
)
|
||||
this.client.connect().then(resolve).catch(reject)
|
||||
})
|
||||
})
|
||||
@@ -26,23 +30,23 @@ async function setup(this: any, port_ = port) {
|
||||
})
|
||||
}
|
||||
|
||||
async function setupBroadcast(this: any) {
|
||||
const servers = [port, port + 1].map((port_) => baseUrl + port_)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Needed for setup
|
||||
async function setupBroadcast(this: any): Promise<void> {
|
||||
const servers = [defaultPort, defaultPort + 1].map(
|
||||
(port) => `${baseUrl}${port}`,
|
||||
)
|
||||
this.client = new BroadcastClient(servers)
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.client.connect().then(resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
|
||||
function teardown(this: any) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Needed for teardown
|
||||
function teardownClient(this: any): undefined {
|
||||
if (this.client.isConnected()) {
|
||||
return this.client.disconnect()
|
||||
return this.client.disconnect() as undefined
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export default {
|
||||
setup,
|
||||
teardown,
|
||||
setupBroadcast,
|
||||
}
|
||||
export { setupClient as setup, teardownClient as teardown, setupBroadcast }
|
||||
|
||||
Reference in New Issue
Block a user