|
1 | 1 | // NOTE: this is a temporary solution to tell us if future changes to the monkey-patched methods |
2 | 2 | // could impact this package. Recognizing this is not an ideal solution, we plan to address this when |
3 | 3 | // we can drop the monkey-patching entirely. |
4 | | -const crypto = require('crypto') |
5 | 4 | const assert = require('assert') |
6 | | -const http = require('http') |
7 | | -const Socket = require('net').Socket |
| 5 | +const knownHashes = require('./known-upstream-hashes.json') |
| 6 | +const { getFunctionHash, httpServerResponsePrototype: res } = require('../scripts/upstream-common') |
8 | 7 |
|
9 | | -const req = new http.IncomingMessage(new Socket()) |
10 | | -const res = new http.ServerResponse(req) |
11 | | - |
12 | | -function getFunctionHash (fn) { |
13 | | - const src = fn.toString().replace(/\s+/g, '') // normalize whitespace |
14 | | - return crypto.createHash('sha256').update(src).digest('hex') |
15 | | -} |
16 | | - |
17 | | -const knownWriteHeadHash = '281e0d02084a69893b8c3b8692e3c7c4de2ce22a626217fcf597fa6ddf6955a9' |
18 | | -const knownSetHeaderHash = '2d4f95e92586d28bfd4d3137a8eaacb82b255967d8c26413015c6b56daf0afe7' |
19 | | -const knownAppendHeaderHash = '0deb9f70c3bba63993321cca9281fb4607e2567bed1436b8574c5b86698125a8' |
20 | | -const knownRemoveHeaderHash = '3ad5ccb0a858beb6268f281492bd8d42c9815f5316cc3c4f7f735e142fcd29d9' |
| 8 | +const { knownAppendHeaderHash, knownRemoveHeaderHash, knownSetHeaderHash, knownWriteHeadHash } = knownHashes |
21 | 9 |
|
22 | 10 | describe('function verification', function () { |
23 | 11 | it('should match the known function hash of writeHead', function () { |
|
0 commit comments