Skip to content

Conversation

@struong
Copy link
Contributor

@struong struong commented Jan 2, 2026

motivation

Follows #359 with an approach that defaults the fee payer tests to use the testnet Tempo image

change

  • Adds a helper that retrieves the current testnet Tempo image sha
  • Uses ^ as the default test version unless TEMPO_TAG is passed
  • Adds dotenv as a dev dep so that variables load into the vitest setup
  • All env loading and configuration happens in setup.global.ts

testing

These are test changes

Greptile Summary

Improved test setup to default to current testnet Tempo image instead of 'latest', allowing tests to run against stable versions matching the testnet environment.

Key changes:

  • Added getCurrentTempoTestnetTag() helper that queries testnet RPC to fetch the current image SHA
  • Defaults to testnet image version unless TEMPO_TAG env var is explicitly provided
  • Added dotenv dependency to load environment variables into vitest
  • Simplified workflow by removing hardcoded TEMPO_TAG: latest and switching back to standard test command
  • Cleaned up prool.ts by removing unused RPC URL logic

Confidence Score: 4/5

  • Safe to merge with minor consideration for network resilience
  • Clean refactoring with clear improvement over hardcoded 'latest' tag. The testnet RPC call during setup adds a network dependency that could fail, but the overall approach is sound and aligns well with PR fix: temporarily use testnet instead of prool for fee-payer CI test #359
  • Pay attention to apps/fee-payer/test/setup.global.ts - consider adding error handling for the testnet RPC call

Important Files Changed

Filename Overview
apps/fee-payer/test/setup.global.ts Added getCurrentTempoTestnetTag() helper that queries testnet RPC for current image SHA, now defaults to testnet image instead of 'latest'
apps/fee-payer/test/prool.ts Simplified by accepting tag parameter directly in createServer(), removed unused rpcUrl logic
apps/fee-payer/vitest.config.ts Added dotenv/config import to load environment variables into process
.github/workflows/test-fee-payer.yml Removed TEMPO_TAG: latest env var and switched from test:testnet to test command

Sequence Diagram

sequenceDiagram
    participant CI as GitHub Actions
    participant Vitest as Vitest Runner
    participant Setup as globalSetup
    participant RPC as Tempo Testnet RPC
    participant Prool as Prool/Docker
    participant Tests as Test Suite

    CI->>Vitest: Run pnpm test
    Note over Vitest: Load dotenv/config
    Vitest->>Setup: Execute globalSetup()
    
    alt TEMPO_ENV != 'localnet'
        Setup->>Vitest: Skip setup, return early
    else TEMPO_ENV == 'localnet' (default)
        alt TEMPO_TAG env var set
            Setup->>Setup: Use TEMPO_TAG value
        else TEMPO_TAG not set
            Setup->>RPC: web3_clientVersion request
            RPC-->>Setup: "tempo/v0.8.0-6318f1a/..."
            Setup->>Setup: Parse SHA: "sha-6318f1a"
        end
        
        Setup->>Prool: createServer(tempoTag)
        Prool->>Docker: Start tempo container
        Docker-->>Prool: Container running
        Prool-->>Setup: Server instance
        
        Setup->>Setup: server.start()
        Setup->>Setup: waitForTempo() - retry loop
        Setup->>Docker: POST web3_clientVersion
        Docker-->>Setup: Response OK
        Setup-->>Vitest: Return teardown function
    end
    
    Vitest->>Tests: Run test suite
    Tests->>Docker: Test RPC calls
    Docker-->>Tests: Responses
    Tests-->>Vitest: Test results
    Vitest->>Setup: Execute teardown
    Setup->>Docker: Stop container
Loading

@struong struong changed the title fix: fee payer tests default to testnet image fix: default fee payer tests to testnet image Jan 2, 2026
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

🚀 Deploying struong/use-testnet-tempo-img with ⚡ Cloudflare Pages

Latest commit: 62fe003d51204d373aec1a4720e62da128e4f983
Status: ✅ Deploy successful
Preview URL: https://e9fed41b-explorer.porto.workers.dev
Branch Preview URL:

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +5 to +14
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}`
}
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.

@struong struong merged commit eff8704 into main Jan 3, 2026
6 checks passed
@struong struong deleted the struong/use-testnet-tempo-img branch January 3, 2026 00:25
gakonst pushed a commit that referenced this pull request Jan 15, 2026
* fix: dotenv to load .env into vitest

* fix: use correct env path in setup.global.ts

* fix: fee payer tests default to testnet image

---------

Co-authored-by: Steven Truong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants