mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
custom faucet hosts and various typing fixes for NFT support that were originally missed (#1882)
* various typing fixes for NFT support that were originally missed * add optional faucet URL to fundWallet * run docgen and commit changes * fixes integration tests
This commit is contained in:
@@ -40,6 +40,7 @@ describe('fundWallet', function () {
|
||||
|
||||
await api.disconnect()
|
||||
})
|
||||
|
||||
it('submit generates a devnet wallet', async function () {
|
||||
const api = new Client('wss://s.devnet.rippletest.net:51233')
|
||||
|
||||
@@ -67,4 +68,36 @@ describe('fundWallet', function () {
|
||||
|
||||
await api.disconnect()
|
||||
})
|
||||
|
||||
it('can generate and fund wallets using a custom host', async function () {
|
||||
const api = new Client('ws://xls20-sandbox.rippletest.net:51233')
|
||||
|
||||
await api.connect()
|
||||
const { wallet, balance } = await api.fundWallet(null, {
|
||||
faucetHost: 'faucet-nft.ripple.com',
|
||||
})
|
||||
|
||||
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(dropsToXrp(info.result.account_data.Balance), balance)
|
||||
|
||||
const { balance: newBalance } = await api.fundWallet(wallet, {
|
||||
faucetHost: 'faucet-nft.ripple.com',
|
||||
})
|
||||
|
||||
const afterSent = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet.classicAddress,
|
||||
})
|
||||
assert.equal(dropsToXrp(afterSent.result.account_data.Balance), newBalance)
|
||||
|
||||
await api.disconnect()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,35 +3,35 @@ import { assert } from 'chai'
|
||||
import { _private } from '../../src/Wallet/fundWallet'
|
||||
import { setupClient, teardownClient } from '../setupClient'
|
||||
|
||||
const { FaucetNetwork, getFaucetUrl } = _private
|
||||
const { FaucetNetwork, getFaucetHost } = _private
|
||||
|
||||
describe('Get Faucet URL', function () {
|
||||
describe('Get Faucet host ', function () {
|
||||
beforeEach(setupClient)
|
||||
afterEach(teardownClient)
|
||||
|
||||
it('returns the Devnet URL', function () {
|
||||
it('returns the Devnet host', function () {
|
||||
const expectedFaucet = FaucetNetwork.Devnet
|
||||
this.client.connection.url = FaucetNetwork.Devnet
|
||||
|
||||
assert.strictEqual(getFaucetUrl(this.client), expectedFaucet)
|
||||
assert.strictEqual(getFaucetHost(this.client), expectedFaucet)
|
||||
})
|
||||
|
||||
it('returns the Testnet URL', function () {
|
||||
it('returns the Testnet host', function () {
|
||||
const expectedFaucet = FaucetNetwork.Testnet
|
||||
this.client.connection.url = FaucetNetwork.Testnet
|
||||
|
||||
assert.strictEqual(getFaucetUrl(this.client), expectedFaucet)
|
||||
assert.strictEqual(getFaucetHost(this.client), expectedFaucet)
|
||||
})
|
||||
|
||||
it('returns the Testnet URL with the XRPL Labs server', function () {
|
||||
it('returns the Testnet host with the XRPL Labs server', function () {
|
||||
const expectedFaucet = FaucetNetwork.Testnet
|
||||
this.client.connection.url = 'wss://testnet.xrpl-labs.com'
|
||||
|
||||
assert.strictEqual(getFaucetUrl(this.client), expectedFaucet)
|
||||
assert.strictEqual(getFaucetHost(this.client), expectedFaucet)
|
||||
})
|
||||
|
||||
it('returns undefined if not a Testnet or Devnet server URL', function () {
|
||||
// Info: setupClient.setup creates a connection to 'localhost'
|
||||
assert.throws(() => getFaucetUrl(this.client))
|
||||
assert.throws(() => getFaucetHost(this.client))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user