Skip to content

Commit ef78149

Browse files
committed
[DO NOT MERGE] Debug flaky test (not reproducible on own machine)
1 parent 4e4a2a3 commit ef78149

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

.github/workflows/test-node.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- main
6+
- debug-flaky-test # temp
67
tags: # To trigger the canary
78
- '*'
89
pull_request:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Hypercore is a secure, distributed append-only log",
55
"main": "index.js",
66
"scripts": {
7-
"test": "standard && node test/all.js",
7+
"test": "npx brittle test/replicate.js",
88
"test:generate": "brittle -r test/all.js test/*.js"
99
},
1010
"repository": {

test/replicate.js

+32-26
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { create, replicate, unreplicate, eventFlush } = require('./helpers')
66
const { makeStreamPair } = require('./helpers/networking.js')
77
const Hypercore = require('../')
88

9+
/*
910
test('basic replication', async function (t) {
1011
const a = await create()
1112
@@ -1215,44 +1216,48 @@ test('cancel block', async function (t) {
12151216
await a.close()
12161217
await b.close()
12171218
})
1219+
*/
12181220

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

1222-
const a = await create()
1223-
const b = await create(a.key)
1225+
const a = await create()
1226+
const b = await create(a.key)
12241227

1225-
await a.append(['a', 'b', 'c'])
1228+
await a.append(['a', 'b', 'c'])
12261229

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

1231-
const s1 = b.session()
1232-
const s2 = b.session()
1234+
const s1 = b.session()
1235+
const s2 = b.session()
12331236

1234-
const cancelling = waitForRequestBlock(s1).then(() => s1.close())
1237+
const cancelling = waitForRequestBlock(s1).then(() => s1.close())
12351238

1236-
const b1 = s1.get(0)
1237-
const b2 = s2.get(0)
1239+
const b1 = s1.get(0)
1240+
const b2 = s2.get(0)
12381241

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

1246-
await cancelling
1249+
await cancelling
12471250

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

1252-
await a.close()
1253-
await b.close()
1254-
})
1255+
await a.close()
1256+
await b.close()
1257+
})
1258+
}
12551259

1260+
/*
12561261
test('retry failed block requests to another peer', async function (t) {
12571262
t.plan(6)
12581263
@@ -1485,6 +1490,7 @@ test('replication updates on core copy', async function (t) {
14851490
14861491
await t.execution(promise)
14871492
})
1493+
*/
14881494

14891495
async function waitForRequestBlock (core, opts) {
14901496
while (true) {

0 commit comments

Comments
 (0)