Skip to content

Commit b85c4cb

Browse files
fetch latest block number from rpc
1 parent 764501a commit b85c4cb

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/ens-test-env/src/manager.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ export const main = async (_config, _options, justKill) => {
283283

284284
if (options.graph) {
285285
try {
286-
console.log('Starting postgres...')
287-
await compose.upOne('postgres', opts)
288-
console.log('Starting ipfs...')
289-
await compose.upOne('ipfs', opts)
290-
console.log('Starting graph-node...')
286+
// console.log('Starting postgres...')
287+
// await compose.upOne('postgres', opts)
288+
// console.log('Starting ipfs...')
289+
// await compose.upOne('ipfs', opts)
290+
// console.log('Starting graph-node...')
291291
await compose.upOne('graph-node', opts)
292292
console.log('Starting metadata...')
293293
// await compose.upOne('metadata', opts)
@@ -352,6 +352,14 @@ export const main = async (_config, _options, justKill) => {
352352

353353
if (!options.save && cmdsToRun.length > 0 && options.scripts) {
354354
if (options.graph) {
355+
356+
const latestBlock = await rpcFetch('eth_getBlockByNumber', ['latest', false])
357+
const latestBlockNumber = parseInt(latestBlock.result.number, 16)
358+
if (Number.isNaN(latestBlockNumber)) {
359+
console.error('Failed to fetch latest block number')
360+
return cleanup(undefined, 0)
361+
}
362+
355363
let indexArray = []
356364
const getCurrentIndex = async () =>
357365
fetch('http://localhost:8000/subgraphs/name/graphprotocol/ens', {
@@ -385,13 +393,11 @@ export const main = async (_config, _options, justKill) => {
385393
if (indexArray.length > 10) indexArray.shift()
386394
await new Promise((resolve) => setTimeout(resolve, 1000))
387395
if (indexArray.every((i) => i === indexArray[0]) && indexArray.length === 10) {
396+
console.error('Subgraph failed to launch properly')
388397
return cleanup(undefined, 0)
389398
}
390399
} while (
391-
indexArray[indexArray.length - 1] < 326
392-
// !indexArray.every((i) => i === indexArray[0]) ||
393-
// indexArray.length < 2 ||
394-
// indexArray[0] === 0
400+
indexArray[indexArray.length - 1] < latestBlockNumber
395401
)
396402
}
397403
/**

0 commit comments

Comments
 (0)