mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Lint integration test files and browser test files (#1612)
* clean up utils * more cleanup * remove client.sign * remove unneeded tests * remove unneeded infra * move helper functions to separate files * fix linter issues * more cleanup * make helper functions more generally useful * fix test account funding * add import note to README * lint browser tests * run eslint --fix
This commit is contained in:
36
test/integration/setup.ts
Normal file
36
test/integration/setup.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { generateXAddress, Client } from 'xrpl-local'
|
||||
|
||||
import serverUrl from './serverUrl'
|
||||
import { ledgerAccept } from './utils'
|
||||
|
||||
export async function teardownClient(this: Mocha.Context): Promise<void> {
|
||||
this.client.disconnect()
|
||||
}
|
||||
|
||||
export async function suiteClientSetup(this: Mocha.Context): Promise<void> {
|
||||
this.transactions = []
|
||||
|
||||
await setupClient.bind(this)(serverUrl)
|
||||
ledgerAccept(this.client)
|
||||
this.newWallet = generateXAddress({ includeClassicAddress: true })
|
||||
// two times to give time to server to send `ledgerClosed` event
|
||||
// so getLedgerVersion will return right value
|
||||
await ledgerAccept(this.client)
|
||||
const response = await this.client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated',
|
||||
})
|
||||
const ledgerVersion = response.result.ledger_index
|
||||
this.startLedgerVersion = ledgerVersion
|
||||
await teardownClient.bind(this)()
|
||||
}
|
||||
|
||||
export async function setupClient(
|
||||
this: Mocha.Context,
|
||||
server = serverUrl,
|
||||
): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.client = new Client(server)
|
||||
this.client.connect().then(resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user