Skip to content

Commit

Permalink
Merge branch 'nj/docs/e2e' into nj/tests/final-solana-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nelitow committed Dec 4, 2024
2 parents b9de404 + 5159dc1 commit 76379c8
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 73 deletions.
25 changes: 9 additions & 16 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ jobs:
id: pnpm-cache
run: pnpm install --frozen-lockfile

- name: Copy .env file for E2E Tests
run: cp e2e-tests/runner/.env.example e2e-tests/runner/.env

- name: Copy .env file for React Next
run: cp e2e-tests/react-next/.env.example e2e-tests/react-next/.env

- name: Copy .env file for React App
run: cp examples/react-app/.env.example examples/react-app/.env

- name: Run build:connectors
run: pnpm build:connectors

Expand All @@ -119,16 +128,10 @@ jobs:
- name: Build & Deploy EVM Predicates
run: pnpm fuels build && pnpm fuels deploy
working-directory: packages/evm-predicates
env:
PROVIDER_URL: "http://localhost:4000/v1/graphql"
PRIVATE_KEY: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"

- name: Build & Deploy Solana Predicates
run: pnpm fuels build && pnpm fuels deploy
working-directory: packages/solana-connector
env:
PROVIDER_URL: "http://localhost:4000/v1/graphql"
PRIVATE_KEY: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"

- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
Expand All @@ -142,15 +145,5 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
run: xvfb-run --auto-servernum -- pnpm --filter @e2e-tests/runner test:e2e
env:
VITE_FUEL_PROVIDER_URL: "http://localhost:4000/v1/graphql"
NEXT_PUBLIC_PROVIDER_URL: "http://localhost:4000/v1/graphql"
NEXT_PUBLIC_WC_PROJECT_ID: e01471314fc69cc4efba6dce12dfd710
NEXT_PUBLIC_CHAIN_ID_NAME: local
REACT_APP_PORT: 5173
REACT_NEXT_PORT: 3002
VITE_WALLET_SECRET: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
VITE_MASTER_WALLET_MNEMONIC: ${{ secrets.VITE_MASTER_WALLET_MNEMONIC }}
VITE_APP_WC_PROJECT_ID: e01471314fc69cc4efba6dce12dfd710
VITE_CHAIN_ID_NAME: local
PORT: 5173

4 changes: 2 additions & 2 deletions e2e-tests/react-next/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_WC_PROJECT_ID=
NEXT_PUBLIC_PROVIDER_URL=https://testnet.fuel.network/v1/graphql
NEXT_PUBLIC_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710
NEXT_PUBLIC_PROVIDER_URL=http://localhost:4000/v1/graphql
4 changes: 0 additions & 4 deletions e2e-tests/react-next/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ const wagmiConfig = createConfig({
],
});

if (!PROVIDER_URL) {
throw new Error(`PROVIDER_URL is not set: ${PROVIDER_URL}`);
}

