Skip to content

Commit a2f9d25

Browse files
committed
(do not merge) sanity check the tests do not hang
1 parent b258002 commit a2f9d25

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

.github/workflows/test-node.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Status
22
on:
33
push:
44
branches:
5-
- main
5+
- ensure-fixed
66
tags: # To trigger the canary
77
- '*'
88
pull_request:

test/replicate.js

+28-26
Original file line numberDiff line numberDiff line change
@@ -1216,42 +1216,44 @@ test('cancel block', async function (t) {
12161216
await b.close()
12171217
})
12181218

1219-
test('try cancel block from a different session', async function (t) {
1220-
t.plan(3)
1219+
for (let i = 0; i < 500; i++) {
1220+
test('try cancel block from a different session', async function (t) {
1221+
t.plan(3)
12211222

1222-
const a = await create()
1223-
const b = await create(a.key)
1223+
const a = await create()
1224+
const b = await create(a.key)
12241225

1225-
await a.append(['a', 'b', 'c'])
1226+
await a.append(['a', 'b', 'c'])
12261227

1227-
const [n1, n2] = makeStreamPair(t, { latency: [50, 50] })
1228-
a.replicate(n1)
1229-
b.replicate(n2)
1228+
const [n1, n2] = makeStreamPair(t, { latency: [50, 50] })
1229+
a.replicate(n1)
1230+
b.replicate(n2)
12301231

1231-
const s1 = b.session()
1232-
const s2 = b.session()
1232+
const s1 = b.session()
1233+
const s2 = b.session()
12331234

1234-
const cancelling = waitForRequestBlock(s1).then(() => s1.close())
1235+
const cancelling = waitForRequestBlock(s1).then(() => s1.close())
12351236

1236-
const b1 = s1.get(0)
1237-
const b2 = s2.get(0)
1237+
const b1 = s1.get(0)
1238+
const b2 = s2.get(0)
12381239

1239-
try {
1240-
await b1
1241-
t.fail('Should have failed')
1242-
} catch (err) {
1243-
t.is(err.code, 'REQUEST_CANCELLED')
1244-
}
1240+
try {
1241+
await b1
1242+
t.fail('Should have failed')
1243+
} catch (err) {
1244+
t.is(err.code, 'REQUEST_CANCELLED')
1245+
}
12451246

1246-
await cancelling
1247+
await cancelling
12471248

1248-
t.alike(await b2, b4a.from('a'))
1249-
t.alike(await s2.get(1), b4a.from('b'))
1250-
await s2.close()
1249+
t.alike(await b2, b4a.from('a'))
1250+
t.alike(await s2.get(1), b4a.from('b'))
1251+
await s2.close()
12511252

1252-
await a.close()
1253-
await b.close()
1254-
})
1253+
await a.close()
1254+
await b.close()
1255+
})
1256+
}
12551257

12561258
test('retry failed block requests to another peer', async function (t) {
12571259
t.plan(6)

0 commit comments

Comments
 (0)