This repository was archived by the owner on Jan 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
test: one block per second #83
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2c695da
test: one block per second
alber70g 791a233
add test sync-nodes
sstraatemans 1b9df62
waiting for cutheight
sstraatemans 54daeda
remove .only
sstraatemans 0afee00
Merge branch 'main' into ag/reth-one-block-per-second
sstraatemans 9f54621
test multiple miners
sstraatemans 56aabc7
teting verify miners test
sstraatemans ae88c95
add verify miner awards test
sstraatemans 7ac80a0
remove devnet stop
sstraatemans 897caea
ignore failing test
sstraatemans 5b732d3
start tests checking logs
sstraatemans f571273
fix the docker-compose
sstraatemans c95c529
run all scripts
sstraatemans 2f963ed
address comments
sstraatemans 8332b4f
fix readme
sstraatemans 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
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,54 @@ | ||
| import { describe, test, expect, afterAll, beforeAll, it } from 'bun:test'; | ||
| import { | ||
| $devnet, | ||
| CONFIG, | ||
| createDockerComposeFile, | ||
| generateDockerComposeAndStartNetwork, | ||
| getDevnetStatus, | ||
| stopAndRemoveNetwork, | ||
| waitFor, | ||
| waitForMinCutHeight, | ||
| } from './devnet-utils'; | ||
| import { DOCKER_COMPOSE_FILE } from './devnet-utils'; | ||
| import { createLogger } from './utils'; | ||
| import { fs, $ } from 'zx'; | ||
|
|
||
| $.verbose = CONFIG.VERBOSE; | ||
|
|
||
| const log = createLogger({ context: 'fast-block-production.test.ts' }); | ||
|
|
||
| describe(`e2e: verify fast block production for reth`, () => { | ||
| beforeAll(() => { | ||
| // if (CONFIG.CLEAN_BEFORE) { | ||
| // return stopAndRemoveNetwork(); | ||
| // } | ||
| }); | ||
| afterAll(() => { | ||
| if (CONFIG.CLEAN_AFTER) { | ||
| return stopAndRemoveNetwork(); | ||
| } | ||
| }); | ||
|
|
||
| test(`e2e: produces 1 block a second or faster`, async () => { | ||
| await generateDockerComposeAndStartNetwork(); | ||
|
|
||
| console.log('waiting for cut-height to reach 98*4...'); | ||
| await waitForMinCutHeight(98 * 4, { timeoutSeconds: 150 }); | ||
|
|
||
| const devnetStatus = await getDevnetStatus(); | ||
| expect(devnetStatus.cutHeight).toBeGreaterThan(98 * 4); | ||
| const currentHeight = devnetStatus.cutHeight; | ||
| const currentTime = Date.now(); | ||
|
|
||
| // wait for a single height = 98 blocks | ||
| await waitForMinCutHeight(currentHeight + 98 * 1, { timeoutSeconds: 100 }); | ||
|
|
||
| const newDevnetStatus = await getDevnetStatus(); | ||
| expect(newDevnetStatus.cutHeight).toBeGreaterThan(currentHeight + 98 * 1); | ||
| const newTime = Date.now(); | ||
|
|
||
| const timePerBlock = (newTime - currentTime) / 98; | ||
| console.log(`produced 98 blocks in ${newTime - currentTime} ms`); | ||
| expect(timePerBlock).toBeLessThanOrEqual(1000); | ||
| }); | ||
| }); |
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,33 @@ | ||
| import { describe, test, expect, afterAll, beforeAll } from 'bun:test'; | ||
| import { | ||
| CONFIG, | ||
| generateDockerComposeAndStartNetwork, | ||
| getDevnetStatus, | ||
| stopAndRemoveNetwork, | ||
| waitForMinCutHeight, | ||
| } from './devnet-utils'; | ||
|
|
||
| describe(`e2e: multinode config with miners`, () => { | ||
| beforeAll(() => {}); | ||
| afterAll(() => { | ||
| if (CONFIG.CLEAN_AFTER) { | ||
| return stopAndRemoveNetwork(); | ||
| } | ||
| }); | ||
|
|
||
| test('should see an update in blockheight on every chain', async () => { | ||
| await generateDockerComposeAndStartNetwork(); | ||
| const devnetStatus = await getDevnetStatus(); | ||
|
|
||
| const evmChains = devnetStatus.chains.filter((c) => c.type === 'evm'); | ||
| expect(evmChains.length).toBeGreaterThan(1); | ||
| const currentHeight = devnetStatus.cutHeight; | ||
|
|
||
| // wait for a 2 height (just to be sure that all are upadted) | ||
| await waitForMinCutHeight(currentHeight + 98 * 2, { timeoutSeconds: 100 }); | ||
| const newDevnetStatus = await getDevnetStatus(); | ||
| const newEvmChains = newDevnetStatus.chains.filter((c) => c.type === 'evm'); | ||
|
|
||
| expect(!!evmChains.find((chain, idx) => chain.height >= newEvmChains[idx]!.height)).toBe(false); | ||
| }); | ||
| }); |
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,59 @@ | ||
| import { describe, test, expect, afterAll, beforeAll } from 'bun:test'; | ||
| import { | ||
| CONFIG, | ||
| generateDockerComposeAndStartNetwork, | ||
| getDevnetStatus, | ||
| restartContainer, | ||
| stopAndRemoveNetwork, | ||
| stopContainer, | ||
| waitForMinCutHeight, | ||
| type DevnetChainStatus, | ||
| type DevnetStatus, | ||
| } from './devnet-utils'; | ||
|
|
||
| const getChainStatus = (chainId: number, status: DevnetStatus): DevnetChainStatus => { | ||
| return status.chains.find((c) => c.chainId === chainId)!; | ||
| }; | ||
|
|
||
| describe.only(`e2e: sync nodes`, () => { | ||
| beforeAll(() => { | ||
| if (CONFIG.CLEAN_BEFORE) { | ||
| return stopAndRemoveNetwork(); | ||
| } | ||
| }); | ||
| afterAll(() => { | ||
| if (CONFIG.CLEAN_AFTER) { | ||
| return stopAndRemoveNetwork(); | ||
| } | ||
| }); | ||
|
|
||
| test('should have node2 catchup with node1 after it went down', async () => { | ||
| await generateDockerComposeAndStartNetwork(); | ||
|
|
||
| const devnetStatus = await getDevnetStatus(); | ||
| const currentHeight = devnetStatus.cutHeight; | ||
| const chain21 = getChainStatus(21, devnetStatus); | ||
| console.log(`evm-21 height: ${chain21.height}`); | ||
|
|
||
| await stopContainer('bootnode-evm-21'); | ||
| console.log('stopped bootnode-evm-21'); | ||
|
|
||
| // wait for a 2 height (just to be sure that all are upadted) | ||
| await waitForMinCutHeight(currentHeight + 98 * 2, { timeoutSeconds: 100 }); | ||
| const newDevnetStatus = await getDevnetStatus(); | ||
| const newChain21 = getChainStatus(21, newDevnetStatus); | ||
| const newCurrentHeight = newDevnetStatus.cutHeight; | ||
|
|
||
| expect(newChain21.height).toBe(chain21.height); | ||
|
|
||
| // wait for a 2 height (just to be sure that all are upadted) | ||
| await restartContainer('bootnode-evm-21'); | ||
| console.log('restarted bootnode-evm-21'); | ||
| await waitForMinCutHeight(newCurrentHeight + 98 * 3, { timeoutSeconds: 100 }); | ||
| const newDevnetStatus2 = await getDevnetStatus(); | ||
| const newChain21_2 = getChainStatus(21, newDevnetStatus2); | ||
|
|
||
| console.log(`evm-21 height: ${newChain21_2.height}`); | ||
| expect(newChain21_2.height).toBeGreaterThan(newChain21.height); | ||
| }); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.