mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
fix: fix error handling in generateFaucetWallet (#1671)
* fix: handle error correctly in generateFaucetWallet * test: Adds generateFaucetWallet integration + browser tests
This commit is contained in:
committed by
Mayukha Vadari
parent
edcdd3a0fc
commit
9e3654d7d6
64
test/integration/generateFaucetWallet.ts
Normal file
64
test/integration/generateFaucetWallet.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import assert from 'assert'
|
||||
|
||||
import _ from 'lodash'
|
||||
|
||||
import { Client, isValidClassicAddress, isValidXAddress } from 'xrpl-local'
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 60000
|
||||
// This test is reliant on external networks, and as such may be flaky.
|
||||
describe('generateFaucetWallet', function () {
|
||||
this.timeout(TIMEOUT)
|
||||
|
||||
it('submit generates a testnet wallet', async function () {
|
||||
const api = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
|
||||
await api.connect()
|
||||
const wallet = await api.generateFaucetWallet()
|
||||
|
||||
assert.notEqual(wallet, undefined)
|
||||
assert(isValidClassicAddress(wallet?.classicAddress ?? ''))
|
||||
assert(isValidXAddress(wallet?.getXAddress() ?? ''))
|
||||
|
||||
const info = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
})
|
||||
assert.equal(info.result.account_data.Balance, '1000000000')
|
||||
|
||||
await api.generateFaucetWallet(wallet)
|
||||
|
||||
const afterSent = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
})
|
||||
assert.equal(afterSent.result.account_data.Balance, '2000000000')
|
||||
|
||||
await api.disconnect()
|
||||
})
|
||||
it('submit generates a devnet wallet', async function () {
|
||||
const api = new Client('wss://s.devnet.rippletest.net:51233')
|
||||
|
||||
await api.connect()
|
||||
const wallet = await api.generateFaucetWallet()
|
||||
|
||||
assert.notEqual(wallet, undefined)
|
||||
assert(isValidClassicAddress(wallet?.classicAddress ?? ''))
|
||||
assert(isValidXAddress(wallet?.getXAddress() ?? ''))
|
||||
|
||||
const info = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
})
|
||||
assert.equal(info.result.account_data.Balance, '1000000000')
|
||||
|
||||
await api.generateFaucetWallet(wallet)
|
||||
|
||||
const afterSent = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
})
|
||||
assert.equal(afterSent.result.account_data.Balance, '2000000000')
|
||||
|
||||
await api.disconnect()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user