@@ -11,8 +11,14 @@ describe('blockfrostChainHistoryProvider', () => {
11
11
let provider : BlockfrostChainHistoryProvider ;
12
12
let networkInfoProvider : NetworkInfoProvider ;
13
13
14
+ const txId1 = Cardano . TransactionId ( '1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477' ) ;
15
+ const txId2 = Cardano . TransactionId ( '2e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477' ) ;
16
+ const address1 = Cardano . PaymentAddress ( '2cWKMJemoBai9J7kVvRTukMmdfxtjL9z7c396rTfrrzfAZ6EeQoKLC2y1k34hswwm4SVr' ) ;
17
+ const address2 = Cardano . PaymentAddress (
18
+ 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x'
19
+ ) ;
14
20
const txsUtxosResponse = {
15
- hash : '4123d70f66414cc921f6ffc29a899aafc7137a99a0fd453d6b200863ef5702d6' ,
21
+ hash : txId1 ,
16
22
inputs : [
17
23
{
18
24
address :
@@ -58,13 +64,13 @@ describe('blockfrostChainHistoryProvider', () => {
58
64
}
59
65
]
60
66
} ;
61
- const mockedTxResponse = {
67
+ const mockedTx1Response = {
62
68
asset_mint_or_burn_count : 5 ,
63
69
block : '356b7d7dbb696ccd12775c016941057a9dc70898d87a63fc752271bb46856940' ,
64
70
block_height : 123_456 ,
65
71
delegation_count : 0 ,
66
72
fees : '182485' ,
67
- hash : '1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477' ,
73
+ hash : txId1 ,
68
74
index : 1 ,
69
75
invalid_before : null ,
70
76
invalid_hereafter : '13885913' ,
@@ -89,6 +95,10 @@ describe('blockfrostChainHistoryProvider', () => {
89
95
valid_contract : true ,
90
96
withdrawal_count : 1
91
97
} ;
98
+ const mockedTx2Response = {
99
+ ...mockedTx1Response ,
100
+ hash : txId2
101
+ } ;
92
102
const mockedMetadataResponse = [
93
103
{
94
104
json_metadata : {
@@ -186,11 +196,20 @@ describe('blockfrostChainHistoryProvider', () => {
186
196
unit_steps : '476468'
187
197
}
188
198
] ;
199
+
189
200
const mockedAddressTransactionResponse : Responses [ 'address_transactions_content' ] = [
190
201
{
191
202
block_height : 123 ,
192
203
block_time : 131_322 ,
193
- tx_hash : '1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477' ,
204
+ tx_hash : txId1 ,
205
+ tx_index : 0
206
+ }
207
+ ] ;
208
+ const mockedAddress2TransactionResponse : Responses [ 'address_transactions_content' ] = [
209
+ {
210
+ block_height : 124 ,
211
+ block_time : 131_322 ,
212
+ tx_hash : txId2 ,
194
213
tx_index : 0
195
214
}
196
215
] ;
@@ -352,25 +371,30 @@ describe('blockfrostChainHistoryProvider', () => {
352
371
] )
353
372
} as unknown as NetworkInfoProvider ;
354
373
provider = new BlockfrostChainHistoryProvider ( client , networkInfoProvider , logger ) ;
355
- const txId = Cardano . TransactionId ( '1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477' ) ;
356
- const id = txId . toString ( ) ;
357
374
mockResponses ( request , [
358
- [ `txs/${ id } /utxos` , txsUtxosResponse ] ,
359
- [ `txs/${ id } ` , mockedTxResponse ] ,
360
- [ `txs/${ id } /metadata` , mockedMetadataResponse ] ,
361
- [ `txs/${ id } /mirs` , mockedMirResponse ] ,
362
- [ `txs/${ id } /pool_updates` , mockedPoolUpdateResponse ] ,
363
- [ `txs/${ id } /pool_retires` , mockedPoolRetireResponse ] ,
364
- [ `txs/${ id } /stakes` , mockedStakeResponse ] ,
365
- [ `txs/${ id } /delegations` , mockedDelegationResponse ] ,
366
- [ `txs/${ id } /withdrawals` , mockedWithdrawalResponse ] ,
367
- [ `txs/${ id } /redeemers` , mockedReedemerResponse ] ,
368
- [
369
- `addresses/${ Cardano . PaymentAddress (
370
- '2cWKMJemoBai9J7kVvRTukMmdfxtjL9z7c396rTfrrzfAZ6EeQoKLC2y1k34hswwm4SVr'
371
- ) . toString ( ) } /transactions?page=1&count=20`,
372
- mockedAddressTransactionResponse
373
- ] ,
375
+ [ `txs/${ txId1 } /utxos` , txsUtxosResponse ] ,
376
+ [ `txs/${ txId1 } ` , mockedTx1Response ] ,
377
+ [ `txs/${ txId1 } /metadata` , mockedMetadataResponse ] ,
378
+ [ `txs/${ txId1 } /mirs` , mockedMirResponse ] ,
379
+ [ `txs/${ txId1 } /pool_updates` , mockedPoolUpdateResponse ] ,
380
+ [ `txs/${ txId1 } /pool_retires` , mockedPoolRetireResponse ] ,
381
+ [ `txs/${ txId1 } /stakes` , mockedStakeResponse ] ,
382
+ [ `txs/${ txId1 } /delegations` , mockedDelegationResponse ] ,
383
+ [ `txs/${ txId1 } /withdrawals` , mockedWithdrawalResponse ] ,
384
+ [ `txs/${ txId1 } /redeemers` , mockedReedemerResponse ] ,
385
+ [ `txs/${ txId2 } /utxos` , txsUtxosResponse ] ,
386
+ [ `txs/${ txId2 } ` , mockedTx2Response ] ,
387
+ [ `txs/${ txId2 } /metadata` , mockedMetadataResponse ] ,
388
+ [ `txs/${ txId2 } /mirs` , mockedMirResponse ] ,
389
+ [ `txs/${ txId2 } /pool_updates` , mockedPoolUpdateResponse ] ,
390
+ [ `txs/${ txId2 } /pool_retires` , mockedPoolRetireResponse ] ,
391
+ [ `txs/${ txId2 } /stakes` , mockedStakeResponse ] ,
392
+ [ `txs/${ txId2 } /delegations` , mockedDelegationResponse ] ,
393
+ [ `txs/${ txId2 } /withdrawals` , mockedWithdrawalResponse ] ,
394
+ [ `txs/${ txId2 } /redeemers` , mockedReedemerResponse ] ,
395
+ [ `addresses/${ address1 } /transactions?page=1&count=20` , mockedAddressTransactionResponse ] ,
396
+ [ `addresses/${ address1 } /transactions?page=1&count=1` , mockedAddressTransactionResponse ] ,
397
+ [ `addresses/${ address2 } /transactions?page=1&count=1` , mockedAddress2TransactionResponse ] ,
374
398
[
375
399
`addresses/${ Cardano . PaymentAddress (
376
400
'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x'
@@ -382,7 +406,7 @@ describe('blockfrostChainHistoryProvider', () => {
382
406
mockedAddressTransactionDescResponse
383
407
] ,
384
408
[ 'epochs/420000/parameters' , mockedEpochParametersResponse ] ,
385
- [ `txs/${ id } /cbor` , new Error ( 'CBOR is null' ) ]
409
+ [ `txs/${ txId1 } /cbor` , new Error ( 'CBOR is null' ) ]
386
410
] ) ;
387
411
} ) ;
388
412
@@ -394,7 +418,7 @@ describe('blockfrostChainHistoryProvider', () => {
394
418
pagination : { limit : 20 , startAt : 0 }
395
419
} ) ;
396
420
397
- expect ( response . totalResultCount ) . toBe ( 1 ) ;
421
+ expect ( response . totalResultCount ) . toBe ( mockedAddressTransactionResponse . length ) ;
398
422
expect ( response . pageResults [ 0 ] ) . toEqual ( expectedHydratedTx ) ;
399
423
} ) ;
400
424
test ( 'supports desc order' , async ( ) => {
@@ -418,6 +442,16 @@ describe('blockfrostChainHistoryProvider', () => {
418
442
expect ( response . pageResults ) . toHaveLength ( mockedAddressTransactionResponse . length ) ;
419
443
expect ( response . totalResultCount ) . toBe ( mockedAddressTransactionResponse . length ) ;
420
444
} ) ;
445
+ test ( 'returns up to the {limit*addresses.length} number of transactions' , async ( ) => {
446
+ const response = await provider . transactionsByAddresses ( {
447
+ addresses : [ address1 , address2 ] ,
448
+ pagination : { limit : 1 , startAt : 0 }
449
+ } ) ;
450
+
451
+ const totalResultCount = mockedAddressTransactionResponse . length + mockedAddress2TransactionResponse . length ;
452
+ expect ( response . totalResultCount ) . toBe ( totalResultCount ) ;
453
+ expect ( response . pageResults . length ) . toBe ( totalResultCount ) ;
454
+ } ) ;
421
455
} ) ;
422
456
423
457
describe ( 'transactionsByHashes' , ( ) => {
@@ -514,7 +548,7 @@ describe('blockfrostChainHistoryProvider', () => {
514
548
const id = txId . toString ( ) ;
515
549
mockResponses ( request , [
516
550
[ `txs/${ id } /utxos` , txsUtxosResponse ] ,
517
- [ `txs/${ id } ` , mockedTxResponse ] ,
551
+ [ `txs/${ id } ` , mockedTx1Response ] ,
518
552
[ `txs/${ id } /metadata` , mockedMetadataResponse ] ,
519
553
[ `txs/${ id } /mirs` , mockedMirResponse ] ,
520
554
[ `txs/${ id } /pool_updates` , mockedPoolUpdateResponse ] ,
@@ -541,7 +575,7 @@ describe('blockfrostChainHistoryProvider', () => {
541
575
pagination : { limit : 20 , startAt : 0 }
542
576
} ) ;
543
577
544
- expect ( response . totalResultCount ) . toBe ( 1 ) ;
578
+ expect ( response . totalResultCount ) . toBe ( mockedAddressTransactionResponse . length ) ;
545
579
expect ( response . pageResults [ 0 ] ) . toEqual ( expectedHydratedTxCBOR ) ;
546
580
} ) ;
547
581
} ) ;
0 commit comments