Skip to content

Commit

Permalink
More debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad committed Aug 25, 2023
1 parent f7e8c2c commit f9dbf37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
13 changes: 0 additions & 13 deletions packages/core/src/hooks/useCall.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,42 +319,29 @@ describe('useCall', () => {

const blockNumber = await network1.provider.getBlockNumber()

console.log('322')
await waitForCurrent(({ block1, block2 }) => !!(block1 && block2))
console.log('324')
expect(result.error).to.be.undefined
expect(getResultProperty(result, 'block1')).to.eq(blockNumber)
expect(getResultProperty(result, 'block2')).to.eq(blockNumber)

await network1.provider.mine()

console.log('331')
await waitForCurrent(({ block1 }) => block1 !== undefined && Number(block1.value?.[0]) === blockNumber + 1)
console.log('333')
expect(getResultProperty(result, 'block1')).to.eq(blockNumber + 1)
expect(getResultProperty(result, 'block2')).to.eq(blockNumber)

await network1.provider.mine()

console.log('339')
await waitForExpect(() => {
expect(getResultProperty(result, 'block1')).to.eq(blockNumber + 2)
expect(getResultProperty(result, 'block2')).to.eq(blockNumber + 2)
})
console.log('344')

for (let i = 0; i < 3; i++) {
await network1.provider.mine()
}

console.log('350')
await waitForExpect(async () => {
console.log({
res1: getResultProperty(result, 'block1'),
res2: getResultProperty(result, 'block2'),
actual: await network1.provider.getBlockNumber(),
blockNumber,
})
expect(getResultProperty(result, 'block1')).to.eq(blockNumber + 5)
const block2 = Number(getResultProperty(result, 'block2'))
// we don't actually know when the update is gonna happen - both possibilities are possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export async function subscribeToNewBlock(
await provider.on('block', update)

provider.getBlockNumber().then(
(blockNumber) => update(blockNumber),
(blockNumber) => {
console.log('new block', blockNumber)
update(blockNumber)
},
(err) => {
console.error(err)
}
Expand Down

0 comments on commit f9dbf37

Please sign in to comment.