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
4 changes: 1 addition & 3 deletions .github/workflows/test-fee-payer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ concurrency:
env:
NODE_OPTIONS: '--disable-warning=ExperimentalWarning --disable-warning=DeprecationWarning'
TEMPO_ENV: localnet
TEMPO_TAG: latest

jobs:
test:
Expand All @@ -35,6 +34,5 @@ jobs:
uses: ./.github/actions/install-dependencies

- name: Run tests
# TODO(struong): use prool instance once Moderato hardfork lands
run: pnpm test:testnet
run: pnpm test
working-directory: apps/fee-payer
1 change: 1 addition & 0 deletions apps/fee-payer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@cloudflare/vitest-pool-workers": "catalog:",
"@cloudflare/workers-types": "catalog:",
"@types/node": "catalog:",
"dotenv": "catalog:",
"prool": "catalog:",
"testcontainers": "catalog:",
"typescript": "catalog:",
Expand Down
11 changes: 1 addition & 10 deletions apps/fee-payer/test/prool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ import * as TestContainers from 'prool/testcontainers'

export const port = 9545

export const rpcUrl = (() => {
if (process.env.TEMPO_ENV === 'testnet')
return 'https://rpc.testnet.tempo.xyz'
// Localnet - use pool ID for parallel test isolation
const poolId = Number(process.env.VITEST_POOL_ID ?? 1)
return `http://localhost:${port}/${poolId}`
})()

export async function createServer() {
const tag = process.env.TEMPO_TAG ?? 'latest'
export async function createServer(tag = 'latest') {
return Server.create({
instance: TestContainers.Instance.tempo({
blockTime: '2ms',
Expand Down
24 changes: 20 additions & 4 deletions apps/fee-payer/test/setup.global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { createPublicClient, http } from 'viem'
import { tempoTestnet } from 'viem/chains'
import { createServer, port } from './prool.js'

const tempoEnv = (process.env.TEMPO_ENV ?? 'localnet') as string
async function getCurrentTempoTestnetTag(): Promise<string> {
const client = createPublicClient({
chain: tempoTestnet,
transport: http(),
})
const clientVersion = await client.request({ method: 'web3_clientVersion' })
// clientVersion format: "tempo/v0.8.0-6318f1a/x86_64-unknown-linux-gnu"
const sha = clientVersion.split('/')[1].split('-').pop()
return `sha-${sha}`
}
Comment on lines +5 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: wrap this in a try/catch to handle network failures gracefully, e.g., fallback to 'latest' if testnet RPC is unreachable

Suggested change
async function getCurrentTempoTestnetTag(): Promise<string> {
const client = createPublicClient({
chain: tempoTestnet,
transport: http(),
})
const clientVersion = await client.request({ method: 'web3_clientVersion' })
// clientVersion format: "tempo/v0.8.0-6318f1a/x86_64-unknown-linux-gnu"
const sha = clientVersion.split('/')[1].split('-').pop()
return `sha-${sha}`
}
async function getCurrentTempoTestnetTag(): Promise<string> {
try {
const client = createPublicClient({
chain: tempoTestnet,
transport: http(),
})
const clientVersion = await client.request({ method: 'web3_clientVersion' })
// clientVersion format: "tempo/v0.8.0-6318f1a/x86_64-unknown-linux-gnu"
const sha = clientVersion.split('/')[1].split('-').pop()
return `sha-${sha}`
} catch (error) {
console.warn('[getCurrentTempoTestnetTag] Failed to fetch testnet version, falling back to latest:', error)
return 'latest'
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/fee-payer/test/setup.global.ts
Line: 5:14

Comment:
**style:** wrap this in a try/catch to handle network failures gracefully, e.g., fallback to 'latest' if testnet RPC is unreachable

```suggestion
async function getCurrentTempoTestnetTag(): Promise<string> {
	try {
		const client = createPublicClient({
			chain: tempoTestnet,
			transport: http(),
		})
		const clientVersion = await client.request({ method: 'web3_clientVersion' })
		// clientVersion format: "tempo/v0.8.0-6318f1a/x86_64-unknown-linux-gnu"
		const sha = clientVersion.split('/')[1].split('-').pop()
		return `sha-${sha}`
	} catch (error) {
		console.warn('[getCurrentTempoTestnetTag] Failed to fetch testnet version, falling back to latest:', error)
		return 'latest'
	}
}
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.


async function waitForTempo(maxRetries = 10, delayMs = 500): Promise<void> {
const url = `http://localhost:${port}/1`
Expand Down Expand Up @@ -30,11 +41,16 @@ async function waitForTempo(maxRetries = 10, delayMs = 500): Promise<void> {
}

export default async function globalSetup() {
if (tempoEnv !== 'localnet') return
if ((import.meta.env.TEMPO_ENV ?? 'localnet') !== 'localnet') return

const tempoTag = (import.meta.env.TEMPO_TAG ??
(await getCurrentTempoTestnetTag())) as string

console.log('[globalSetup] Starting local Tempo via Prool...')
console.log('[globalSetup] Starting local Tempo via Prool...', {
tempoTag,
})
try {
const server = await createServer()
const server = await createServer(tempoTag)
console.log('[globalSetup] Server created, starting...')
const teardown = await server.start()
console.log(
Expand Down
1 change: 1 addition & 0 deletions apps/fee-payer/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { join } from 'node:path'
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'
import { Mnemonic } from 'ox'
import 'dotenv/config'

const tempoEnv = process.env.TEMPO_ENV ?? 'localnet'

Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

16 changes: 10 additions & 6 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ packages:
- apps/**
- '!**/_/**'

shellEmulator: true
workspaceConcurrency: -1
enablePrePostScripts: true
nodeOptions: '--disable-warning=ExperimentalWarning --disable-warning=DeprecationWarning'

catalog:
'@biomejs/biome': ^2.3.10
'@cloudflare/puppeteer': ^1.0.4
Expand Down Expand Up @@ -40,6 +35,7 @@ catalog:
'@vitejs/plugin-react': ^5.1.2
abitype: ^1.2.3
cva: ^1.0.0-beta.4
dotenv: ^17.2.3
eruda: ^3.4.3
esbuild: ^0.27.2
globals: ^16.5.0
Expand All @@ -54,8 +50,8 @@ catalog:
shiki: ^3.20.0
tailwind-merge: ^3.4.0
tailwindcss: ^4.1.18
testcontainers: ^11.11.0
tempo.ts: ^0.12.1
testcontainers: ^11.11.0
tw-animate-css: ^1.4.0
typed-query-selector: ^2.12.0
typescript: ^5.9.3
Expand All @@ -69,3 +65,11 @@ catalog:
zod: ^4.3.4

catalogMode: strict

enablePrePostScripts: true

nodeOptions: '--disable-warning=ExperimentalWarning --disable-warning=DeprecationWarning'

shellEmulator: true

workspaceConcurrency: -1