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

Check RPC after geth startup to reduce flakiness #10406

Merged
merged 1 commit into from
Jul 4, 2023
Merged
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
22 changes: 20 additions & 2 deletions packages/celotool/src/lib/geth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,26 @@ export async function startGeth(
}
}

// Geth startup isn't fully done even when the port is open, so give it another second
await sleep(1000)
// Geth startup isn't fully done even when the port is open, so check until it responds
const maxTries = 5
let tries = 0
while (tries < maxTries) {
tries++
let block = null
try {
block = await new Web3('http://localhost:8545').eth.getBlock('latest')
} catch (e) {
console.log(`Failed to fetch test block: ${e}`)
}
if (block) {
break
}
console.log('Could not fetch test block. Wait one second, then retry.')
await sleep(1000)
}
if (tries === maxTries) {
throw new Error(`Geth did not start within ${tries} seconds`)
}

console.log(
`${instance.name}: running.`,
Expand Down