Skip to content

Commit

Permalink
client: fix type issues (#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau authored Jul 28, 2023
1 parent f5fc7d4 commit 6308469
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/client/test/net/peerpool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ describe('[PeerPool]', async () => {
pool.ban(p, 1000)
}
pool.config.events.on(Event.POOL_PEER_BANNED, (peer) =>
assert.equal(peer, peers[1], 'banned peer')
assert.equal(peer, peers[1] as any, 'banned peer')
)
pool.config.events.on(Event.POOL_PEER_REMOVED, (peer) =>
assert.equal(peer, peers[1], 'removed peer')
assert.equal(peer, peers[1] as any, 'removed peer')
)
assert.equal(pool.peers[0], peers[0], 'outbound peer not banned')
assert.equal(pool.peers[0], peers[0] as any, 'outbound peer not banned')
})

it('should reset td', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/client/test/sim/snapsync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import debug from 'debug'
import { Client } from 'jayson/promise'
import { assert, describe, it } from 'vitest'

import { Config } from '../../src/config'
import { getLogger } from '../../src/logging'
import { Event } from '../../src/types'
import { Config } from '../../src/config.js'
import { getLogger } from '../../src/logging.js'
import { Event } from '../../src/types.js'

import {
createInlineClient,
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('simple mainnet test run', async () => {
}

// ------------Sanity checks--------------------------------
it('add some EOA transfers', { skip: process.env.ADD_EOA_STATE === undefined }, async () => {
it.skipIf(process.env.ADD_EOA_STATE === undefined)('add some EOA transfers', async () => {
const startBalance = await client.request('eth_getBalance', [
'0x3dA33B9A0894b908DdBb00d96399e506515A1009',
'latest',
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('simple mainnet test run', async () => {
)
})

it('setup snap sync', { skip: process.env.SNAP_SYNC === undefined }, async () => {
it.skipIf(process.env.ADD_EOA_STATE === undefined)('setup snap sync', async () => {
// start client inline here for snap sync, no need for beacon
const { ejsInlineClient, peerConnectedPromise, snapSyncCompletedPromise } =
// eslint-disable-next-line @typescript-eslint/no-use-before-define
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/sync/fetcher/blockfetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('[BlockFetcher]', async () => {
count: BigInt(0),
})
td.when((fetcher as any).pool.idle(td.matchers.anything())).thenReturn('peer0')
assert.equal(fetcher.peer(), 'peer0', 'found peer')
assert.equal(fetcher.peer(), 'peer0' as any, 'found peer')
})

it('should request correctly', async () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/client/test/sync/fetcher/fetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ describe('[Fetcher]', () => {
;(fetcher as any).total = 10
fetcher.next()
setTimeout(() => {
assert.deepEqual(job, { index: 0, peer: { idle: false }, state: 'expired' }, 'expired job')
assert.deepEqual(
job as any,
{ index: 0, peer: { idle: false }, state: 'expired' },
'expired job'
)
assert.equal((fetcher as any).in.length, 1, 'enqueued job')
}, 20)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/client/test/sync/fetcher/headerfetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ describe('[HeaderFetcher]', async () => {
assert.deepEqual(
//@ts-ignore
fetcher.process({ task: { count: 2 }, peer: 'peer0' }, { headers, bv: BigInt(1) }),
headers,
headers as any,
'got results'
)
//@ts-ignore
assert.notOk(
fetcher.process({ task: { count: 2 } }, { headers: [], bv: BigInt(1) }),
fetcher.process({ task: { count: 2 } } as any, { headers: [], bv: BigInt(1) } as any),
'bad results'
)
td.verify((fetcher as any).flow.handleReply('peer0', 1))
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('[HeaderFetcher]', async () => {
const pool = new PeerPool()
const fetcher = new HeaderFetcher({ config, pool })
td.when((fetcher as any).pool.idle(td.matchers.anything())).thenReturn('peer0')
assert.equal(fetcher.peer(), 'peer0', 'found peer')
assert.equal(fetcher.peer(), 'peer0' as any, 'found peer')
})

it('should request correctly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('[ReverseBlockFetcher]', async () => {
count: BigInt(2),
})
td.when((fetcher as any).pool.idle(td.matchers.anything())).thenReturn('peer0')
assert.equal(fetcher.peer(), 'peer0', 'found peer')
assert.equal(fetcher.peer(), 'peer0' as any, 'found peer')
})

it('should request correctly', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/sync/snapsync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('[SnapSynchronizer]', async () => {
]
;(sync as any).pool = { peers }
;(sync as any).forceSync = true
assert.equal(await sync.best(), peers[1], 'found best')
assert.equal(await sync.best(), peers[1] as any, 'found best')
await sync.start()
})
})
2 changes: 1 addition & 1 deletion packages/devp2p/test/integration/rlpx-simulator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('RLPx simulator tests', () => {
rlpxs[0]['_dpt']!['_banlist'].has(peer),
'should not be in ban list before bad peer discovered'
)
rlpxs[0]['_dpt']!.emit('peer:new', peer)
rlpxs[0]['_dpt']!.events.emit('peer:new', peer)
assert.ok(
rlpxs[0]['_dpt']!['_banlist'].has(peer),
'should be in ban list after bad peer discovered'
Expand Down
2 changes: 1 addition & 1 deletion packages/devp2p/test/integration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function initTwoPeerRLPXSetup(
capabilities?: any,
common?: Object | Common,
basePort = 30306
) {
): RLPx[] {
const rlpxs = getTestRLPXs(2, maxPeers, basePort, capabilities, common)
const peer = { address: localhost, udpPort: basePort + 1, tcpPort: basePort + 1 }
rlpxs[0]['_dpt']!.addPeer(peer).catch(() => {
Expand Down

0 comments on commit 6308469

Please sign in to comment.