const FUEL_CONFIG = {
connectors: defaultConnectors({
devMode: true,
Expand Down
13 changes: 3 additions & 10 deletions e2e-tests/runner/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
VITE_FUEL_PROVIDER_URL="http://localhost:4000/v1/graphql"
NEXT_PUBLIC_PROVIDER_URL="http://localhost:4000/v1/graphql"

# Project and chain configuration
NEXT_PUBLIC_WC_PROJECT_ID="your_wc_project_id"
NEXT_PUBLIC_CHAIN_ID_NAME="testnet"
VITE_APP_WC_PROJECT_ID="your_wc_project_id"
VITE_CHAIN_ID_NAME="local"

# Wallet configuration
VITE_WALLET_SECRET="your_wallet_secret"
VITE_MASTER_WALLET_MNEMONIC="your_wallet_mnemonic"
VITE_WALLET_SECRET=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
VITE_MASTER_WALLET_MNEMONIC=shuffle become fold deputy sick shove wolf olympic breeze antique ball broom

# Port settings
REACT_APP_PORT=5173
REACT_NEXT_PORT=3002
PORT=5173
REACT_NEXT_PORT=3002
37 changes: 13 additions & 24 deletions e2e-tests/runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,9 @@
- Rust toolchain with `forc` and `fuel-core`

## Environment Setup
1. Create a `.env` file in the `e2e-tests/runner` directory:

```env
# Provider URLs (local node)
VITE_FUEL_PROVIDER_URL="http://localhost:4000/v1/graphql"
NEXT_PUBLIC_PROVIDER_URL="http://localhost:4000/v1/graphql"
# Project and chain configuration
NEXT_PUBLIC_WC_PROJECT_ID="your_wc_project_id"
NEXT_PUBLIC_CHAIN_ID_NAME="testnet"
VITE_APP_WC_PROJECT_ID="your_wc_project_id"
VITE_CHAIN_ID_NAME="local"
# Wallet configuration
VITE_WALLET_SECRET="your_wallet_secret"
VITE_MASTER_WALLET_MNEMONIC="your_wallet_mnemonic"
# Port settings
REACT_APP_PORT=5173
REACT_NEXT_PORT=3002
PORT=5173
```
1. Copy `e2e-tests/runner/.env.example` to `e2e-tests/runner/.env`. They will have the required environment variables for local testing providing you have a local Fuel node running.
2. Copy `examples/react-app/.env.example` to `examples/react-app/.env`.
3. Copy `examples/react-next/.env.example` to `examples/react-next/.env`.

## Steps to Run Tests

Expand All @@ -53,14 +34,17 @@
```

5. **Build and Deploy EVM Predicates**
Copy `packages/evm-predicates/.env.example` to `packages/evm-predicates/.env`.
From the root directory:
```bash
cd packages/evm-predicates
pnpm fuels build && pnpm fuels deploy
```

6. **Build and Deploy Solana Predicates**
Set the private key in the fuels.config.ts file, and the provider URL to your local node.
Copy `packages/solana-connector/.env.example` to `packages/solana-connector/.env`.
```bash
cd packages/solana-predicates
cd packages/solana-connector
pnpm fuels build && pnpm fuels deploy
```

Expand All @@ -81,6 +65,11 @@
cd e2e-tests/runner
pnpm test:e2e
```
Or to run the Playwright UI and start the servers:
```bash
cd e2e-tests/runner
pnpm test:e2e:dev
```

## Environment Variables
- `VITE_FUEL_PROVIDER_URL`: URL for the local Fuel node (default: http://localhost:4000/v1/graphql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ test.describe('WalletConnectConnector', () => {
}

await transferTests(page, { connect, approveTransfer, keepSession: true });

await incrementTests(page, { connect, approveTransfer, keepSession: true });
});
});
7 changes: 6 additions & 1 deletion e2e-tests/runner/fuels.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import dotenv from 'dotenv';
import { createConfig } from 'fuels';

dotenv.config({
path: ['.env'],
});

