Skip to content

Commit

Permalink
Clean up typing in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 authored and g11tech committed Sep 22, 2023
1 parent bd495a2 commit e1af691
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/client/test/sim/beaconsync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ describe('simple mainnet test run', async () => {
// call sync if not has been called yet
void ejsClient.services[0].synchronizer?.sync()
const syncResponse = await Promise.race([beaconSyncPromise, syncTimeout])
assert(syncResponse.syncState, 'SYNCED', 'beaconSyncRelayer should have synced client')
assert.equal(
syncResponse.syncState,
'SYNCED',
'beaconSyncRelayer should have synced client'
)
await ejsClient.stop()
assert.ok(true, 'completed beacon sync')
} catch (e) {
Expand Down
15 changes: 8 additions & 7 deletions packages/client/test/sim/simutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { EthereumClient } from '../../src/client'
import { Config } from '../../src/config'
import { LevelDB } from '../../src/execution/level'
import { RPCManager } from '../../src/rpc'
import { Event } from '../../src/types'

import type { Common } from '@ethereumjs/common'
import type { TransactionType, TxData, TxOptions } from '@ethereumjs/tx'
Expand Down Expand Up @@ -479,16 +480,16 @@ export async function setupEngineUpdateRelay(client: EthereumClient, peerBeaconU

// possible values: STARTED, PAUSED, ERRORED, SYNCING, VALID
let syncState = 'PAUSED'
let pollInterval = null
let pollInterval: any | null = null
let waitForStates = ['VALID']
let errorMessage = ''
const updateState = (newState) => {
const updateState = (newState: string) => {
if (syncState !== 'PAUSED') {
syncState = newState
}
}

const playUpdate = async (payload, finalizedBlockHash, version) => {
const playUpdate = async (payload: any, finalizedBlockHash: string, version: string) => {
if (version !== 'capella') {
throw Error('only capella replay supported yet')
}
Expand Down Expand Up @@ -525,8 +526,8 @@ export async function setupEngineUpdateRelay(client: EthereumClient, peerBeaconU
}
}

// ignoring the actual even, just using it as trigger to feed
eventSource.addEventListener(topics[0], (async (_event: MessageEvent) => {
// ignoring the actual event, just using it as trigger to feed
eventSource.addEventListener(topics[0], async (_event: MessageEvent) => {
if (syncState === 'PAUSED' || syncState === 'CLOSED') return
try {
// just fetch finalized updated, it has all relevant hashes for fcU
Expand Down Expand Up @@ -555,7 +556,7 @@ export async function setupEngineUpdateRelay(client: EthereumClient, peerBeaconU
updateState('ERRORED')
errorMessage = (e as Error).message
}
}) as EventListener)
})

const cleanUpPoll = () => {
if (pollInterval !== null) {
Expand All @@ -564,7 +565,7 @@ export async function setupEngineUpdateRelay(client: EthereumClient, peerBeaconU
}
}

const start = (opts: { waitForStates?: string } = {}) => {
const start = (opts: { waitForStates?: string[] } = {}) => {
waitForStates = opts.waitForStates ?? ['VALID']
if (pollInterval !== null) {
throw Error('Already waiting on sync')
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/sim/snapsync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('simple mainnet test run', async () => {
const address = Address.fromString(addressString)
const account = await stateManager.getAccount(address)
assert.equal(
account.balance,
account?.balance,
BigInt(customGenesisState[addressString][0]),
`${addressString} balance should match`
)
Expand Down

0 comments on commit e1af691

Please sign in to comment.