Skip to content

Commit

Permalink
test(e2e): set up e2e to use all currently available blockfrost provi…
Browse files Browse the repository at this point in the history
…ders

also delete 'blockfrost-providers' test suite as it overlaps with wallet test suites
  • Loading branch information
mkazlauskas committed Nov 27, 2024
1 parent 3bac79c commit 55242b3
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 277 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/continuous-integration-blockfrost-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ env:
STAKE_POOL_TEST_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool_test'
TEST_CLIENT_ASSET_PROVIDER: 'blockfrost'
TEST_CLIENT_ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015"}'
TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'ws'
TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'blockfrost'
TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015/"}'
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:4000/"}'
TEST_CLIENT_TX_SUBMIT_PROVIDER: 'http'
TEST_CLIENT_TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
TEST_CLIENT_UTXO_PROVIDER: 'ws'
TEST_CLIENT_UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
TEST_CLIENT_NETWORK_INFO_PROVIDER: 'blockfrost'
TEST_CLIENT_NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015/"}'
TEST_CLIENT_REWARDS_PROVIDER: 'blockfrost'
TEST_CLIENT_REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015/"}'
TEST_CLIENT_TX_SUBMIT_PROVIDER: 'blockfrost'
TEST_CLIENT_TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015/"}'
TEST_CLIENT_UTXO_PROVIDER: 'blockfrost'
TEST_CLIENT_UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:3015/"}'
TEST_CLIENT_STAKE_POOL_PROVIDER: 'http'
TEST_CLIENT_STAKE_POOL_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
WS_PROVIDER_URL: 'http://localhost:4100/ws'
Expand Down Expand Up @@ -86,9 +86,6 @@ jobs:
- name: 🔬 Test - e2e - wallet at epoch 3
run: |
yarn workspace @cardano-sdk/e2e test:wallet:epoch3
yarn workspace @cardano-sdk/e2e test:blockfrost:providers
env:
BLOCKFROST_API_KEY: ${{ secrets.BLOCKFROST_API_KEY }}
- name: Dump docker logs
if: ${{ cancelled() || failure() }}
Expand Down
20 changes: 10 additions & 10 deletions packages/e2e/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ NETWORK_SPEED=fast
# to run tests against local 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"}'
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"}'
1 change: 0 additions & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"load-test-custom:wallet-restoration": "ts-node test/load-test-custom/wallet-restoration/wallet-restoration.test.ts",
"test": "echo 'test' command not implemented yet",
"test:blockfrost": "jest -c jest.config.js --forceExit --selectProjects blockfrost --runInBand --verbose",
"test:blockfrost:providers": "jest -c jest.config.js --forceExit --selectProjects blockfrost-providers --runInBand --verbose",
"test:utils": "jest -c jest.config.js --forceExit --selectProjects utils --verbose",
"test:long-running": "jest -c jest.config.js --forceExit --selectProjects long-running --runInBand --verbose",
"test:local-network": "jest -c jest.config.js --forceExit --selectProjects local-network --runInBand --verbose",
Expand Down
1 change: 0 additions & 1 deletion packages/e2e/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const providerParams = makeValidator((value) => {
const validators = {
ADDRESS_DISCOVERY: str({ default: 'HDSequentialDiscovery' }),
ARRIVAL_PHASE_DURATION_IN_SECS: num(),
BLOCKFROST_API_KEY: str(),
DB_SYNC_CONNECTION_STRING: str({ default: undefined }),
KEY_MANAGEMENT_PARAMS: keyManagementParams(),
KEY_MANAGEMENT_PROVIDER: str(),
Expand Down
93 changes: 53 additions & 40 deletions packages/e2e/src/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
BlockfrostClient,
BlockfrostNetworkInfoProvider,
BlockfrostRewardsProvider,
BlockfrostTxSubmitProvider,
BlockfrostUtxoProvider,
CardanoWsClient,
assetInfoHttpProvider,
Expand Down Expand Up @@ -121,16 +122,6 @@ const getWsClient = async (logger: Logger) => {
return (wsClient = new CardanoWsClient({ chainHistoryProvider, logger }, { url: new URL(env.WS_PROVIDER_URL) }));
};

const getBlockfrostRemoteClient = (params: { baseUrl: string; projectId: string }) =>
new BlockfrostClient(
{
apiVersion: 'v0',
baseUrl: params.baseUrl,
projectId: params.projectId
},
{ rateLimiter: { schedule: (task) => task() } }
);

// Asset providers

assetProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger): Promise<AssetProvider> => {
Expand Down Expand Up @@ -176,22 +167,19 @@ chainHistoryProviderFactory.register(
async (_params: any, logger: Logger) => (await getWsClient(logger)).chainHistoryProvider
);

chainHistoryProviderFactory.register(
BLOCKFROST_PROVIDER,
async (params: any, logger: Logger): Promise<ChainHistoryProvider> => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostUtxoProvider.name}: ${MISSING_URL_PARAM}`);
chainHistoryProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger) => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostChainHistoryProvider.name}: ${MISSING_URL_PARAM}`);

return new Promise<BlockfrostChainHistoryProvider>(async (resolve) => {
resolve(
new BlockfrostChainHistoryProvider(
getBlockfrostRemoteClient(params),
await networkInfoProviderFactory.create('blockfrost', params, logger),
logger
)
);
});
}
);
return new Promise(async (resolve) => {
resolve(
new BlockfrostChainHistoryProvider(
new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
await networkInfoProviderFactory.create('blockfrost', params, logger),
logger
)
);
});
});

