@atproto/pds 0.5.6 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/background.d.ts +12 -6
  3. package/dist/background.d.ts.map +1 -1
  4. package/dist/background.js +32 -13
  5. package/dist/background.js.map +1 -1
  6. package/dist/context.d.ts.map +1 -1
  7. package/dist/context.js +4 -31
  8. package/dist/context.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +33 -11
  12. package/dist/index.js.map +1 -1
  13. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts +5 -0
  14. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts.map +1 -1
  15. package/dist/lexicons/app/bsky/notification/defs.defs.js +1 -0
  16. package/dist/lexicons/app/bsky/notification/defs.defs.js.map +1 -1
  17. package/dist/lexicons/chat/bsky/notification/defs.d.ts +2 -0
  18. package/dist/lexicons/chat/bsky/notification/defs.d.ts.map +1 -0
  19. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts +20 -0
  20. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts.map +1 -0
  21. package/dist/lexicons/chat/bsky/notification/defs.defs.js +19 -0
  22. package/dist/lexicons/chat/bsky/notification/defs.defs.js.map +1 -0
  23. package/dist/lexicons/chat/bsky/notification/defs.js +5 -0
  24. package/dist/lexicons/chat/bsky/notification/defs.js.map +1 -0
  25. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts +3 -0
  26. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts.map +1 -0
  27. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts +18 -0
  28. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts.map +1 -0
  29. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js +16 -0
  30. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js.map +1 -0
  31. package/dist/lexicons/chat/bsky/notification/getPreferences.js +6 -0
  32. package/dist/lexicons/chat/bsky/notification/getPreferences.js.map +1 -0
  33. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts +3 -0
  34. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts.map +1 -0
  35. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts +27 -0
  36. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts.map +1 -0
  37. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js +22 -0
  38. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js.map +1 -0
  39. package/dist/lexicons/chat/bsky/notification/putPreferences.js +6 -0
  40. package/dist/lexicons/chat/bsky/notification/putPreferences.js.map +1 -0
  41. package/dist/lexicons/chat/bsky/notification.d.ts +4 -0
  42. package/dist/lexicons/chat/bsky/notification.d.ts.map +1 -0
  43. package/dist/lexicons/chat/bsky/notification.js +7 -0
  44. package/dist/lexicons/chat/bsky/notification.js.map +1 -0
  45. package/dist/lexicons/chat/bsky.d.ts +1 -0
  46. package/dist/lexicons/chat/bsky.d.ts.map +1 -1
  47. package/dist/lexicons/chat/bsky.js +1 -0
  48. package/dist/lexicons/chat/bsky.js.map +1 -1
  49. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +4 -0
  50. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
  51. package/dist/lexicons/tools/ozone/report/defs.defs.js +2 -0
  52. package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
  53. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts +3 -0
  54. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts.map +1 -0
  55. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts +42 -0
  56. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts.map +1 -0
  57. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js +31 -0
  58. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js.map +1 -0
  59. package/dist/lexicons/tools/ozone/report/queryActivities.js +6 -0
  60. package/dist/lexicons/tools/ozone/report/queryActivities.js.map +1 -0
  61. package/dist/lexicons/tools/ozone/report.d.ts +1 -0
  62. package/dist/lexicons/tools/ozone/report.d.ts.map +1 -1
  63. package/dist/lexicons/tools/ozone/report.js +1 -0
  64. package/dist/lexicons/tools/ozone/report.js.map +1 -1
  65. package/dist/pipethrough.d.ts +3 -0
  66. package/dist/pipethrough.d.ts.map +1 -1
  67. package/dist/pipethrough.js +32 -0
  68. package/dist/pipethrough.js.map +1 -1
  69. package/package.json +11 -11
  70. package/src/background.ts +49 -18
  71. package/src/context.ts +4 -37
  72. package/src/index.ts +31 -13
  73. package/src/pipethrough.ts +38 -1
  74. package/tests/_util.ts +8 -25
  75. package/tests/account-deactivation.test.ts +1 -1
  76. package/tests/account-deletion.test.ts +1 -1
  77. package/tests/account-migration.test.ts +2 -2
  78. package/tests/account-status.test.ts +1 -1
  79. package/tests/account.test.ts +1 -1
  80. package/tests/app-passwords.test.ts +1 -1
  81. package/tests/auth.test.ts +1 -1
  82. package/tests/blob-deletes.test.ts +1 -1
  83. package/tests/create-post.test.ts +1 -1
  84. package/tests/crud.test.ts +1 -1
  85. package/tests/db.test.ts +1 -1
  86. package/tests/email-confirmation.test.ts +1 -1
  87. package/tests/file-uploads.test.ts +2 -2
  88. package/tests/get-service-auth.test.ts +1 -1
  89. package/tests/handles.test.ts +1 -1
  90. package/tests/invite-codes.test.ts +1 -1
  91. package/tests/invites-admin.test.ts +1 -1
  92. package/tests/moderation.test.ts +1 -1
  93. package/tests/moderator-auth.test.ts +1 -1
  94. package/tests/plc-operations.test.ts +1 -1
  95. package/tests/preferences.test.ts +1 -1
  96. package/tests/proxied/admin.test.ts +1 -1
  97. package/tests/proxied/feedgen.test.ts +1 -1
  98. package/tests/proxied/notif.test.ts +6 -13
  99. package/tests/proxied/procedures.test.ts +1 -1
  100. package/tests/proxied/proxy-catchall.test.ts +9 -8
  101. package/tests/proxied/proxy-header.test.ts +12 -8
  102. package/tests/proxied/proxy-oauth-aud.test.ts +17 -10
  103. package/tests/proxied/read-after-write.test.ts +4 -5
  104. package/tests/proxied/views.test.ts +1 -1
  105. package/tests/races.test.ts +1 -1
  106. package/tests/rate-limits.test.ts +1 -1
  107. package/tests/recovery.test.ts +1 -1
  108. package/tests/seeds/basic.ts +2 -2
  109. package/tests/seeds/users.ts +4 -1
  110. package/tests/sequencer.test.ts +1 -1
  111. package/tests/server.test.ts +9 -12
  112. package/tests/sync/invertible-ops.test.ts +1 -1
  113. package/tests/sync/list.test.ts +1 -1
  114. package/tests/sync/subscribe-repos.test.ts +1 -1
  115. package/tests/sync/sync.test.ts +1 -1
  116. package/tests/takedown-appeal.test.ts +1 -1
  117. package/tsconfig.build.tsbuildinfo +1 -1
