-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrowser.js
28 lines (24 loc) · 914 Bytes
/
browser.js
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
var context = require.context('./fixtures', true, /\.json$/)
const test = require('./test')
async function run () {
const fixtures = []
// load .json files to `fixture.data` and corresponding .hex file binary data as `fixture.block`
await Promise.all(context.keys().map(async (f) => {
const hash = f.replace(/^.\/([^.]+)\.json/, '$1')
// console.log((await import(`!!raw-loader!./fixtures/${hash}.hex`)).substr(0, 100)
const data = (await import(`./fixtures/${hash}.json`)).default
const blockHex = (await import(`!!raw-loader!./fixtures/${hash}.hex`)).default
const block = Buffer.from(blockHex.replace(/\n/g, ''), 'hex')
fixtures.push({
hash,
block,
data
})
}))
console.log('testing', fixtures.length, 'fixtures')
for (const { hash, block, data } of fixtures) {
console.log('testing', hash)
test(hash, block, data)
}
}
module.exports = run