networkInfoProviderFactory.register(
HTTP_PROVIDER,
Expand All @@ -209,16 +197,18 @@ networkInfoProviderFactory.register(
async (_params: any, logger: Logger) => (await getWsClient(logger)).networkInfoProvider
);

networkInfoProviderFactory.register(
BLOCKFROST_PROVIDER,
async (params: any, logger: Logger): Promise<NetworkInfoProvider> => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostNetworkInfoProvider.name}: ${MISSING_URL_PARAM}`);
networkInfoProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger) => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostNetworkInfoProvider.name}: ${MISSING_URL_PARAM}`);

return new Promise<BlockfrostNetworkInfoProvider>(async (resolve) => {
resolve(new BlockfrostNetworkInfoProvider(getBlockfrostRemoteClient(params), logger));
});
}
);
return new Promise(async (resolve) => {
resolve(
new BlockfrostNetworkInfoProvider(
new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
logger
)
);
});
});

rewardsProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger): Promise<RewardsProvider> => {
if (params.baseUrl === undefined) throw new Error(`${rewardsHttpProvider.name}: ${MISSING_URL_PARAM}`);
Expand All @@ -228,11 +218,16 @@ rewardsProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logge
});
});

rewardsProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger: Logger): Promise<RewardsProvider> => {
rewardsProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger) => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostRewardsProvider.name}: ${MISSING_URL_PARAM}`);

return new Promise<BlockfrostRewardsProvider>(async (resolve) => {
resolve(new BlockfrostRewardsProvider(getBlockfrostRemoteClient(params), logger));
return new Promise(async (resolve) => {
resolve(
new BlockfrostRewardsProvider(
new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
logger
)
);
});
});

Expand Down Expand Up @@ -270,6 +265,19 @@ txSubmitProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logg
});
});

txSubmitProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger) => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostTxSubmitProvider.name}: ${MISSING_URL_PARAM}`);

return new Promise(async (resolve) => {
resolve(
new BlockfrostTxSubmitProvider(
new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
logger
)
);
});
});

utxoProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger): Promise<UtxoProvider> => {
if (params.baseUrl === undefined) throw new Error(`${utxoHttpProvider.name}: ${MISSING_URL_PARAM}`);

Expand All @@ -283,11 +291,16 @@ utxoProviderFactory.register(
async (_params: any, logger: Logger) => (await getWsClient(logger)).utxoProvider
);

utxoProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger: Logger): Promise<UtxoProvider> => {
utxoProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger) => {
if (params.baseUrl === undefined) throw new Error(`${BlockfrostUtxoProvider.name}: ${MISSING_URL_PARAM}`);

return new Promise<BlockfrostUtxoProvider>(async (resolve) => {
resolve(new BlockfrostUtxoProvider(getBlockfrostRemoteClient(params), logger));
return new Promise(async (resolve) => {
resolve(
new BlockfrostUtxoProvider(
new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
logger
)
);
});
});

Expand Down
56 changes: 0 additions & 56 deletions packages/e2e/test/blockfrost-providers/chainHistory.test.ts

This file was deleted.

80 changes: 0 additions & 80 deletions packages/e2e/test/blockfrost-providers/networkInfo.test.ts

This file was deleted.

Loading

0 comments on commit 55242b3

Please sign in to comment.