Add Path and Orderbook integration tests (#1644)

Add bookOrder, depositAuthorized, and ripplePathFind, and pathFind integration and browser tests
This commit is contained in:
Jackson Mills
2021-09-24 10:46:54 -07:00
committed by Mayukha Vadari
parent 5200682915
commit 955e21717a
7 changed files with 200 additions and 0 deletions

View File

@@ -16,6 +16,8 @@ export * from './requests/accountLines'
export * from './requests/accountObjects'
export * from './requests/accountOffers'
export * from './requests/accountTx'
export * from './requests/bookOffers'
export * from './requests/depositAuthorized'
export * from './requests/gatewayBalances'
export * from './requests/ledger'
export * from './requests/ledgerClosed'
@@ -24,6 +26,8 @@ export * from './requests/ledgerData'
export * from './requests/ledgerEntry'
export * from './requests/multisign'
export * from './requests/noRippleCheck'
export * from './requests/pathFind'
export * from './requests/ripplePathFind'
export * from './requests/submit'
export * from './requests/tx'
export * from './requests/utility'

View File

@@ -0,0 +1,45 @@
import { assert } from 'chai'
import _ from 'lodash'
import { BookOffersRequest, BookOffersResponse } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
// how long before each test case times out
const TIMEOUT = 20000
describe('book_offers', function () {
this.timeout(TIMEOUT)
before(suiteClientSetup)
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('base', async function () {
const bookOffer: BookOffersRequest = {
command: 'book_offers',
taker_gets: {
currency: 'XRP',
},
taker_pays: {
currency: 'USD',
issuer: this.wallet.getClassicAddress(),
},
}
const response = await this.client.request(bookOffer)
const expectedResponse: BookOffersResponse = {
id: response.id,
status: 'success',
type: 'response',
result: {
ledger_current_index: response.result.ledger_current_index,
offers: response.result.offers,
validated: false,
},
}
assert.deepEqual(response, expectedResponse)
})
})

View File

@@ -0,0 +1,45 @@
import { assert } from 'chai'
import _ from 'lodash'
import { DepositAuthorizedRequest, DepositAuthorizedResponse } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
import { generateFundedWallet } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
describe('deposit_authorized', function () {
this.timeout(TIMEOUT)
before(suiteClientSetup)
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const depositAuthorized: DepositAuthorizedRequest = {
command: 'deposit_authorized',
source_account: this.wallet.getClassicAddress(),
destination_account: wallet2.getClassicAddress(),
}
const response = await this.client.request(depositAuthorized)
const expectedResponse: DepositAuthorizedResponse = {
id: response.id,
status: 'success',
type: 'response',
result: {
deposit_authorized: true,
destination_account: depositAuthorized.destination_account,
ledger_current_index: response.result.ledger_current_index,
source_account: depositAuthorized.source_account,
validated: false,
},
}
assert.deepEqual(response, expectedResponse)
})
})

View File

@@ -0,0 +1,48 @@
import { assert } from 'chai'
import _ from 'lodash'
import { PathFindRequest, PathFindResponse } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
import { generateFundedWallet } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
describe('path_find', function () {
this.timeout(TIMEOUT)
before(suiteClientSetup)
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const pathFind: PathFindRequest = {
command: 'path_find',
subcommand: 'create',
source_account: this.wallet.getClassicAddress(),
destination_account: wallet2.getClassicAddress(),
destination_amount: '100',
}
const response = await this.client.request(pathFind)
const expectedResponse: PathFindResponse = {
id: response.id,
status: 'success',
type: 'response',
result: {
alternatives: response.result.alternatives,
destination_account: pathFind.destination_account,
destination_amount: pathFind.destination_amount,
source_account: pathFind.source_account,
full_reply: false,
id: response.id,
},
}
assert.deepEqual(response, expectedResponse)
})
})

View File

@@ -0,0 +1,51 @@
import { assert } from 'chai'
import _ from 'lodash'
import { RipplePathFindRequest, RipplePathFindResponse } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
import { generateFundedWallet } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
describe('ripple_path_find', function () {
this.timeout(TIMEOUT)
before(suiteClientSetup)
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('base', async function () {
const wallet2 = await generateFundedWallet(this.client)
const ripplePathFind: RipplePathFindRequest = {
command: 'ripple_path_find',
subcommand: 'create',
source_account: this.wallet.getClassicAddress(),
destination_account: wallet2.getClassicAddress(),
destination_amount: '100',
}
const response = await this.client.request(ripplePathFind)
const expectedResponse: RipplePathFindResponse = {
id: response.id,
status: 'success',
type: 'response',
result: {
alternatives: response.result.alternatives,
destination_account: wallet2.getClassicAddress(),
destination_currencies: response.result.destination_currencies,
destination_amount: ripplePathFind.destination_amount,
full_reply: true,
id: response.id,
ledger_current_index: response.result.ledger_current_index,
source_account: ripplePathFind.source_account,
validated: false,
},
}
assert.deepEqual(response, expectedResponse)
})
})