Skip to content

Commit fa36c17

Browse files
committed
trie, client -> new CP mechanism: improved FullSynchronizer.runBlocks() test coverage
1 parent 3f47fca commit fa36c17

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

packages/client/test/sync/fullsync.spec.ts

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,41 +174,28 @@ tape('[FullSynchronizer]', async (t) => {
174174
t.deepEqual(sync.vm.blockchain.getHead(), oldHead, 'should not modify blockchain on emtpy run')
175175

176176
blockchain.getHead = td.func<any>()
177-
td.when(blockchain.getHead()).thenResolve(
178-
{
179-
hash: () => {
180-
return Buffer.from('hash1')
181-
},
182-
header: { number: new BN(1) },
183-
transactions: [],
184-
},
185-
{
177+
const getHeadResponse: any = []
178+
for (let i = 2; i <= 100; i++) {
179+
getHeadResponse.push({
186180
hash: () => {
187-
return Buffer.from('hash2')
181+
return Buffer.from(`hash${i}`)
188182
},
189-
header: { number: new BN(2) },
190-
transactions: [],
191-
}
192-
)
193-
t.equal(await sync.runBlocks(), 1)
183+
header: { number: new BN(i) },
184+
transactions: [i],
185+
})
186+
}
194187

195188
td.when(blockchain.getHead()).thenResolve(
196189
{
197190
hash: () => {
198-
return Buffer.from('hash1')
191+
return Buffer.from('hash0')
199192
},
200193
header: { number: new BN(1) },
201194
transactions: [],
202195
},
203-
{
204-
hash: () => {
205-
return Buffer.from('hash2')
206-
},
207-
header: { number: new BN(2) },
208-
transactions: [1, 2, 3],
209-
}
196+
...getHeadResponse
210197
)
211-
t.equal(await sync.runBlocks(), 1)
198+
t.equal(await sync.runBlocks(), 49)
212199

213200
t.end()
214201
})

0 commit comments

Comments
 (0)