Skip to content

Commit 5ad6bb4

Browse files
committed
chore: fix unit test
1 parent 4774e87 commit 5ad6bb4

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

packages/beacon-node/test/unit/network/reqresp/handlers/beaconBlocksByHead.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,13 @@ describe("onBeaconBlocksByHead", () => {
121121
expect(chain.logger.verbose).toHaveBeenCalledOnce();
122122
});
123123

124-
it("allows zero-count requests", async () => {
124+
it("rejects zero-count requests", async () => {
125125
const blocks = createBlocks([10]);
126126
const chain = createChain(blocks);
127127

128-
const responses = await Array.fromAsync(
129-
onBeaconBlocksByHead({beaconRoot: blocks[0].root, count: 0}, chain, peerId, "test-client")
130-
);
131-
132-
expect(responses).toEqual([]);
128+
await expect(
129+
Array.fromAsync(onBeaconBlocksByHead({beaconRoot: blocks[0].root, count: 0}, chain, peerId, "test-client"))
130+
).rejects.toMatchObject({status: RespStatus.INVALID_REQUEST});
133131
expect(chain.getSerializedBlockByRoot).not.toHaveBeenCalled();
134132
});
135133

@@ -190,7 +188,7 @@ function createChain(blocks: TestBlock[], currentEpoch = 0, testConfig = config)
190188

191189
return {
192190
config: testConfig,
193-
clock: {currentEpoch},
191+
clock: {currentEpoch, currentSlot: computeStartSlotAtEpoch(currentEpoch)},
194192
getSerializedBlockByRoot: vi.fn(async (rootHex: string) => {
195193
const block = blocksByRoot.get(rootHex);
196194
return block ? {block: block.bytes, executionOptimistic: false, finalized: false, slot: block.slot} : null;

0 commit comments

Comments
 (0)