test: integration tests for Payment (#1635)

* test payment

* use new helper function elsewhere

* remove unneeded comment
This commit is contained in:
Mayukha Vadari
2021-09-21 15:02:45 -04:00
parent 6eec7b0b77
commit dac8c27b49
4 changed files with 41 additions and 7 deletions

View File

@@ -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 = {

View 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)
})
})

View File

@@ -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'

View File

@@ -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,