Skip to content

Commit

Permalink
test: start anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Dec 19, 2024
1 parent 54a5c1a commit edd18fe
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 79 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ src/_generated
out

# playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
test-results/
playwright-report/
blob-report/
playwright/.cache/

# vercel
.vercel
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ import { useConnect } from 'porto/wagmi'
# Install pnpm
$ curl -fsSL https://get.pnpm.io/install.sh | sh -

$ pnpm install # Install modules
$ pnpm wagmi generate # get ABIs, etc.
$ pnpm dev # Run playground
$ pnpm install # Install modules
$ pnpm wagmi generate # Get ABIs, etc.
$ pnpm dev # Run playground
```

### Contracts
Expand All @@ -523,7 +523,7 @@ $ pnpm dev # Run playground
$ foundryup

$ forge build --config-path ./contracts/foundry.toml # Build
$ forge test --config-path ./contracts/foundry.toml # Test
$ forge test --config-path ./contracts/foundry.toml # Test
```

## License
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"preinstall": "pnpx only-allow pnpm",
"prepare": "pnpm simple-git-hooks",
"test": "vitest dev",
"test:browser": "pnpm exec playwright test"
"test:browser": "pnpm exec playwright test -c test/browser/playwright.config.ts"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.1",
Expand Down
36 changes: 0 additions & 36 deletions playwright.config.ts

This file was deleted.

32 changes: 0 additions & 32 deletions scripts/generate-typed-artifacts.ts

This file was deleted.

10 changes: 9 additions & 1 deletion test/browser/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
porto.localhost, www.porto.localhost {
reverse_proxy localhost:3000
reverse_proxy localhost:3000
}

anvil.porto.localhost {
reverse_proxy localhost:8545
}

caddy.porto.localhost {
respond 200
}
9 changes: 8 additions & 1 deletion test/browser/app/create-account/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
'use client'

import { odysseyTestnet } from '@/chains'
import { Porto } from 'porto'
import { useState } from 'react'
import { http } from 'viem'

const porto = Porto.create()
const porto = Porto.create({
chains: [odysseyTestnet],
transports: {
[odysseyTestnet.id]: http(),
},
})

export default function Page() {
const [result, setResult] = useState<string | null>(null)
Expand Down
19 changes: 19 additions & 0 deletions test/browser/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Chains } from 'porto'
import type { Chain } from 'viem'

export const odysseyTestnet = {
...Chains.odysseyTestnet,
rpcUrls: {
default: {
http: ['https://anvil.porto.localhost'],
webSocket: ['wss://anvil.porto.localhost'],
},
public: {
http: ['https://anvil.porto.localhost'],
webSocket: ['wss://anvil.porto.localhost'],
},
},
} as const satisfies Chain

export const chainLookup = { odysseyTestnet }
export const chains = [odysseyTestnet]
58 changes: 58 additions & 0 deletions test/browser/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { defineConfig, devices } from '@playwright/test'

/** https://playwright.dev/docs/test-configuration */
export default defineConfig({
forbidOnly: !!process.env.CI,
fullyParallel: true,
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
],
reporter: process.env.CI ? 'github' : 'list',
retries: process.env.CI ? 2 : 0,
testDir: './',
use: {
baseURL: 'https://porto.localhost',
},
webServer: [
{
command: ['pnpm dev'].join(' && '),
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
timeout: 5_000,
},
{
command: [
'anvil',
'--chain-id 911867',
`--fork-url ${process.env.ODYSSEY_FORK_URL ?? 'https://911867.rpc.thirdweb.com'}`,
'--fork-block-number 6030102',
].join(' '),
url: 'http://127.0.0.1:8545',
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
timeout: 5_000,
},
{
command: 'caddy run -c Caddyfile',
url: 'http://localhost:2019/reverse_proxy/upstreams',
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
timeout: 5_000,
},
],
})

0 comments on commit edd18fe

Please sign in to comment.