Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: testcontainers integration #386

Merged
merged 43 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
27fecfc
chore: add testcontainer packages
viraj124 Jan 23, 2025
d37fef0
chore: generate new fuel wallets during setup
viraj124 Jan 23, 2025
5d2b8ce
chore: make minor adjustments in existing docker files
viraj124 Jan 23, 2025
79df68f
feat: add testcontainers setup
viraj124 Jan 23, 2025
1aa882f
test: add testcontainer integration in non-fork tests
viraj124 Jan 23, 2025
414b372
chore: resolve merge conflict
viraj124 Jan 23, 2025
1f0c731
feat: integrate fork tests with testcontainer
viraj124 Jan 23, 2025
f98dae6
test: small touchups
viraj124 Jan 23, 2025
48446e6
chore: delete current docker setup related files
viraj124 Jan 24, 2025
28d5f1a
chore: remove container start command
viraj124 Jan 24, 2025
518c950
chore: update commands in upgrade test suite ci
viraj124 Jan 24, 2025
8d473b7
feat: testcontainers integration for remaining tests
viraj124 Jan 24, 2025
cd6a3a0
chore: add changeset
viraj124 Jan 24, 2025
6d431b9
chore: update comments
viraj124 Jan 24, 2025
7b7c495
chore: debug ci
viraj124 Jan 24, 2025
14fd01b
chore: formatting
viraj124 Jan 24, 2025
5fab8da
fix: ts linting
viraj124 Jan 24, 2025
ca02355
chore: testcontainer integration in ci
viraj124 Jan 27, 2025
a613ea1
chore: more ci updates
viraj124 Jan 27, 2025
01fbad2
chore: add wait strategy for l1 container
viraj124 Jan 27, 2025
8b14d68
chore: remove healthcheck
viraj124 Jan 27, 2025
bdd0f71
chore: comment out deployment serve port
viraj124 Jan 27, 2025
efb6ff2
chore: more l1 container updates
viraj124 Jan 27, 2025
96d04c9
chore: add logging
viraj124 Jan 27, 2025
c95d34b
chore: fix ts linting
viraj124 Jan 27, 2025
9eac428
chore: add debug arg in ci
viraj124 Jan 27, 2025
8466c8d
chore: remove env args in ci
viraj124 Jan 27, 2025
4c3499e
chore: add typing and revert debugging changes
viraj124 Jan 27, 2025
91e35e9
chore: remove logging
viraj124 Jan 27, 2025
9d6d49b
fix: remove shell scripting to build docker images
viraj124 Jan 28, 2025
3ff9141
chore: rename vars
viraj124 Jan 28, 2025
bab0876
chore: resolve merge conflicts
viraj124 Feb 12, 2025
8e2f0be
chore: update lock file
viraj124 Feb 12, 2025
332dd8c
chore: add try/catch block
viraj124 Feb 12, 2025
1e3ca86
chore: debug ci
viraj124 Feb 12, 2025
db7c8a5
chore: revert latest change
viraj124 Feb 12, 2025
32dc415
chore: resolve conflicts
viraj124 Feb 12, 2025
981b7db
chore: debug ci
viraj124 Feb 12, 2025
c6a3b6f
chore: update command in yml
viraj124 Feb 13, 2025
dd3ad58
chore: revert to original docker setup to build images externally
viraj124 Feb 13, 2025
a26a512
chore: debug tests ci
viraj124 Feb 13, 2025
132db83
chore: uncomment tests
viraj124 Feb 13, 2025
2827212
chore: remove comment
viraj124 Feb 14, 2025
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
6 changes: 6 additions & 0 deletions .changeset/clever-mails-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuel-bridge/solidity-contracts': minor
'@fuel-bridge/test-utils': minor
---

testcontainer integration for all intergration tests
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
working-directory: docker/envs
- name: Run integration tests on a L1 fork after upgrading contracts
run: |
pnpm run test:fork
pnpm run test:integration:fork
15 changes: 0 additions & 15 deletions docker/Makefile

This file was deleted.

61 changes: 0 additions & 61 deletions docker/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ services:
COMMITTER__APP__BUNDLE__FRAGMENT_ACCUMULATION_TIMEOUT: '10m'
COMMITTER__APP__BUNDLE__NEW_BUNDLE_CHECK_INTERVAL: '3s'
DEPLOYMENTS_HTTP: http://l1_chain:8081/deployments.local.json
ports:
# expose the service to the host for integration testing
- ${COMMITTER_HTTP_PORT:-8888}:8888
depends_on:
db:
condition: service_healthy
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
"changeset:version": "changeset version",
"build": "sh ./scripts/build.sh",
"format": "sh ./scripts/format.sh",
"node:build": "make -C ./docker build",
"node:up": "make -C ./docker up",
"node:stop": "make -C ./docker stop",
"node:clean": "make -C ./docker clean",
"node:logs": "make -C ./docker logs",
"test": "sh ./scripts/test.sh",
"test:fork": "sh ./scripts/test-fork.sh",
"test:integration": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test",
"test:integration:fork": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test-fork",
"lint:check": "eslint . --ext .ts,.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/integration-tests/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ ETH_ERC721_TOKEN_ADDRESS=
# (Optional) Fuel network specific variables
FUEL_GAS_LIMIT=10000000
FUEL_GAS_PRICE=1

# for fork test
TENDERLY_RPC_URL=
51 changes: 51 additions & 0 deletions packages/integration-tests/docker-setup/docker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { config as dotEnvConfig } from 'dotenv';
import * as path from 'path';
import type {
StartedTestContainer,
StartedDockerComposeEnvironment,
} from 'testcontainers';
import { DockerComposeEnvironment } from 'testcontainers';

dotEnvConfig();

