Repository navigation
feat: add bootstrapped Tempo localnet instance #105
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'prool': minor | ||
| --- | ||
|
|
||
| Added a Testcontainers-backed `Instance.tempoLocalnet` for bootstrapped Tempo development networks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,28 @@ jobs: | |
| run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test --bail=1 | ||
| run: | | ||
| if [[ -n "$VITE_FORK_URL" ]]; then | ||
| pnpm test --bail=1 | ||
| else | ||
| pnpm test --bail=1 \ | ||
| --exclude src/instances/alto.test.ts \ | ||
| --testNamePattern="^(?!.*instance: alto)(?!.*instance: 'alto')" | ||
| fi | ||
| env: | ||
| VITE_FORK_URL: ${{ secrets.VITE_FORK_URL }} | ||
|
|
||
| tempo-localnet: | ||
| name: Tempo localnet | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install dependencies | ||
| uses: ./.github/actions/install-dependencies | ||
|
|
||
| - name: Run Tempo localnet tests | ||
| run: pnpm test --run src/testcontainers/tempoLocalnet.test.ts | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be nice to setup vitest projects so we can exclude (like alto) or run specifics suite like tempo localnet more easily. (can do some other time so we can get this out.) |
||
| env: | ||
| TEST_TEMPO_LOCALNET: "true" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { Instance } from 'prool/testcontainers' | ||
| import { describe, expect, expectTypeOf, test } from 'vitest' | ||
|
|
||
| describe('tempoLocalnetCommand', () => { | ||
| test.each([ | ||
| { expected: [], parameters: {} }, | ||
| { expected: ['--bare'], parameters: { bare: true } }, | ||
| { | ||
| expected: ['--block-time', '200ms'], | ||
| parameters: { blockTime: '200ms' }, | ||
| }, | ||
| { | ||
| expected: ['--bare', '--block-time', '1s'], | ||
| parameters: { bare: true, blockTime: '1s' }, | ||
| }, | ||
| ])('$expected', ({ expected, parameters }) => { | ||
| expect(Instance.tempoLocalnet(parameters)._internal.command).toEqual( | ||
| expected, | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| test('defines the bootstrapped localnet endpoint', () => { | ||
| const instance = Instance.tempoLocalnet({ | ||
| bare: true, | ||
| blockTime: '200ms', | ||
| }) | ||
|
|
||
| expect(instance.name).toBe('tempo-localnet') | ||
| expect(instance.host).toBe('localhost') | ||
| expect(instance.port).toBe(8545) | ||
| expect(instance.url).toBe('http://localhost:8545') | ||
| expect(instance._internal.args).toEqual({ | ||
| bare: true, | ||
| blockTime: '200ms', | ||
| }) | ||
| expect(instance._internal.command).toEqual([ | ||
| '--bare', | ||
| '--block-time', | ||
| '200ms', | ||
| ]) | ||
| expectTypeOf(instance).toMatchTypeOf<Instance.Instance>() | ||
| }) | ||
|
|
||
| test.skipIf(process.env['TEST_TEMPO_LOCALNET'] !== 'true')( | ||
| 'starts a healthy bootstrapped localnet', | ||
| { timeout: 240_000 }, | ||
| async () => { | ||
| const instance = Instance.tempoLocalnet({ | ||
| blockTime: '1ms', | ||
| image: | ||
| 'ghcr.io/tempoxyz/tempo-localnet@sha256:86f199f161be85d3610d990e5bc2653ece29de3ee9c91e8c8e768cf2b8c05c3b', | ||
| }) | ||
|
|
||
| try { | ||
| await instance.start() | ||
| const rpc = async (method: string, params: unknown[] = []) => { | ||
| const response = await fetch(instance.url, { | ||
| body: JSON.stringify({ id: 1, jsonrpc: '2.0', method, params }), | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| method: 'POST', | ||
| }) | ||
| return (await response.json()) as { result: unknown } | ||
| } | ||
|
|
||
| expect(await rpc('eth_chainId')).toMatchObject({ result: '0x539' }) | ||
| const funded = await rpc('tempo_fundAddress', [ | ||
| '0x000000000000000000000000000000000000beef', | ||
| ]) | ||
| expect(funded.result).toEqual([ | ||
| expect.stringMatching(/^0x[0-9a-f]{64}$/), | ||
| expect.stringMatching(/^0x[0-9a-f]{64}$/), | ||
| expect.stringMatching(/^0x[0-9a-f]{64}$/), | ||
| expect.stringMatching(/^0x[0-9a-f]{64}$/), | ||
| ]) | ||
| } finally { | ||
| await instance.stop().catch(() => {}) | ||
| } | ||
| }, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
VITE_FORK_URLis unavailable, this name filter skips the Alto test bodies but does not prevent their files' module-level setup from running:src/Pool.test.tsandsrc/Server.test.tsboth start a forked Anvil before tests are filtered. Those suites therefore still contact the public fallback RPC and can fail or be rate-limited before the skipped tests are considered, so the no-secret CI path remains externally fork-dependent; make those setup hooks conditional or refactor/exclude the fork-dependent suites themselves.Useful? React with 👍 / 👎.