mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
test: integration tests for CheckCreate, CheckCancel, CheckCash (#1664)
* test checkCreate * test CheckCancel * test CheckCash * add browser tests
This commit is contained in:
68
test/integration/transactions/checkCash.ts
Normal file
68
test/integration/transactions/checkCash.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { assert } from 'chai'
|
||||
import _ from 'lodash'
|
||||
|
||||
import { CheckCreate, CheckCash } 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('CheckCash', function () {
|
||||
this.timeout(TIMEOUT)
|
||||
|
||||
before(suiteClientSetup)
|
||||
beforeEach(_.partial(setupClient, serverUrl))
|
||||
afterEach(teardownClient)
|
||||
|
||||
it('base', async function () {
|
||||
const wallet2 = await generateFundedWallet(this.client)
|
||||
const amount = '500'
|
||||
|
||||
const setupTx: CheckCreate = {
|
||||
TransactionType: 'CheckCreate',
|
||||
Account: this.wallet.getClassicAddress(),
|
||||
Destination: wallet2.getClassicAddress(),
|
||||
SendMax: amount,
|
||||
}
|
||||
|
||||
await testTransaction(this.client, setupTx, this.wallet)
|
||||
|
||||
// get check ID
|
||||
const response1 = await this.client.request({
|
||||
command: 'account_objects',
|
||||
account: this.wallet.getClassicAddress(),
|
||||
type: 'check',
|
||||
})
|
||||
assert.lengthOf(
|
||||
response1.result.account_objects,
|
||||
1,
|
||||
'Should be exactly one check on the ledger',
|
||||
)
|
||||
const checkId = response1.result.account_objects[0].index
|
||||
|
||||
// actual test - cash the check
|
||||
const tx: CheckCash = {
|
||||
TransactionType: 'CheckCash',
|
||||
Account: wallet2.getClassicAddress(),
|
||||
CheckID: checkId,
|
||||
Amount: amount,
|
||||
}
|
||||
|
||||
await testTransaction(this.client, tx, wallet2)
|
||||
|
||||
// confirm that the check no longer exists
|
||||
const accountOffersResponse = await this.client.request({
|
||||
command: 'account_objects',
|
||||
account: this.wallet.getClassicAddress(),
|
||||
type: 'check',
|
||||
})
|
||||
assert.lengthOf(
|
||||
accountOffersResponse.result.account_objects,
|
||||
0,
|
||||
'Should be no checks on the ledger',
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user