export type Containers = {
postGresContainer: StartedTestContainer;
l1_node: StartedTestContainer;
fuel_node: StartedTestContainer;
block_committer: StartedTestContainer;
};

const PROJECT_ROOT = path.resolve(__dirname, '../../../');
let environment: StartedDockerComposeEnvironment;

// responsible for starting all containers
export async function startContainers() {
// building images externally
console.log('Setting up environment using docker compose...');
environment = await new DockerComposeEnvironment(
path.resolve(PROJECT_ROOT, 'docker'),
'docker-compose.yml'
)
.withBuild()
.up();

console.log('Environment setup done...');

const postGresContainer = environment.getContainer('db-1');

const l1_node: StartedTestContainer = environment.getContainer('l1_chain-1');
const fuel_node: StartedTestContainer =
environment.getContainer('fuel_core-1');
const block_committer: StartedTestContainer = environment.getContainer(
'fuel_block_commiter-1'
);

return { postGresContainer, l1_node, fuel_node, block_committer };
}

export async function stopEnvironment(): Promise<void> {
console.log('Stopping environment...');
if (environment) {
await environment.down();
}
}
9 changes: 9 additions & 0 deletions packages/integration-tests/fork-tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type {
Provider,
} from 'fuels';

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

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

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
eth_erc20GatewayAddress = (
await env.eth.fuelERC20Gateway.getAddress()
Expand Down Expand Up @@ -722,4 +726,9 @@ describe('Bridging ERC20 tokens', async function () {
).to.be.true;
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
10 changes: 10 additions & 0 deletions packages/integration-tests/fork-tests/transfer_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import type {
Provider,
} from 'fuels';

import { startContainers, stopEnvironment } from '../docker-setup/docker';

const { expect } = chai;

describe('Transferring ETH', async function () {
Expand Down Expand Up @@ -131,6 +133,9 @@ describe('Transferring ETH', async function () {
}

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
BASE_ASSET_ID = env.fuel.provider.getBaseAssetId();
});
Expand Down Expand Up @@ -465,4 +470,9 @@ describe('Transferring ETH', async function () {
expect(currentWithdrawnAmountAfterSettingLimit == 0n).to.be.true;
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
4 changes: 3 additions & 1 deletion packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"fuels": "0.96.1",
"mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"testcontainers": "^10.16.0",
"@testcontainers/postgresql": "^10.16.0"
}
}
9 changes: 9 additions & 0 deletions packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
MessageProof,
} from 'fuels';

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

const { expect } = chai;
Expand Down Expand Up @@ -234,6 +235,9 @@ describe('Bridging ERC20 tokens', async function () {
}

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
eth_erc20GatewayAddress = (
await env.eth.fuelERC20Gateway.getAddress()
Expand Down Expand Up @@ -876,4 +880,9 @@ describe('Bridging ERC20 tokens', async function () {
).to.be.true;
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
10 changes: 10 additions & 0 deletions packages/integration-tests/tests/bridge_erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import type {
MessageProof,
} from 'fuels';

import { startContainers, stopEnvironment } from '../docker-setup/docker';

const { expect } = chai;

// TODO: develop new version of ERC721 gateway
Expand All @@ -48,6 +50,9 @@ describe.skip('Bridging ERC721 tokens', async function () {
this.timeout(DEFAULT_TIMEOUT_MS);

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
eth_testToken = await getOrDeployERC721Contract(env);
eth_testTokenAddress = (await eth_testToken.getAddress()).toLowerCase();
Expand Down Expand Up @@ -263,4 +268,9 @@ describe.skip('Bridging ERC721 tokens', async function () {
);
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
9 changes: 9 additions & 0 deletions packages/integration-tests/tests/bridge_mainnet_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import type {
MessageProof,
} from 'fuels';

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

const { expect } = chai;
Expand Down Expand Up @@ -160,6 +161,9 @@ describe('Bridge mainnet tokens', function () {
}

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
eth_erc20GatewayAddress = (
await env.eth.fuelERC20Gateway.getAddress()
Expand Down Expand Up @@ -737,4 +741,9 @@ describe('Bridge mainnet tokens', function () {
});
});
}

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
10 changes: 10 additions & 0 deletions packages/integration-tests/tests/bridge_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { setupEnvironment, getOrDeployL2Bridge } from '@fuel-bridge/test-utils';
import chai from 'chai';
import type { Contract, FuelError } from 'fuels';

import { startContainers, stopEnvironment } from '../docker-setup/docker';

const { expect } = chai;

describe('Proxy', async function () {
Expand All @@ -16,6 +18,9 @@ describe('Proxy', async function () {
let fuel_proxy: Proxy;

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});

const { proxy, implementation } = await getOrDeployL2Bridge(
Expand Down Expand Up @@ -177,4 +182,9 @@ describe('Proxy', async function () {
expect(message).contains('NotOwner');
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
10 changes: 10 additions & 0 deletions packages/integration-tests/tests/transfer_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import type {
MessageProof,
} from 'fuels';

import { startContainers, stopEnvironment } from '../docker-setup/docker';

const { expect } = chai;

describe('Transferring ETH', async function () {
Expand Down Expand Up @@ -93,6 +95,9 @@ describe('Transferring ETH', async function () {
}

before(async () => {
// spinning up all docker containers
await startContainers();

env = await setupEnvironment({});
BASE_ASSET_ID = env.fuel.provider.getBaseAssetId();
});
Expand Down Expand Up @@ -523,4 +528,9 @@ describe('Transferring ETH', async function () {
expect(currentWithdrawnAmountAfterSettingLimit == 0n).to.be.true;
});
});

// stopping containers post the test
after(async () => {
await stopEnvironment();
});
});
Loading
Loading