Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
39 changes: 25 additions & 14 deletions test/lib/e2e/IExecWorkerpoolModule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,27 +263,35 @@ 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',
);
expect(typeof apiUrl).toBe('string');
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(),
Expand All @@ -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(),
Expand Down
14 changes: 14 additions & 0 deletions test/mock/compass/data.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
1 change: 1 addition & 0 deletions test/test-config-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
21 changes: 21 additions & 0 deletions test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading