Skip to content

Commit 6840107

Browse files
committed
add ledgerEntry tickets test
1 parent 9a063ff commit 6840107

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

packages/xrpl/test/integration/requests/ledgerEntry.test.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { assert } from 'chai'
22

3-
import { LedgerEntryRequest, LedgerEntryResponse } from '../../../src'
3+
import {
4+
LedgerEntryRequest,
5+
LedgerEntryResponse,
6+
TicketCreate,
7+
} from '../../../src'
8+
import Ticket from '../../../src/models/ledger/Ticket'
49
import serverUrl from '../serverUrl'
510
import {
611
setupClient,
712
teardownClient,
813
type XrplIntegrationTestContext,
914
} from '../setup'
15+
import { testTransaction } from '../utils'
1016

1117
// how long before each test case times out
1218
const TIMEOUT = 20000
@@ -55,4 +61,46 @@ describe('ledger_entry', function () {
5561
},
5662
TIMEOUT,
5763
)
64+
65+
it(
66+
'fetches a Ticket object',
67+
async () => {
68+
// Step 1: Get the current account sequence
69+
const accountInfoResponse = await testContext.client.request({
70+
command: 'account_info',
71+
account: testContext.wallet.classicAddress,
72+
})
73+
const accSeq = accountInfoResponse.result.account_data.Sequence
74+
const ticketSeq = accSeq + 1
75+
// Step 2: Create a Ticket
76+
const ticketCreate: TicketCreate = {
77+
TransactionType: 'TicketCreate',
78+
Account: testContext.wallet.classicAddress,
79+
TicketCount: 1,
80+
Sequence: accSeq,
81+
}
82+
await testTransaction(testContext.client, ticketCreate, testContext.wallet)
83+
// Step 3: Fetch the Ticket via ledger_entry using account + ticket_seq
84+
const ledgerEntryRequest: LedgerEntryRequest = {
85+
command: 'ledger_entry',
86+
ticket: {
87+
account: testContext.wallet.classicAddress,
88+
ticket_seq: ticketSeq,
89+
},
90+
}
91+
const ledgerEntryResponse: LedgerEntryResponse<Ticket> =
92+
await testContext.client.request(ledgerEntryRequest)
93+
assert.equal(ledgerEntryResponse.type, 'response')
94+
assert.equal(ledgerEntryResponse.result.node?.LedgerEntryType, 'Ticket')
95+
assert.equal(
96+
ledgerEntryResponse.result.node?.Account,
97+
testContext.wallet.classicAddress,
98+
)
99+
assert.equal(
100+
ledgerEntryResponse.result.node?.TicketSequence,
101+
ticketSeq,
102+
)
103+
},
104+
TIMEOUT,
105+
)
58106
})

0 commit comments

Comments
 (0)