Skip to content

Commit e119cad

Browse files
committed
Avoid chained batch in deferred test (#58)
Follow-up for #51. Found while testing v2 on `memory-level` (#57).
1 parent b075a25 commit e119cad

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/sublevel-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,19 @@ exports.all = function (test, testCommon) {
136136
if (!deferred) await sub1.open()
137137
if (!deferred) await sub2.open()
138138

139-
const batch1 = sub1.batch()
140-
const batch2 = sub2.batch()
139+
const batch1 = []
140+
const batch2 = []
141141
const keys = []
142142

143+
// TODO: write before creating the sublevels, to make the deferred test more meaningful
143144
for (let i = 0; i < 256; i++) {
144145
const key = keyEncoding === 'buffer' ? Buffer.from([i]) : new Uint8Array([i])
145146
keys.push(key)
146-
batch1.put(key, 'aa')
147-
batch2.put(key, 'bb')
147+
batch1.push({ type: 'put', key, value: 'aa' })
148+
batch2.push({ type: 'put', key, value: 'bb' })
148149
}
149150

150-
await Promise.all([batch1.write(), batch2.write()])
151+
await Promise.all([sub1.batch(batch1), sub2.batch(batch2)])
151152

152153
const entries1 = await sub1.iterator().all()
153154
const entries2 = await sub2.iterator().all()

0 commit comments

Comments
 (0)