export default createConfig({
output: './src/contracts',
contracts: ['./contracts/custom_asset'],
forcBuildFlags: ['--release'],
privateKey:
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298',
providerUrl: 'http://localhost:4000/v1/graphql',
providerUrl: process.env.PROVIDER_URL || 'http://localhost:4000/v1/graphql',
onDeploy: (_, contracts) => {
const contractIdsPath = join(__dirname, './src/contract-ids.json');
let contractIds = {};
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:react-app": "pnpm test:react-app:ci -- --ui",
"test:react-app:ci": "playwright test e2e-tests/react-app --project=react-app",
"test:react-next": "pnpm playwright test --project=react-next",
"test:e2e:dev": "pnpm --workspace-root node:up && pnpm run start:servers & pnpm playwright test --ui",
"test:e2e:dev": "pnpm run start:servers & pnpm playwright test --ui",
"test:e2e:local": "pnpm run deploy:contracts && pnpm run test:e2e",
"start:react-app": "pnpm --filter react-app dev",
"start:react-next": "pnpm --filter @e2e-tests/react-next dev",
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/runner/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
defineConfig,
devices,
} from '@playwright/test';
import { synpressFixtures } from '@synthetixio/synpress';
// import { synpressFixtures } from '@synthetixio/synpress';

import dotenv from 'dotenv';
dotenv.config();
Expand All @@ -28,6 +28,7 @@ const config: PlaywrightTestConfig = defineConfig({
},
},
],
retries: 1,
workers: 1,
timeout: 60_000,
reporter: [['html', { printSteps: true }]],
Expand Down
9 changes: 3 additions & 6 deletions examples/react-app/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
VITE_APP_WC_PROJECT_ID=
VITE_CHAIN_ID_NAME=testnet
VITE_FUEL_PROVIDER_URL=https://testnet.fuel.network/v1/graphql
VITE_WALLET_SECRET="0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
VITE_MASTER_WALLET_MNEMONIC="shuffle become fold deputy sick shove wolf olympic breeze antique ball broom"
PORT=5173
VITE_APP_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710
VITE_CHAIN_ID_NAME=local
VITE_FUEL_PROVIDER_URL=http://localhost:4000/v1/graphql
4 changes: 3 additions & 1 deletion examples/react-next/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
NEXT_PUBLIC_WC_PROJECT_ID=
NEXT_PUBLIC_WC_PROJECT_ID=e01471314fc69cc4efba6dce12dfd710
NEXT_PUBLIC_CHAIN_ID_NAME=testnet
NEXT_PUBLIC_PROVIDER_URL=http://localhost:4000/v1/graphql
2 changes: 2 additions & 0 deletions packages/evm-predicates/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PRIVATE_KEY=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
PROVIDER_URL=http://localhost:4000/v1/graphql
11 changes: 8 additions & 3 deletions packages/evm-predicates/fuels.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import dotenv from 'dotenv';
import { createConfig } from 'fuels';

dotenv.config({
path: ['.env'],
});

export default createConfig({
providerUrl:
process.env.PROVIDER_URL || 'https://testnet.fuel.network/v1/graphql',
providerUrl: process.env.PROVIDER_URL || 'http://localhost:4000/v1/graphql',
predicates: ['./predicate'],
output: './src/generated/tmp',
forcBuildFlags: ['--release'],
// needs the private key to deploy the predicate
privateKey: process.env.PRIVATE_KEY || '0x',
privateKey:
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298',
});
1 change: 1 addition & 0 deletions packages/evm-predicates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"@fuel-connectors/common": "workspace:*",
"dotenv": "16.4.5",
"fuels": "0.96.1",
"tsx": "4.9.3",
"typescript": "5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions packages/solana-connector/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PRIVATE_KEY=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
PROVIDER_URL=http://localhost:4000/v1/graphql
11 changes: 8 additions & 3 deletions packages/solana-connector/fuels.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import dotenv from 'dotenv';
import { createConfig } from 'fuels';

dotenv.config({
path: ['.env'],
});

export default createConfig({
providerUrl:
process.env.PROVIDER_URL || 'https://testnet.fuel.network/v1/graphql',
providerUrl: process.env.PROVIDER_URL || 'http://localhost:4000/v1/graphql',
predicates: ['./predicate'],
output: './src/generated/tmp',
forcBuildFlags: ['--release'],
// needs the private key to deploy the predicate
privateKey: process.env.PRIVATE_KEY || '0x',
privateKey:
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298',
});
1 change: 1 addition & 0 deletions packages/solana-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@fuel-connectors/common": "workspace:*",
"@types/memoizee": "0.4.11",
"@web3modal/core": "5.0.0",
"dotenv": "16.4.5",
"fuels": "0.96.1",
"jsdom": "24.0.0",
"ts-loader": "9.5.1",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76379c8

Please sign in to comment.