Skip to content

Commit bc02a46

Browse files
authored
feat: testcontainers integration (#386)
- closes #382
1 parent 7602794 commit bc02a46

File tree

20 files changed

+705
-176
lines changed

20 files changed

+705
-176
lines changed

.changeset/clever-mails-agree.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@fuel-bridge/solidity-contracts': minor
3+
'@fuel-bridge/test-utils': minor
4+
---
5+
6+
testcontainer integration for all intergration tests

.github/workflows/upgrade-test-suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
working-directory: docker/envs
4444
- name: Run integration tests on a L1 fork after upgrading contracts
4545
run: |
46-
pnpm run test:fork
46+
pnpm run test:integration:fork

docker/Makefile

Lines changed: 0 additions & 15 deletions
This file was deleted.

docker/README.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

docker/docker-compose.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ services:
8383
COMMITTER__APP__BUNDLE__FRAGMENT_ACCUMULATION_TIMEOUT: '10m'
8484
COMMITTER__APP__BUNDLE__NEW_BUNDLE_CHECK_INTERVAL: '3s'
8585
DEPLOYMENTS_HTTP: http://l1_chain:8081/deployments.local.json
86-
ports:
87-
# expose the service to the host for integration testing
88-
- ${COMMITTER_HTTP_PORT:-8888}:8888
8986
depends_on:
9087
db:
9188
condition: service_healthy

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
"changeset:version": "changeset version",
1313
"build": "sh ./scripts/build.sh",
1414
"format": "sh ./scripts/format.sh",
15-
"node:build": "make -C ./docker build",
16-
"node:up": "make -C ./docker up",
17-
"node:stop": "make -C ./docker stop",
18-
"node:clean": "make -C ./docker clean",
19-
"node:logs": "make -C ./docker logs",
2015
"test": "sh ./scripts/test.sh",
21-
"test:fork": "sh ./scripts/test-fork.sh",
2216
"test:integration": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test",
2317
"test:integration:fork": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test-fork",
2418
"lint:check": "eslint . --ext .ts,.js",

packages/integration-tests/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ ETH_ERC721_TOKEN_ADDRESS=
2727
# (Optional) Fuel network specific variables
2828
FUEL_GAS_LIMIT=10000000
2929
FUEL_GAS_PRICE=1
30+
31+
# for fork test
32+
TENDERLY_RPC_URL=
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { config as dotEnvConfig } from 'dotenv';
2+
import * as path from 'path';
3+
import type {
4+
StartedTestContainer,
5+
StartedDockerComposeEnvironment,
6+
} from 'testcontainers';
7+
import { DockerComposeEnvironment } from 'testcontainers';
8+
9+
dotEnvConfig();
10+
11+
export type Containers = {
12+
postGresContainer: StartedTestContainer;
13+
l1_node: StartedTestContainer;
14+
fuel_node: StartedTestContainer;
15+
block_committer: StartedTestContainer;
16+
};
17+
18+
const PROJECT_ROOT = path.resolve(__dirname, '../../../');
19+
let environment: StartedDockerComposeEnvironment;
20+
21+
// responsible for starting all containers
22+
export async function startContainers() {
23+
// building images externally
24+
console.log('Setting up environment using docker compose...');
25+
environment = await new DockerComposeEnvironment(
26+
path.resolve(PROJECT_ROOT, 'docker'),
27+
'docker-compose.yml'
28+
)
29+
.withBuild()
30+
.up();
31+
32+
console.log('Environment setup done...');
33+
34+
const postGresContainer = environment.getContainer('db-1');
35+
36+
const l1_node: StartedTestContainer = environment.getContainer('l1_chain-1');
37+
const fuel_node: StartedTestContainer =
38+
environment.getContainer('fuel_core-1');
39+
const block_committer: StartedTestContainer = environment.getContainer(
40+
'fuel_block_commiter-1'
41+
);
42+
43+
return { postGresContainer, l1_node, fuel_node, block_committer };
44+
}
45+
46+
export async function stopEnvironment(): Promise<void> {
47+
console.log('Stopping environment...');
48+
if (environment) {
49+
await environment.down();
50+
}
51+
}

packages/integration-tests/fork-tests/bridge_erc20.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
Provider,
3434
} from 'fuels';
3535

36+
import { startContainers, stopEnvironment } from '../docker-setup/docker';
3637
import { fundWithdrawalTransactionWithBaseAssetResource } from '../utils/utils';
3738

3839
const { expect } = chai;
@@ -203,6 +204,9 @@ describe('Bridging ERC20 tokens', async function () {
203204
}
204205

205206
before(async () => {
207+
// spinning up all docker containers
208+
await startContainers();
209+
206210
env = await setupEnvironment({});
207211
eth_erc20GatewayAddress = (
208212
await env.eth.fuelERC20Gateway.getAddress()
@@ -722,4 +726,9 @@ describe('Bridging ERC20 tokens', async function () {
722726
).to.be.true;
723727
});
724728
});
729+
730+
// stopping containers post the test
731+
after(async () => {
732+
await stopEnvironment();
733+
});
725734
});

packages/integration-tests/fork-tests/transfer_eth.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import type {
2020
Provider,
2121
} from 'fuels';
2222

23+
import { startContainers, stopEnvironment } from '../docker-setup/docker';
24+
2325
const { expect } = chai;
2426

2527
describe('Transferring ETH', async function () {
@@ -131,6 +133,9 @@ describe('Transferring ETH', async function () {
131133
}
132134

133135
before(async () => {
136+
// spinning up all docker containers
137+
await startContainers();
138+
134139
env = await setupEnvironment({});
135140
BASE_ASSET_ID = env.fuel.provider.getBaseAssetId();
136141
});
@@ -465,4 +470,9 @@ describe('Transferring ETH', async function () {
465470
expect(currentWithdrawnAmountAfterSettingLimit == 0n).to.be.true;
466471
});
467472
});
473+
474+
// stopping containers post the test
475+
after(async () => {
476+
await stopEnvironment();
477+
});
468478
});

0 commit comments

Comments
 (0)