Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/beacon-node/test/unit/sync/unknownBlock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,11 @@ describe("UnknownBlockSync", () => {
peers: [{peerId: peer}],
}));

emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, {
// tsgo overload-resolution miss when emit is reached through a closure that captures emitter
// first; cast re-anchors the StrictEventEmitter overload for ChainEvent keys (see #9491).
(emitter as ChainEventEmitter).emit(ChainEvent.unknownEnvelopeBlockRoot, {
rootHex: blockRootHex,
slot: 0,
peer,
source: BlockInputSource.gossip,
});
Comment on lines +1027 to 1034

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the comment (tsgo instead of tsc). Additionally, instead of hardcoding slot: 0, it is more accurate and robust to use block.message.slot to match the slot of the block and envelope created in the test fixture.

Suggested change
// tsgo overload-resolution miss when emit is reached through a closure that captures emitter
// first; cast re-anchors the StrictEventEmitter overload for ChainEvent keys (see #9491).
(emitter as ChainEventEmitter).emit(ChainEvent.unknownEnvelopeBlockRoot, {
rootHex: blockRootHex,
slot: 0,
peer,
source: BlockInputSource.gossip,
});
// tsc overload-resolution miss when emit is reached through a closure that captures emitter
// first; cast re-anchors the StrictEventEmitter overload for ChainEvent keys (see #9491).
(emitter as ChainEventEmitter).emit(ChainEvent.unknownEnvelopeBlockRoot, {
rootHex: blockRootHex,
slot: block.message.slot,
peer,
source: BlockInputSource.gossip,
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining both suggestions, but flagging the reasoning:

  1. tsgo vs tsc — tsgo is correct, not a typo. This repo uses @typescript/native-preview via "check-types": "tsgo" in packages/beacon-node/package.json:94, with @typescript/native-preview: 7.0.0-dev.20260303.1 pinned in the root package.json. The overload-resolution behavior that motivates this cast is specifically tsgo's — tsc doesn't reject this site.

  2. slot: 0 vs block.message.slot — kept slot: 0 for consistency with every other emitter.emit(ChainEvent.unknownEnvelopeBlockRoot, ...) site in this file (unknownBlock.test.ts:762, :836, :926, :1131). The field is a logging/prune hint per the emitter.ts comment (// slot is the message slot, not necessarily the envelope's slot, but useful as a logging/prune hint), not a correctness-load-bearing value in these tests, and switching just this one site would diverge from the established pattern. Happy to update all sites to block.message.slot in a follow-up if you'd rather have semantic accuracy across the board.

Expand Down
Loading