|
1 |
| -import app from '../app.js' |
| 1 | +import app, { providerConfig, timers } from '../app.js' |
2 | 2 | import request from 'supertest'
|
3 |
| -import { jest } from '@jest/globals' |
| 3 | +import { afterAll, describe, expect, it, jest } from '@jest/globals' |
| 4 | +import { deployments } from 'ethr-did-resolver' |
4 | 5 |
|
5 | 6 | jest.setTimeout(30000)
|
6 | 7 |
|
7 | 8 | describe('did:ethr driver', () => {
|
| 9 | + afterAll(() => { |
| 10 | + // poor man's benchmarking |
| 11 | + for (const rpcUrl of Object.keys(timers)) { |
| 12 | + const average = |
| 13 | + Object.values(timers[rpcUrl]).reduce((acc, val) => acc + val, 0) / |
| 14 | + Object.values(timers[rpcUrl]).length |
| 15 | + console.log(`Average time for ${rpcUrl}: ${average}ms`) |
| 16 | + } |
| 17 | + }) |
| 18 | + |
| 19 | + it.skip('configures all official deployments', () => { |
| 20 | + const configured = providerConfig.networks.map((network) => network.chainId) |
| 21 | + const known = deployments.map((deployment) => deployment.chainId) |
| 22 | + const knownButNotConfigured = known.filter((x) => !new Set(configured).has(x)) |
| 23 | + expect(knownButNotConfigured).toEqual([]) |
| 24 | + }) |
| 25 | + |
| 26 | + it.skip('configures only official deployments', () => { |
| 27 | + const configured = providerConfig.networks.map((network) => network.chainId) |
| 28 | + const known = deployments.map((deployment) => deployment.chainId) |
| 29 | + const configuredButUnknown = configured.filter((x) => !new Set(known).has(x)) |
| 30 | + expect(configuredButUnknown).toEqual([]) |
| 31 | + }) |
| 32 | + |
8 | 33 | it('responds with didResolutionResult', async () => {
|
9 | 34 | expect.assertions(4)
|
10 | 35 | const did = 'did:ethr:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
|
@@ -128,106 +153,19 @@ describe('did:ethr driver', () => {
|
128 | 153 | })
|
129 | 154 |
|
130 | 155 | describe('responds with didResolutionResult for', () => {
|
131 |
| - it('did:ethr:mainnet:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
132 |
| - expect.assertions(1) |
133 |
| - const did = 'did:ethr:mainnet:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
134 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
135 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
136 |
| - }) |
137 |
| - |
138 |
| - it('did:ethr:0x1:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
139 |
| - expect.assertions(1) |
140 |
| - const did = 'did:ethr:0x1:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
141 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
142 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
143 |
| - }) |
| 156 | + const names = providerConfig.networks.map((network) => network.name) |
| 157 | + const chainIds = providerConfig.networks.map((network) => `0x${BigInt(network.chainId).toString(16)}`) |
144 | 158 |
|
145 |
| - it('did:ethr:goerli:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
146 |
| - expect.assertions(1) |
147 |
| - const did = 'did:ethr:goerli:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
148 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
149 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
150 |
| - }) |
151 |
| - |
152 |
| - it('did:ethr:0x5:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
153 |
| - expect.assertions(1) |
154 |
| - const did = 'did:ethr:0x5:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
155 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
156 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
157 |
| - }) |
158 |
| - |
159 |
| - // it('did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
160 |
| - // expect.assertions(1) |
161 |
| - // const did = 'did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
162 |
| - // const response = await request(app).get(`/1.0/identifiers/${did}`) |
163 |
| - // expect(response.body.didDocument).toHaveProperty('verificationMethod') |
164 |
| - // }) |
165 |
| - |
166 |
| - // it('did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
167 |
| - // expect.assertions(1) |
168 |
| - // const did = 'did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
169 |
| - // const response = await request(app).get(`/1.0/identifiers/${did}`) |
170 |
| - // expect(response.body.didDocument).toHaveProperty('verificationMethod') |
171 |
| - // }) |
172 |
| - |
173 |
| - it('did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
174 |
| - expect.assertions(1) |
175 |
| - const did = 'did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
176 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
177 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
178 |
| - }) |
179 |
| - |
180 |
| - it('did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
181 |
| - expect.assertions(1) |
182 |
| - const did = 'did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
183 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
184 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
185 |
| - }) |
186 |
| - |
187 |
| - it.skip('did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
188 |
| - expect.assertions(1) |
189 |
| - const did = 'did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
190 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
191 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
192 |
| - }) |
193 |
| - |
194 |
| - it.skip('did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
195 |
| - expect.assertions(1) |
196 |
| - const did = 'did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
197 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
198 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
199 |
| - }) |
200 |
| - |
201 |
| - it('did:ethr:0x03c401:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
202 |
| - expect.assertions(1) |
203 |
| - const did = 'did:ethr:0x03c401:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
204 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
205 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
206 |
| - }) |
207 |
| - |
208 |
| - it('did:ethr:volta:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
209 |
| - expect.assertions(1) |
210 |
| - const did = 'did:ethr:volta:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
211 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
212 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
213 |
| - }) |
214 |
| - |
215 |
| - it('did:ethr:0x12047:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
216 |
| - expect.assertions(1) |
217 |
| - const did = 'did:ethr:0x12047:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
218 |
| - const response = await request(app).get(`/1.0/identifiers/${did}`) |
219 |
| - expect(response.body.didDocument).toHaveProperty('verificationMethod') |
220 |
| - }) |
221 |
| - it('did:ethr:ewc:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
| 159 | + it.each(names)('did:ethr:%s:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async (name) => { |
222 | 160 | expect.assertions(1)
|
223 |
| - const did = 'did:ethr:ewc:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
| 161 | + const did = `did:ethr:${name}:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736` |
224 | 162 | const response = await request(app).get(`/1.0/identifiers/${did}`)
|
225 | 163 | expect(response.body.didDocument).toHaveProperty('verificationMethod')
|
226 | 164 | })
|
227 | 165 |
|
228 |
| - it('did:ethr:0xf6:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => { |
| 166 | + it.each(chainIds)('did:ethr:%s:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async (chainId) => { |
229 | 167 | expect.assertions(1)
|
230 |
| - const did = 'did:ethr:0xf6:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736' |
| 168 | + const did = `did:ethr:${chainId}:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736` |
231 | 169 | const response = await request(app).get(`/1.0/identifiers/${did}`)
|
232 | 170 | expect(response.body.didDocument).toHaveProperty('verificationMethod')
|
233 | 171 | })
|
|
0 commit comments