@@ -24,7 +24,7 @@ describe('app_passwords', () => {
24
24
  })
25
25
 
26
26
  afterAll(async () => {
27
- await network.close()
27
+ await network?.close()
28
28
  })
29
29
 
30
30
  let appPass: string
@@ -16,7 +16,7 @@ describe('auth', () => {
16
16
  })
17
17
 
18
18
  afterAll(async () => {
19
- await network.close()
19
+ await network?.close()
20
20
  })
21
21
 
22
22
  const createAccount = async (info) => {
@@ -35,7 +35,7 @@ describe('blob deletes', () => {
35
35
  })
36
36
 
37
37
  afterAll(async () => {
38
- await network.close()
38
+ await network?.close()
39
39
  })
40
40
 
41
41
  const getDbBlobsForDid = (did: string) => {
@@ -25,7 +25,7 @@ describe('pds posts record creation', () => {
25
25
  })
26
26
 
27
27
  afterAll(async () => {
28
- await network.close()
28
+ await network?.close()
29
29
  })
30
30
 
31
31
  it('allows for creating posts with tags', async () => {
@@ -47,7 +47,7 @@ describe('crud operations', () => {
47
47
  })
48
48
 
49
49
  afterAll(async () => {
50
- await network.close()
50
+ await network?.close()
51
51
  })
52
52
 
53
53
  it('registers users', async () => {
package/tests/db.test.ts CHANGED
@@ -14,7 +14,7 @@ describe('db', () => {
14
14
  })
15
15
 
16
16
  afterAll(async () => {
17
- await network.close()
17
+ await network?.close()
18
18
  })
19
19
 
20
20
  it('commits changes', async () => {
@@ -42,7 +42,7 @@ describe('email confirmation', () => {
42
42
 
43
43
  afterAll(async () => {
44
44
  mailer.transporter.sendMail = _origSendMail
45
- await network.close()
45
+ await network?.close()
46
46
  })
47
47
 
48
48
  const getMailFrom = async (promise): Promise<SendMailOptions> => {
@@ -41,8 +41,8 @@ describe('file uploads', () => {
41
41
  })
42
42
 
43
43
  afterAll(async () => {
44
- aliceDb.close()
45
- await network.close()
44
+ aliceDb?.close()
45
+ await network?.close()
46
46
  })
47
47
 
48
48
  let smallBlob: TypedBlobRef
@@ -23,7 +23,7 @@ describe('com.atproto.server.getServiceAuth', () => {
23
23
  })
24
24
 
25
25
  afterAll(async () => {
26
- await network.close()
26
+ await network?.close()
27
27
  })
28
28
 
29
29
  it('issues a token whose aud matches a bare-DID input', async () => {
@@ -60,7 +60,7 @@ describe('handles', () => {
60
60
  })
61
61
 
62
62
  afterAll(async () => {
63
- await network.close()
63
+ await network?.close()
64
64
  })
65
65
 
66
66
  const getHandleFromDb = async (
@@ -26,7 +26,7 @@ describe('account', () => {
26
26
  })
27
27
 
28
28
  afterAll(async () => {
29
- await network.close()
29
+ await network?.close()
30
30
  })
31
31
 
32
32
  it('describes the fact that invites are required', async () => {
@@ -20,7 +20,7 @@ describe('pds admin invite views', () => {
20
20
  })
21
21
 
22
22
  afterAll(async () => {
23
- await network.close()
23
+ await network?.close()
24
24
  })
25
25
 
26
26
  let alice: string
@@ -47,7 +47,7 @@ describe('moderation', () => {
47
47
  })
48
48
 
49
49
  afterAll(async () => {
50
- await network.close()
50
+ await network?.close()
51
51
  })
52
52
 
53
53
  it('takes down accounts', async () => {
@@ -71,7 +71,7 @@ describe('moderator auth', () => {
71
71
  }, 20_000) // @NOTE seeding can take a while
72
72
 
73
73
  afterAll(async () => {
74
- await network.close()
74
+ await network?.close()
75
75
  })
76
76
 
77
77
  it('allows service auth requests from the configured appview did', async () => {
@@ -48,7 +48,7 @@ describe('plc operations', () => {
48
48
  })
49
49
 
50
50
  afterAll(async () => {
51
- await network.close()
51
+ await network?.close()
52
52
  })
53
53
 
54
54
  const getMailFrom = async (promise): Promise<SendMailOptions> => {
@@ -29,7 +29,7 @@ describe('user preferences', () => {
29
29
  }, 20_000) // @NOTE seeding can take a while
30
30
 
31
31
  afterAll(async () => {
32
- await network.close()
32
+ await network?.close()
33
33
  })
34
34
 
35
35
  it('requires auth to set or put preferences.', async () => {
@@ -69,7 +69,7 @@ describe('proxies admin requests', () => {
69
69
  })
70
70
 
71
71
  afterAll(async () => {
72
- await network.close()
72
+ await network?.close()
73
73
  })
74
74
 
75
75
  it('creates reports of a repo.', async () => {
@@ -51,7 +51,7 @@ describe('feedgen proxy view', () => {
51
51
  })
52
52
 
53
53
  afterAll(async () => {
54
- await network.close()
54
+ await network?.close()
55
55
  })
56
56
 
57
57
  it('performs basic proxy of getFeed', async () => {
@@ -1,16 +1,13 @@
1
- import { once } from 'node:events'
2
- import http from 'node:http'
3
- import { AddressInfo } from 'node:net'
4
- import express from 'express'
5
1
  import { AtpAgent } from '@atproto/api'
6
2
  import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
7
3
  import { createServer, verifyJwt } from '@atproto/xrpc-server'
8
4
  import { app } from '../../src/lexicons/index.js'
5
+ import { startServer } from '../_util.js'
9
6
  import usersSeed from '../seeds/users.js'
10
7
 
11
8
  describe('notif service proxy', () => {
12
9
  let network: TestNetworkNoAppView
13
- let notifServer: http.Server
10
+ let notifServer: AsyncDisposable & { port: number }
14
11
  let notifDid: string
15
12
  let agent: AtpAgent
16
13
  let sc: SeedClient
@@ -29,10 +26,9 @@ describe('notif service proxy', () => {
29
26
  notifServer = await createMockNotifService(spy)
30
27
  notifDid = sc.dids.dan
31
28
  await plc.updateData(notifDid, network.pds.ctx.plcRotationKey, (x) => {
32
- const addr = notifServer.address() as AddressInfo
33
29
  x.services['bsky_notif'] = {
34
30
  type: 'BskyNotificationService',
35
- endpoint: `http://localhost:${addr.port}`,
31
+ endpoint: `http://localhost:${notifServer.port}`,
36
32
  }
37
33
  return x
38
34
  })
@@ -40,9 +36,8 @@ describe('notif service proxy', () => {
40
36
  }, 20_000) // @NOTE seeding can take a while
41
37
 
42
38
  afterAll(async () => {
43
- await network.close()
44
- notifServer.close()
45
- await once(notifServer, 'close')
39
+ await notifServer?.[Symbol.asyncDispose]()
40
+ await network?.close()
46
41
  })
47
42
 
48
43
  it('proxies to notif service.', async () => {
@@ -86,7 +81,5 @@ async function createMockNotifService(ref: { current: unknown }) {
86
81
  jwt: req.headers.authorization?.replace('Bearer ', ''),
87
82
  }
88
83
  })
89
- const server = express().use(svc.router).listen()
90
- await once(server, 'listening')
91
- return server
84
+ return startServer(svc.router)
92
85
  }
@@ -25,7 +25,7 @@ describe('proxies appview procedures', () => {
25
25
  })
26
26
 
27
27
  afterAll(async () => {
28
- await network.close()
28
+ await network?.close()
29
29
  })
30
30
 
31
31
  it('maintains muted actors.', async () => {
@@ -4,6 +4,8 @@ import { AddressInfo } from 'node:net'
4
4
  import { setTimeout as sleep } from 'node:timers/promises'
5
5
  import * as plc from '@did-plc/lib'
6
6
  import express from 'express'
7
+ // eslint-disable-next-line import/default
8
+ import httpTerminator from 'http-terminator'
7
9
  import AtpAgent from '@atproto/api'
8
10
  import { Keypair } from '@atproto/crypto'
9
11
  import { TestNetworkNoAppView } from '@atproto/dev-env'
@@ -158,10 +160,14 @@ describe('proxy header', () => {
158
160
  })
159
161
 
160
162
  class ProxyServer {
163
+ private terminator: httpTerminator.HttpTerminator
164
+
161
165
  constructor(
162
- private server: http.Server,
166
+ server: http.Server,
163
167
  public did: string,
164
- ) {}
168
+ ) {
169
+ this.terminator = httpTerminator.createHttpTerminator({ server })
170
+ }
165
171
 
166
172
  static async create(
167
173
  plcClient: plc.Client,
@@ -245,11 +251,6 @@ class ProxyServer {
245
251
  }
246
252
 
247
253
  async close() {
248
- await new Promise<void>((resolve, reject) => {
249
- this.server.close((err) => {
250
- if (err) reject(err)
251
- else resolve()
252
- })
253
- })
254
+ await this.terminator.terminate()
254
255
  }
255
256
  }
@@ -4,6 +4,8 @@ import http from 'node:http'
4
4
  import { AddressInfo } from 'node:net'
5
5
  import * as plc from '@did-plc/lib'
6
6
  import express from 'express'
7
+ // eslint-disable-next-line import/default
8
+ import httpTerminator from 'http-terminator'
7
9
  import { Keypair } from '@atproto/crypto'
8
10
  import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
9
11
  import { verifyJwt } from '@atproto/xrpc-server'
@@ -35,8 +37,8 @@ describe('proxy header', () => {
35
37
  }, 20_000) // @NOTE seeding can take a while
36
38
 
37
39
  afterAll(async () => {
38
- await proxyServer.close()
39
- await network.close()
40
+ await proxyServer?.close()
41
+ await network?.close()
40
42
  })
41
43
 
42
44
  it('parses proxy header', async () => {
@@ -171,12 +173,16 @@ type ProxyReq = {
171
173
  }
172
174
 
173
175
  class ProxyServer {
176
+ private terminator: httpTerminator.HttpTerminator
177
+
174
178
  constructor(
175
- public server: http.Server,
179
+ server: http.Server,
176
180
  public url: string,
177
181
  public did: string,
178
182
  public requests: ProxyReq[],
179
- ) {}
183
+ ) {
184
+ this.terminator = httpTerminator.createHttpTerminator({ server })
185
+ }
180
186
 
181
187
  static async create(
182
188
  plcClient: plc.Client,
@@ -226,9 +232,7 @@ class ProxyServer {
226
232
  return new ProxyServer(server, url, did, requests)
227
233
  }
228
234
 
229
- close(): Promise<void> {
230
- return new Promise<void>((resolve) => {
231
- this.server.close(() => resolve())
232
- })
235
+ async close(): Promise<void> {
236
+ await this.terminator.terminate()
233
237
  }
234
238
  }
@@ -3,6 +3,8 @@ import http from 'node:http'
3
3
  import { AddressInfo } from 'node:net'
4
4
  import * as plc from '@did-plc/lib'
5
5
  import express from 'express'
6
+ // eslint-disable-next-line import/default
7
+ import httpTerminator from 'http-terminator'
6
8
  import { Keypair } from '@atproto/crypto'
7
9
  import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
8
10
  import { ScopePermissions } from '@atproto/oauth-scopes'
@@ -30,7 +32,7 @@ describe('proxy oauth audience', () => {
30
32
  let sc: SeedClient
31
33
  let alice: string
32
34
  let upstream: ProxyServer
33
- let server: http.Server
35
+ let terminator: httpTerminator.HttpTerminator
34
36
  let serverUrl: string
35
37
 
36
38
  beforeAll(async () => {
@@ -88,15 +90,18 @@ describe('proxy oauth audience', () => {
88
90
  res.status(err.status ?? err.statusCode ?? 500).end()
89
91
  },
90
92
  )
91
- server = app.listen(0)
93
+ const server = app.listen(0)
92
94
  await once(server, 'listening')
95
+ terminator = httpTerminator.createHttpTerminator({ server })
93
96
  serverUrl = `http://localhost:${(server.address() as AddressInfo).port}`
94
97
  })
95
98
 
96
99
  afterAll(async () => {
97
- await new Promise<void>((resolve) => server.close(() => resolve()))
98
- await upstream.close()
99
- await network.close()
100
+ await Promise.all([
101
+ terminator?.terminate(),
102
+ upstream?.close(),
103
+ network?.close(),
104
+ ])
100
105
  })
101
106
 
102
107
  it('matches an OAuth rpc scope granted with combined did#serviceId aud', async () => {
@@ -127,11 +132,15 @@ describe('proxy oauth audience', () => {
127
132
  })
128
133
 
129
134
  class ProxyServer {
135
+ private terminator: httpTerminator.HttpTerminator
136
+
130
137
  constructor(
131
- public server: http.Server,
138
+ server: http.Server,
132
139
  public url: string,
133
140
  public did: string,
134
- ) {}
141
+ ) {
142
+ this.terminator = httpTerminator.createHttpTerminator({ server })
143
+ }
135
144
 
136
145
  static async create(
137
146
  plcClient: plc.Client,
@@ -168,8 +177,6 @@ class ProxyServer {
168
177
  }
169
178
 
170
179
  close(): Promise<void> {
171
- return new Promise<void>((resolve) => {
172
- this.server.close(() => resolve())
173
- })
180
+ return this.terminator.terminate()
174
181
  }
175
182
  }
@@ -27,15 +27,14 @@ describe('proxy read after write', () => {
27
27
  agent = network.pds.getAgent()
28
28
  sc = network.getSeedClient()
29
29
  await basicSeed(sc, { addModLabels: network.bsky })
30
- await network.processAll()
31
30
  alice = sc.dids.alice
32
31
  carol = sc.dids.carol
33
- await network.bsky.sub.destroy()
32
+ await network.processAll()
33
+ await network.bsky.sub.stop()
34
34
  })
35
35
 
36
- afterAll(async () => {
37
- await network.close()
38
- })
36
+ beforeEach(async () => network.processAll())
37
+ afterAll(async () => network?.close())
39
38
 
40
39
  it('handles read after write on profiles', async () => {
41
40
  await sc.updateProfile(alice, { displayName: 'blah' })
@@ -45,7 +45,7 @@ describe('proxies view requests', () => {
45
45
  })
46
46
 
47
47
  afterAll(async () => {
48
- await network.close()
48
+ await network?.close()
49
49
  })
50
50
 
51
51
  it('actor.getProfile', async () => {
@@ -31,7 +31,7 @@ describe('races', () => {
31
31
  })
32
32
 
33
33
  afterAll(async () => {
34
- await network.close()
34
+ await network?.close()
35
35
  })
36
36
 
37
37
  const processCommitWithWait = async (
@@ -27,7 +27,7 @@ describe('rate limits', () => {
27
27
  })
28
28
 
29
29
  afterAll(async () => {
30
- await network.close()
30
+ await network?.close()
31
31
  })
32
32
 
33
33
  it('rate limits by ip', async () => {
@@ -31,7 +31,7 @@ describe('recovery', () => {
31
31
  })
32
32
 
33
33
  afterAll(async () => {
34
- await network.close()
34
+ await network?.close()
35
35
  })
36
36
 
37
37
  const getStats = (did: string) => {
@@ -2,10 +2,10 @@ import { EXAMPLE_LABELER, SeedClient, TestBsky } from '@atproto/dev-env'
2
2
  import { app, com } from '../../src/lexicons/index.js'
3
3
  import usersSeed from './users.js'
4
4
 
5
- export default async (
5
+ export default async function basicSeed(
6
6
  sc: SeedClient,
7
7
  opts?: { inviteCode?: string; addModLabels?: TestBsky },
8
- ) => {
8
+ ) {
9
9
  await usersSeed(sc, opts)
10
10
 
11
11
  const alice = sc.dids.alice
@@ -1,6 +1,9 @@
1
1
  import { SeedClient } from '@atproto/dev-env'
2
2
 
3
- export default async (sc: SeedClient, opts?: { inviteCode?: string }) => {
3
+ export default async function usersSeed(
4
+ sc: SeedClient,
5
+ opts?: { inviteCode?: string },
6
+ ) {
4
7
  await sc.createAccount('alice', {
5
8
  ...users.alice,
6
9
  inviteCode: opts?.inviteCode,
@@ -45,7 +45,7 @@ describe('sequencer', () => {
45
45
  })
46
46
 
47
47
  afterAll(async () => {
48
- await network.close()
48
+ await network?.close()
49
49
  })
50
50
 
51
51
  const randomPost = async (by: string) => sc.post(by, randomStr(8, 'base32'))
@@ -28,7 +28,7 @@ describe('server', () => {
28
28
  })
29
29
 
30
30
  afterAll(async () => {
31
- await network.close()
31
+ await network?.close()
32
32
  })
33
33
 
34
34
  it('preserves 404s.', async () => {
@@ -43,17 +43,14 @@ describe('server', () => {
43
43
  })
44
44
  .use(errorHandler)
45
45
 
46
- const { origin, stop } = await startServer(app)
47
- try {
48
- const res = await fetch(new URL(`/oops`, origin))
49
- expect(res.status).toEqual(500)
50
- await expect(res.json()).resolves.toEqual({
51
- error: 'InternalServerError',
52
- message: 'Internal Server Error',
53
- })
54
- } finally {
55
- await stop()
56
- }
46
+ await using server = await startServer(app)
47
+
48
+ const res = await fetch(`http://localhost:${server.port}/oops`)
49
+ expect(res.status).toEqual(500)
50
+ await expect(res.json()).resolves.toEqual({
51
+ error: 'InternalServerError',
52
+ message: 'Internal Server Error',
53
+ })
57
54
  })
58
55
 
59
56
  it('limits size of json input.', async () => {
@@ -40,7 +40,7 @@ describe('invertible ops', () => {
40
40
  })
41
41
 
42
42
  afterAll(async () => {
43
- await network.close()
43
+ await network?.close()
44
44
  })
45
45
 
46
46
  it('works', async () => {
@@ -17,7 +17,7 @@ describe('sync listing', () => {
17
17
  })
18
18
 
19
19
  afterAll(async () => {
20
- await network.close()
20
+ await network?.close()
21
21
  })
22
22
 
23
23
  it('lists hosted repos in order of creation', async () => {
@@ -51,7 +51,7 @@ describe('repo subscribe repos', () => {
51
51
  })
52
52
 
53
53
  afterAll(async () => {
54
- await network.close()
54
+ await network?.close()
55
55
  })
56
56
 
57
57
  const getRepo = async (did: string): Promise<repo.VerifiedRepo> => {
@@ -39,7 +39,7 @@ describe('repo sync', () => {
39
39
  })
40
40
 
41
41
  afterAll(async () => {
42
- await network.close()
42
+ await network?.close()
43
43
  })
44
44
 
45
45
  it('creates and syncs some records', async () => {
@@ -25,7 +25,7 @@ describe('appeal account takedown', () => {
25
25
  })
26
26
 
27
27
  afterAll(async () => {
28
- await network.close()
28
+ await network?.close()
29
29
  })
30
30
 
31
31
  it('actor takedown allows appeal request.', async () => {