mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-28 08:05:51 +00:00
Add Ledger Method Integration Tests (#1640)
Add integration tests for ledger, ledgerEntry, ledgerData, ledgerClosed and ledgerCurrent, plus add them to the browser tests.
This commit is contained in:
committed by
Mayukha Vadari
parent
5d67f14ea3
commit
297dee9b8f
51
test/integration/requests/ledgerEntry.ts
Normal file
51
test/integration/requests/ledgerEntry.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { assert } from 'chai'
|
||||
import _ from 'lodash'
|
||||
|
||||
import { LedgerEntryRequest, LedgerEntryResponse } from 'xrpl-local'
|
||||
|
||||
import serverUrl from '../serverUrl'
|
||||
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
|
||||
import { verifySuccessfulResponse } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
|
||||
describe('ledger_entry', function () {
|
||||
this.timeout(TIMEOUT)
|
||||
|
||||
before(suiteClientSetup)
|
||||
beforeEach(_.partial(setupClient, serverUrl))
|
||||
afterEach(teardownClient)
|
||||
|
||||
it('base', async function () {
|
||||
const validatedLedgerResponse = await this.client.request({
|
||||
command: 'ledger_data',
|
||||
ledger_index: 'validated',
|
||||
})
|
||||
|
||||
verifySuccessfulResponse(validatedLedgerResponse)
|
||||
const ledgerEntryIndex = validatedLedgerResponse.result.state[0].index
|
||||
|
||||
const ledgerEntryRequest: LedgerEntryRequest = {
|
||||
command: 'ledger_entry',
|
||||
index: ledgerEntryIndex,
|
||||
}
|
||||
|
||||
const ledgerEntryResponse = await this.client.request(ledgerEntryRequest)
|
||||
|
||||
const expectedResponse: LedgerEntryResponse = {
|
||||
id: ledgerEntryResponse.id,
|
||||
status: 'success',
|
||||
type: 'response',
|
||||
result: {
|
||||
index: ledgerEntryIndex,
|
||||
ledger_current_index: ledgerEntryResponse.result.ledger_current_index,
|
||||
node: ledgerEntryResponse.result.node,
|
||||
validated: false,
|
||||
},
|
||||
}
|
||||
|
||||
verifySuccessfulResponse(ledgerEntryResponse)
|
||||
assert.deepEqual(ledgerEntryResponse, expectedResponse)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user