|
1 | | -import * as envalid from 'envalid'; |
| 1 | +import { BlockfrostChainHistoryProvider, util } from '@cardano-sdk/cardano-services'; |
2 | 2 | import { Cardano, ChainHistoryProvider } from '@cardano-sdk/core'; |
3 | | -import { chainHistoryProviderFactory } from '../../src/factories'; |
4 | 3 | import { logger } from '@cardano-sdk/util-dev'; |
5 | 4 |
|
6 | | -// Verify environment. |
7 | | -export const env = envalid.cleanEnv(process.env, { |
8 | | - CHAIN_HISTORY_PROVIDER: envalid.str(), |
9 | | - CHAIN_HISTORY_PROVIDER_PARAMS: envalid.json({ default: {} }) |
10 | | -}); |
11 | | - |
12 | | -describe.only('blockfrostChainHistoryProvider', () => { |
| 5 | +describe.only('BlockfrostChainHistoryProvider', () => { |
13 | 6 | let chainHistoryProvider: ChainHistoryProvider; |
14 | | - |
| 7 | + let blockfrost; |
15 | 8 | beforeAll(async () => { |
16 | | - chainHistoryProvider = await chainHistoryProviderFactory.create( |
17 | | - env.CHAIN_HISTORY_PROVIDER, |
18 | | - env.CHAIN_HISTORY_PROVIDER_PARAMS, |
| 9 | + blockfrost = util.getBlockfrostApi(); |
| 10 | + chainHistoryProvider = new BlockfrostChainHistoryProvider({ |
| 11 | + blockfrost, |
19 | 12 | logger |
20 | | - ); |
| 13 | + }); |
21 | 14 | }); |
22 | 15 |
|
23 | 16 | describe('transactionsByHashes', () => { |
@@ -48,6 +41,14 @@ describe.only('blockfrostChainHistoryProvider', () => { |
48 | 41 | txId: 'b6b1692fd22680e06b136a013f3867eb2b73125671fe4cbe61037f0a5e17ccaa' |
49 | 42 | }); |
50 | 43 | }); |
| 44 | + |
| 45 | + it('has collaterals for failed contract', async () => { |
| 46 | + const [tx] = await chainHistoryProvider.transactionsByHashes({ |
| 47 | + ids: [Cardano.TransactionId('3de3e581ead2b38d6ba1a82a282501e4447d7b6ae28e5fb4a340b9416d5ba6c5')] |
| 48 | + }); |
| 49 | + expect(tx.inputSource).toBe(Cardano.InputSource.collaterals); |
| 50 | + }); |
| 51 | + |
51 | 52 | it('has withdrawals', async () => { |
52 | 53 | const [tx] = await chainHistoryProvider.transactionsByHashes({ |
53 | 54 | ids: [Cardano.TransactionId('5929a59b9bebad1622f021d13b3d143d88cc92cf2400472e36ed8dcdf598a7fa')] |
@@ -277,18 +278,17 @@ describe.only('blockfrostChainHistoryProvider', () => { |
277 | 278 | expect(response.totalResultCount).toBe(0); |
278 | 279 | }); |
279 | 280 |
|
280 | | - // @todo find a script failure in preprod |
281 | | - it.skip('queries successfully invalid transaction (script failure)', async () => { |
| 281 | + it('queries successfully invalid transaction (script failure)', async () => { |
282 | 282 | const response = await chainHistoryProvider.transactionsByAddresses({ |
283 | | - addresses: [Cardano.PaymentAddress('addr_test1vr8nl4u0u6fmtfnawx2rxfz95dy7m46t6dhzdftp2uha87syeufdg')], |
| 283 | + addresses: [Cardano.PaymentAddress('addr_test1vqtcml25xg7p6udz6tvyulcnxeysswq8et7r48k8fdzk5kgwlyqxc')], |
284 | 284 | pagination: { limit: 20, startAt: 0 } |
285 | 285 | }); |
286 | 286 |
|
287 | 287 | const invalidTx = response.pageResults.find( |
288 | | - (tx) => tx.id === Cardano.TransactionId('FHnt4NL7yPYH2vP2FLEfH2pt3K6meM7fgtjRiLBidaqpP5ogPzxLNsZy68e1KdW') |
| 288 | + (tx) => tx.id === Cardano.TransactionId('3de3e581ead2b38d6ba1a82a282501e4447d7b6ae28e5fb4a340b9416d5ba6c5') |
289 | 289 | ); |
290 | 290 | expect(invalidTx).toBeDefined(); |
291 | | - expect(invalidTx?.body.outputs.length).toEqual(0); |
| 291 | + expect(invalidTx?.inputSource).toBe(Cardano.InputSource.collaterals); |
292 | 292 | }); |
293 | 293 |
|
294 | 294 | it('returns transactions starting from blockRange param', async () => { |
|
0 commit comments