git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: a925d24ca2819ab0d5702e2877d76981bcd7b285

Files: a925d24ca2819ab0d5702e2877d76981bcd7b285 / tests / interfaceRunner.js

1235 bytesRaw
1'use strict'
2const tape = require('tape')
3const fs = require('fs')
4const cp = require('child_process')
5
6const Environment = require('../environment.js')
7const Interface = require('../interface.js')
8const dir = __dirname + '/interface'
9// get the test names
10let tests = fs.readdirSync(dir).filter((file) => file.endsWith('.wast'))
11// tests = ['balance.wast']
12// run the tests
13for (let testName of tests) {
14 testName = testName.split('.')[0]
15 tape(testName, (t) => {
16 // Compile Command
17 cp.execSync(`${__dirname}/../../evm-wasm-transcompiler/deps/sexpr-wasm-prototype/out/sexpr-wasm ${dir}/${testName}.wast -o ${dir}/${testName}.wasm`)
18 const buffer = fs.readFileSync(`${dir}/${testName}.wasm`)
19 const envData = fs.readFileSync(`${dir}/${testName}.json`)
20
21 const environment = new Environment(envData)
22 const ethInterface = new Interface(environment)
23
24 try {
25 const mod = Wasm.instantiateModule(buffer, {'ethereum': ethInterface})
26 ethInterface.setModule(mod)
27 // ethInterface.address(0)
28 // console.log(ethInterface.environment);
29 mod.exports.test()
30 } catch (e) {
31 console.error('FAIL')
32 console.error(e)
33 } finally {
34 console.log('done')
35 }
36 t.end()
37 })
38}
39

Built with git-ssb-web