Skip to content

Commit 8901f0e

Browse files
authored
fix(chainHead_v1): bestBlock not announced after initialised (AcalaNetwork#972)
1 parent 438242d commit 8901f0e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/core/src/rpc/rpc-spec/chainHead_v1.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export const chainHead_v1_follow: Handler<[boolean], string> = async (
8888
finalizedBlockHashes: [context.chain.head.hash],
8989
finalizedBlockRuntime: withRuntime ? await context.chain.head.runtimeVersion : null,
9090
})
91+
callback({
92+
event: 'bestBlockChanged',
93+
bestBlockHash: context.chain.head.hash,
94+
})
9195
})
9296

9397
return id

packages/e2e/src/chainHead_v1.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ describe('chainHead_v1 rpc', async () => {
1717
const initialized = await nextValue()
1818
expect(initialized).toMatchSnapshot()
1919

20+
const [[firstBest]] = next.mock.calls.slice(1)
21+
expect(firstBest).toEqual({
22+
type: 'bestBlockChanged',
23+
bestBlockHash: '0x6c74912ce35793b05980f924c3a4cdf1f96c66b2bedd0c7b7378571e60918145',
24+
})
25+
2026
const blockHash = await dev.newBlock()
2127

22-
const [[newBlock], [bestBlock], [finalized]] = next.mock.calls.slice(1)
28+
const [[newBlock], [bestBlock], [finalized]] = next.mock.calls.slice(2)
2329

2430
expect(newBlock).toEqual({
2531
type: 'newBlock',

0 commit comments

Comments
 (0)