Skip to content
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

Buffer to Uint8Array cleanup #2607

Merged
merged 19 commits into from
Apr 4, 2023
Merged
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions packages/client/test/miner/ethash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Config } from '../../lib'
import { createInlineClient } from '../sim/simutils'

import type { EthereumClient } from '../../lib'
import type { FullEthereumService } from '../../lib/service'

const pk = hexToBytes('95a602ff1ae30a2243f400dcf002561b9743b2ae9827b1008e3714a5cc1c0cfe')
const minerAddress = Address.fromPrivateKey(pk)
Expand Down Expand Up @@ -94,7 +95,6 @@ const stopClient = async (client: EthereumClient, t: tape.Test) => {
}

const restartClient = async (client: EthereumClient, t: tape.Test) => {
await client.start()
await new Promise((resolve) => {
client.config.logger.on('data', (data) => {
if (data.message.includes('Miner: Found PoW solution') === true && client.started) {
Copy link
Member

Choose a reason for hiding this comment

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

This test looks good, but the only problem I have here is that if this test fails (we broke the miner) this test will run endlessly and thus our CI will not finish. Maybe add a time limit of a minute or so, which rejects the promise if no solution is found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a 60 second timeout to the test so the whole suite fails if it doesn't complete in 60 seconds (which I think should be sufficient).

Expand All @@ -110,7 +110,10 @@ tape('start client', async (t) => {
const client = await setupPowDevnet(minerAddress, true)
t.ok(client.started, 'client started successfully')
await stopClient(client, t)
const restartedClient = await setupPowDevnet(minerAddress, false)
await restartClient(restartedClient, t)
await client.open()
await ((client.service('eth') as FullEthereumService).execution as any).stateDB!.open()
Copy link
Member

Choose a reason for hiding this comment

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

In general this is a great test too, so if we stop the client some internal variables are not cleaned up (so we cannot restart correctly). But this is a different issue, should be addressed though.

await client.chain.blockchain.db.open()
await client.start()
await restartClient(client, t)
t.end()
})