mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
test: integration tests for Payment (#1635)
* test payment * use new helper function elsewhere * remove unneeded comment
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'assert'
|
||||
|
||||
import _ from 'lodash'
|
||||
|
||||
import { Client, Wallet } from 'xrpl-local'
|
||||
import { Client } from 'xrpl-local'
|
||||
import { AccountSet, SignerListSet } from 'xrpl-local/models/transactions'
|
||||
import { convertStringToHex } from 'xrpl-local/utils'
|
||||
import { sign, multisign } from 'xrpl-local/wallet/signer'
|
||||
@@ -10,7 +10,7 @@ import { sign, multisign } from 'xrpl-local/wallet/signer'
|
||||
import serverUrl from './serverUrl'
|
||||
import { setupClient, suiteClientSetup, teardownClient } from './setup'
|
||||
import {
|
||||
fundAccount,
|
||||
generateFundedWallet,
|
||||
ledgerAccept,
|
||||
testTransaction,
|
||||
verifySubmittedTransaction,
|
||||
@@ -32,10 +32,8 @@ describe('integration tests', function () {
|
||||
|
||||
it('submit multisigned transaction', async function () {
|
||||
const client: Client = this.client
|
||||
const signerWallet1 = Wallet.generate()
|
||||
await fundAccount(client, signerWallet1)
|
||||
const signerWallet2 = Wallet.generate()
|
||||
await fundAccount(client, signerWallet2)
|
||||
const signerWallet1 = await generateFundedWallet(client)
|
||||
const signerWallet2 = await generateFundedWallet(client)
|
||||
|
||||
// set up the multisigners for the account
|
||||
const signerListSet: SignerListSet = {
|
||||
|
||||
29
test/integration/transactions/payment.ts
Normal file
29
test/integration/transactions/payment.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import _ from 'lodash'
|
||||
|
||||
import { Payment } from 'xrpl-local'
|
||||
|
||||
import serverUrl from '../serverUrl'
|
||||
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
|
||||
import { generateFundedWallet, testTransaction } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
|
||||
describe('Payment', function () {
|
||||
this.timeout(TIMEOUT)
|
||||
|
||||
before(suiteClientSetup)
|
||||
beforeEach(_.partial(setupClient, serverUrl))
|
||||
afterEach(teardownClient)
|
||||
|
||||
it('base', async function () {
|
||||
const wallet2 = await generateFundedWallet(this.client)
|
||||
const tx: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: this.wallet.getClassicAddress(),
|
||||
Destination: wallet2.getClassicAddress(),
|
||||
Amount: '1000',
|
||||
}
|
||||
await testTransaction(this.client, tx, this.wallet)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from 'lodash'
|
||||
import { SignerListSet } from 'xrpl-local/models/transactions'
|
||||
|
||||
import { SignerListSet } from 'xrpl-local'
|
||||
|
||||
import serverUrl from '../serverUrl'
|
||||
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
|
||||
|
||||
@@ -39,6 +39,12 @@ export async function fundAccount(
|
||||
await ledgerAccept(client)
|
||||
}
|
||||
|
||||
export async function generateFundedWallet(client: Client): Promise<Wallet> {
|
||||
const wallet = Wallet.generate()
|
||||
await fundAccount(client, wallet)
|
||||
return wallet
|
||||
}
|
||||
|
||||
export async function verifySubmittedTransaction(
|
||||
client: Client,
|
||||
tx: Transaction | string,
|
||||
|
||||
Reference in New Issue
Block a user