diff --git a/test/docker-compose.yml b/test/docker-compose.yml index eecd5c8e..48b78f52 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -108,7 +108,7 @@ services: service-internal-error: image: nginx:alpine volumes: - - $PWD/mock/server/http500.nginx.conf:/etc/nginx/conf.d/default.conf + - $PWD/mock/server/http500.nginx.conf:/etc/nginx/conf.d/default.conf:ro expose: - 80 ports: @@ -269,6 +269,18 @@ services: market-mongo: condition: service_started + custom-token-chain-compass: + image: iexechub/compass:v0.1.1 + restart: unless-stopped + environment: + DATA_FILE_PATH: /app/data.json + volumes: + - $PWD/mock/compass/data.json:/app/data.json:ro + ports: + - 8069:3000 + healthcheck: + test: nc -w 1 0.0.0.0 3000 + stack-ready: image: bash command: @@ -290,5 +302,7 @@ services: condition: service_started result-proxy: condition: service_started + custom-token-chain-compass: + condition: service_healthy voucher-subgraph-deployer: condition: service_completed_successfully diff --git a/test/lib/e2e/IExecWorkerpoolModule.test.js b/test/lib/e2e/IExecWorkerpoolModule.test.js index e29ef6cc..cba69681 100644 --- a/test/lib/e2e/IExecWorkerpoolModule.test.js +++ b/test/lib/e2e/IExecWorkerpoolModule.test.js @@ -263,12 +263,10 @@ describe('workerpool', () => { }); describe('on networks relying on compass', () => { - // TODO include compass in stack instead of using arbitrum-sepolia-testnet + const noEnsTestChain = TEST_CHAINS['custom-token-chain-no-ens']; + test('resolves the url against Compass', async () => { - const readOnlyIExec = new IExec( - { ethProvider: 'arbitrum-sepolia-testnet' }, - { allowExperimentalNetworks: true }, - ); + const { iexec: readOnlyIExec } = getTestConfig(noEnsTestChain)(); const apiUrl = await readOnlyIExec.workerpool.getWorkerpoolApiUrl( '0xB967057a21dc6A66A29721d96b8Aa7454B7c383F', ); @@ -276,14 +274,24 @@ describe('workerpool', () => { expect(apiUrl.startsWith('https://')).toBe(true); }); + test('throw if the workerpool does not exist in Compass', async () => { + const { iexec: readOnlyIExec } = getTestConfig(noEnsTestChain)(); + const address = getRandomAddress(); + await expect( + readOnlyIExec.workerpool.getWorkerpoolApiUrl(address), + ).rejects.toThrow( + Error( + `API error: Workerpool with address '${address}' not found in chain '${noEnsTestChain.chainId}'`, + ), + ); + }); + test('fails with CompassCallError if Compass is not available', async () => { - const iexecCompassNotFound = new IExec( - { ethProvider: 'arbitrum-sepolia-testnet' }, - { - allowExperimentalNetworks: true, + const { iexec: iexecCompassNotFound } = getTestConfig(noEnsTestChain)({ + options: { compassURL: SERVICE_UNREACHABLE_URL, }, - ); + }); await expect( iexecCompassNotFound.workerpool.getWorkerpoolApiUrl( getRandomAddress(), @@ -294,10 +302,13 @@ describe('workerpool', () => { ), ); - const iexecCompassInternalError = new IExec( - { ethProvider: 'arbitrum-sepolia-testnet' }, - { allowExperimentalNetworks: true, compassURL: SERVICE_HTTP_500_URL }, - ); + const { iexec: iexecCompassInternalError } = getTestConfig( + noEnsTestChain, + )({ + options: { + compassURL: SERVICE_HTTP_500_URL, + }, + }); await expect( iexecCompassInternalError.workerpool.getWorkerpoolApiUrl( getRandomAddress(), diff --git a/test/mock/compass/data.json b/test/mock/compass/data.json new file mode 100644 index 00000000..3ddfaf0d --- /dev/null +++ b/test/mock/compass/data.json @@ -0,0 +1,14 @@ +[ + { + "chainId": "65535", + "description": "custom-token-chain-no-ens", + "iapps": [], + "workerpools": [ + { + "name": "custom-token-chain-no-ens-workerpool", + "apiUrl": "https://core.custom-token-chain-no-ens.iex.ec", + "address": "0xB967057a21dc6A66A29721d96b8Aa7454B7c383F" + } + ] + } +] diff --git a/test/test-config-utils.js b/test/test-config-utils.js index 3d591425..cdb91fbb 100644 --- a/test/test-config-utils.js +++ b/test/test-config-utils.js @@ -21,6 +21,7 @@ export const getTestConfigOptions = isNative: options.isNative ?? chain.isNative, providerOptions: options.providerOptions ?? chain.providerOptions, resultProxyURL: options.resultProxyURL ?? chain.resultProxyURL, + compassURL: options.compassURL ?? chain.compassURL, smsURL: options.smsURL ?? chain.smsMap, useGas: options.useGas ?? chain.useGas, }); diff --git a/test/test-utils.js b/test/test-utils.js index bfadc76c..70b3774e 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -81,6 +81,27 @@ export const TEST_CHAINS = { }, isAnvil: false, }, + 'custom-token-chain-no-ens': { + rpcURL: 'http://localhost:18545', + chainId: '65535', + hubAddress: '0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca', + pocoAdminWallet: new Wallet( + '0x564a9db84969c8159f7aa3d5393c5ecd014fce6a375842a45b12af6677b12407', + ), + compassURL: 'http://localhost:8069', + // TODO use another wallet + faucetWallet: new Wallet( + '0x564a9db84969c8159f7aa3d5393c5ecd014fce6a375842a45b12af6677b12407', + ), + provider: new JsonRpcProvider('http://localhost:18545', undefined, { + pollingInterval: 100, + }), + defaults: { + isNative: false, + useGas: true, + }, + isAnvil: false, + }, 'bellecour-fork': { rpcURL: 'http://localhost:8545', chainId: '134',