diff --git a/.github/workflows/continuous-integration-blockfrost-e2e.yaml b/.github/workflows/continuous-integration-blockfrost-e2e.yaml index fab690b0d83..eb165b51b1a 100644 --- a/.github/workflows/continuous-integration-blockfrost-e2e.yaml +++ b/.github/workflows/continuous-integration-blockfrost-e2e.yaml @@ -10,20 +10,20 @@ env: OGMIOS_URL: 'ws://localhost:1340/' STAKE_POOL_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool' STAKE_POOL_TEST_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool_test' - TEST_CLIENT_ASSET_PROVIDER: 'http' - TEST_CLIENT_ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4014/"}' - TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'http' - TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}' + TEST_CLIENT_ASSET_PROVIDER: 'blockfrost' + TEST_CLIENT_ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://blockfrost-ryo:3000"}' + TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'ws' + TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' TEST_CLIENT_HANDLE_PROVIDER: 'http' TEST_CLIENT_HANDLE_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4011/"}' TEST_CLIENT_NETWORK_INFO_PROVIDER: 'ws' TEST_CLIENT_NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' TEST_CLIENT_REWARDS_PROVIDER: 'http' - TEST_CLIENT_REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}' + TEST_CLIENT_REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' TEST_CLIENT_TX_SUBMIT_PROVIDER: 'http' TEST_CLIENT_TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' - TEST_CLIENT_UTXO_PROVIDER: 'http' - TEST_CLIENT_UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}' + TEST_CLIENT_UTXO_PROVIDER: 'ws' + TEST_CLIENT_UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' TEST_CLIENT_STAKE_POOL_PROVIDER: 'http' TEST_CLIENT_STAKE_POOL_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}' WS_PROVIDER_URL: 'http://localhost:4100/ws' diff --git a/packages/e2e/.env.example b/packages/e2e/.env.example index 24fc638e6ae..8aea58b05ce 100644 --- a/packages/e2e/.env.example +++ b/packages/e2e/.env.example @@ -66,11 +66,15 @@ STAKE_POOL_PROJECTOR_URL='http://localhost:4002/' NETWORK_SPEED=fast # to run tests against local blockfrost -# Blockfrost secrets -#BLOCKFROST_CUSTOM_BACKEND_URL='http://blockfrost-ryo:3000' -#ASSET_PROVIDER: 'blockfrost' -#UTXO_PROVIDER: 'blockfrost' -#CHAIN_HISTORY_PROVIDER: 'blockfrost' -#REWARDS_PROVIDER: 'blockfrost' -#NETWORK_INFO_PROVIDER: 'blockfrost' -#TX_SUBMIT_PROVIDER: 'blockfrost' +TEST_CLIENT_ASSET_PROVIDER='blockfrost' +TEST_CLIENT_ASSET_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' +#TEST_CLIENT_UTXO_PROVIDER='blockfrost' +#TEST_UTXO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' +#TEST_CLIENT_CHAIN_HISTORY_PROVIDER='blockfrost' +#TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' +#TEST_CLIENT_REWARDS_PROVIDER='blockfrost' +#TEST_REWARDS_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' +#TEST_CLIENT_NETWORK_INFO_PROVIDER='blockfrost' +#TEST_NETWORK_INFO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' +#TEST_CLIENT_TX_SUBMIT_PROVIDER='blockfrost' +#TEST_TX_SUBMIT_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3015"}' diff --git a/packages/e2e/src/factories.ts b/packages/e2e/src/factories.ts index 1663a53cf24..790129ebad9 100644 --- a/packages/e2e/src/factories.ts +++ b/packages/e2e/src/factories.ts @@ -36,6 +36,8 @@ import { util } from '@cardano-sdk/key-management'; import { + BlockfrostAssetProvider, + BlockfrostClient, CardanoWsClient, assetInfoHttpProvider, chainHistoryHttpProvider, @@ -66,6 +68,7 @@ const HTTP_PROVIDER = 'http'; const OGMIOS_PROVIDER = 'ogmios'; const STUB_PROVIDER = 'stub'; const WS_PROVIDER = 'ws'; +const BLOCKFROST_PROVIDER = 'blockfrost'; const MISSING_URL_PARAM = 'Missing URL'; @@ -130,6 +133,19 @@ assetProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger) }); }); +assetProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger): Promise => { + if (params.baseUrl === undefined) throw new Error(`${BlockfrostAssetProvider.name}: ${MISSING_URL_PARAM}`); + + return new Promise(async (resolve) => { + resolve( + new BlockfrostAssetProvider( + new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }), + logger + ) + ); + }); +}); + chainHistoryProviderFactory.register( HTTP_PROVIDER, async (params: any, logger: Logger): Promise => { diff --git a/packages/e2e/test/blockfrost/getAsset.test.ts b/packages/e2e/test/blockfrost/getAsset.test.ts index da5ede42331..40da30e0fd0 100644 --- a/packages/e2e/test/blockfrost/getAsset.test.ts +++ b/packages/e2e/test/blockfrost/getAsset.test.ts @@ -1,11 +1,21 @@ -import { BlockfrostAssetProvider } from '@cardano-sdk/cardano-services-client'; import { Cardano } from '@cardano-sdk/core'; +import { assetProviderFactory, getEnv, walletVariables } from '../../src'; import { logger } from '@cardano-sdk/util-dev'; -import { util } from '@cardano-sdk/cardano-services'; + +const env = getEnv(walletVariables); describe('BlockfrostAssetProvider', () => { + beforeAll(() => { + if (env.TEST_CLIENT_ASSET_PROVIDER !== 'blockfrost') + throw new Error('TEST_CLIENT_ASSET_PROVIDER must be "blockfrost" to run these tests'); + }); + test('getAsset', async () => { - const assetProvider = new BlockfrostAssetProvider(util.getBlockfrostClient(), logger); + const assetProvider = await assetProviderFactory.create( + 'blockfrost', + env.TEST_CLIENT_ASSET_PROVIDER_PARAMS, + logger + ); const asset = await assetProvider.getAsset({ assetId: Cardano.AssetId( 'b27160f0c50a9cf168bf945dcbfcabbfbee5c7a801e7b467093b41534d6574616c4d6f6e7374657230303036' diff --git a/packages/e2e/test/wallet_epoch_0/PersonalWallet/nft.test.ts b/packages/e2e/test/wallet_epoch_0/PersonalWallet/nft.test.ts index 107c7973964..a61181f9117 100644 --- a/packages/e2e/test/wallet_epoch_0/PersonalWallet/nft.test.ts +++ b/packages/e2e/test/wallet_epoch_0/PersonalWallet/nft.test.ts @@ -206,7 +206,6 @@ describe('PersonalWallet.assets/nft', () => { nftMetadata: { image: 'ipfs://some_hash1', name: 'One', - otherProperties: new Map([['version', '1.0']]), version: '1.0' }, policyId, @@ -214,7 +213,7 @@ describe('PersonalWallet.assets/nft', () => { // the limitation that asset info is not refreshed on wallet balance changes quantity: expect.anything(), supply: expect.anything(), - tokenMetadata: null + tokenMetadata: expect.anything() }); expect(nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_1_INDEX])).toBeDefined(); }); @@ -246,15 +245,12 @@ describe('PersonalWallet.assets/nft', () => { image: 'ipfs://somehash', mediaType: 'image/png', name: 'NFT with files', - otherProperties: new Map([ - ['id', '1'], - ['version', '1.0'] - ]), + otherProperties: new Map([['id', '1']]), version: '1.0' } as Asset.NftMetadata, policyId, supply: expect.anything(), - tokenMetadata: null + tokenMetadata: expect.anything() }); }); @@ -325,7 +321,7 @@ describe('PersonalWallet.assets/nft', () => { metadatum.jsonToMetadatum({ image: ['ipfs://some_hash1'], name: assetName, - version: '1.0' + version }) ] ]) @@ -377,18 +373,21 @@ describe('PersonalWallet.assets/nft', () => { nftMetadata: { image: 'ipfs://some_hash1', name: assetName, - otherProperties: new Map([['version', '1.0']]), - version: '1.0' + version: `${version}.0` }, policyId, quantity: expect.anything(), supply: expect.anything(), - tokenMetadata: null + tokenMetadata: expect.anything() }); }); CIP0025Test('supports CIP-25 v1, assetName hex encoded', 'CIP-0025-v1-hex', 1, 'hex'); CIP0025Test('supports CIP-25 v1, assetName utf8 encoded', 'CIP-0025-v1-utf8', 1, 'utf8'); - CIP0025Test('supports CIP-25 v2', 'CIP-0025-v2', 2); + + // https://input-output-rnd.slack.com/archives/C06J663L2A2/p1731505470694659 + env.TEST_CLIENT_ASSET_PROVIDER !== 'blockfrost' + ? CIP0025Test('supports CIP-25 v2', 'CIP-0025-v2', 2) + : test.todo('"supports CIP-25 v2" test is disabled when running with Blockfrost asset provider'); }); });