Skip to content

Commit

Permalink
Client: Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Apr 16, 2024
1 parent 9e60a09 commit d6c2a6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/client/src/net/peer/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ export abstract class Peer extends EventEmitter {
if (latest !== undefined) {
const height = latest.number
if (
this.config.syncTargetHeight === undefined ||
this.config.syncTargetHeight === BIGINT_0 ||
this.config.syncTargetHeight < latest.number
height > BIGINT_0 &&
(this.config.syncTargetHeight === undefined ||
this.config.syncTargetHeight === BIGINT_0 ||
this.config.syncTargetHeight < latest.number)
) {
this.config.syncTargetHeight = height
this.config.logger.info(`New sync target height=${height} hash=${short(latest.hash())}`)
Expand Down
8 changes: 8 additions & 0 deletions packages/client/test/integration/mocks/mockpeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createStream } from './network'
import type { PeerOptions } from '../../../src/net/peer'
import type { MockServer } from './mockserver'
import type { RemoteStream } from './network'
import type { BlockHeader } from '@ethereumjs/block'

// TypeScript doesn't have support yet for ReturnType
// with generic types, so this wrapper is used as a helper.
Expand Down Expand Up @@ -40,6 +41,13 @@ export class MockPeer extends Peer {
this.config.events.emit(Event.PEER_CONNECTED, this)
}

async latest(): Promise<BlockHeader | undefined> {
if (this.eth !== undefined) {
this.eth.updatedBestHeader = undefined
}
return super.latest()
}

async accept(server: MockServer) {
if (this.connected) {
return
Expand Down

0 comments on commit d6c2a6c

Please sign in to comment.