-
Notifications
You must be signed in to change notification settings - Fork 316
/
Copy pathadapter.test.ts
54 lines (46 loc) · 1.31 KB
/
adapter.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import type { AddressInfo } from 'net'
import nock from 'nock'
import process from 'process'
import request from 'supertest'
import type { SuperTest, Test } from 'supertest'
import { server as startServer } from '../../src'
import { dnsProofTests } from './dnsProof'
import { setEnvVariables } from '@chainlink/ea-test-helpers'
import { FastifyInstance } from '@chainlink/ea-bootstrap'
let oldEnv: NodeJS.ProcessEnv
export interface SuiteContext {
fastify: FastifyInstance | null
req: SuperTest<Test> | null
}
beforeAll(() => {
oldEnv = JSON.parse(JSON.stringify(process.env))
process.env.DNS_PROVIDER = 'google'
process.env.API_VERBOSE = 'true'
process.env.CACHE_ENABLED = 'false'
if (process.env.RECORD) {
nock.recorder.rec()
}
})
afterAll(() => {
setEnvVariables(oldEnv)
if (process.env.RECORD) {
nock.recorder.play()
}
nock.restore()
nock.cleanAll()
nock.enableNetConnect()
})
describe('execute', () => {
const context: SuiteContext = {
fastify: null,
req: null,
}
beforeEach(async () => {
context.fastify = await startServer()
context.req = request(`localhost:${(context.fastify.server.address() as AddressInfo).port}`)
})
afterEach((done) => {
;(context.fastify as FastifyInstance).close(done)
})
describe('dnsProof endpoint', () => dnsProofTests(context))
})