mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
* write getLedgerIndex * add to client * rename file * add tests * remove unused import * fix browser tests * respond to comments, more cleanup
35 lines
930 B
TypeScript
35 lines
930 B
TypeScript
import { generateXAddress, Client, Wallet } from 'xrpl-local'
|
|
|
|
import serverUrl from './serverUrl'
|
|
import { fundAccount, 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)
|
|
await ledgerAccept(this.client)
|
|
this.newWallet = generateXAddress({ includeClassicAddress: true })
|
|
await teardownClient.bind(this)()
|
|
}
|
|
|
|
export async function setupClient(
|
|
this: Mocha.Context,
|
|
server = serverUrl,
|
|
): Promise<void> {
|
|
this.wallet = Wallet.generate()
|
|
return new Promise<void>((resolve, reject) => {
|
|
this.client = new Client(server)
|
|
this.client
|
|
.connect()
|
|
.then(async () => {
|
|
await fundAccount(this.client, this.wallet)
|
|
resolve()
|
|
})
|
|
.catch(reject)
|
|
})
|
|
}
|