Skip to content

Commit 5be8db1

Browse files
committed
Fix test
1 parent 02b8845 commit 5be8db1

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/trie/test/stream.spec.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,17 @@ describe('kv stream test', () => {
105105
await trie.batch(ops)
106106
})
107107

108-
it('should fetch all of the nodes', () => {
108+
it('should fetch all of the nodes', async () => {
109109
const stream = trie.createReadStream()
110-
stream.on('data', (d: any) => {
111-
const key = d.key.toString()
112-
const value = d.value.toString()
110+
for await (const chunk of stream) {
111+
const key = chunk.key.toString()
112+
const value = chunk.value.toString()
113113
assert.equal(valObj[key], value)
114114
delete valObj[key]
115-
})
116-
stream.on('end', () => {
117-
const keys = Object.keys(valObj)
118-
assert.equal(keys.length, 0)
119-
})
115+
}
116+
117+
const keys = Object.keys(valObj)
118+
assert.equal(keys.length, 0)
120119
})
121120
})
122121

0 commit comments

Comments
 (0)