git ssb

0+

wanderer🌟 / js-primea-wasm-container



Commit 7450b5946986c1567218e744ea2148f8917555fe

update wasm container for typeids

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 8/13/2017, 3:54:35 PM
Parent: 4af0630e844fe5c816f308e0ce8210d97c227951

Files changed

tests/index.jschanged
tests/index.jsView
@@ -32,47 +32,51 @@
3232 tape('wasm container - main', async t => {
3333 t.plan(1)
3434 const hypervisor = new Hypervisor(node.dag)
3535 const main = fs.readFileSync(`${__dirname}/wasm/run.wasm`)
36- hypervisor.registerContainer('wasm', WasmContainer, {
36+ hypervisor.registerContainer(WasmContainer, {
3737 test: testInterface(t)
3838 })
39- const instance = await hypervisor.createInstance('wasm', new Message({
39+ const instance = await hypervisor.createInstance(WasmContainer.typeId, new Message({
4040 data: main
4141 }))
4242 instance.message(instance.createMessage())
4343 })
4444
4545 tape('wasm container - mem', async t => {
4646 t.plan(1)
47- const hypervisor = new Hypervisor(node.dag)
48- const readMem = fs.readFileSync(`${__dirname}/wasm/readMem.wasm`)
49- hypervisor.registerContainer('wasm', WasmContainer, {
50- env: ContainerTestInterface,
51- test: testInterface(t)
52- })
53- await hypervisor.createInstance('wasm', new Message({
54- data: readMem
55- }))
47+ try {
48+ const hypervisor = new Hypervisor(node.dag)
49+ const readMem = fs.readFileSync(`${__dirname}/wasm/readMem.wasm`)
50+ hypervisor.registerContainer(WasmContainer, {
51+ env: ContainerTestInterface,
52+ test: testInterface(t)
53+ })
54+ await hypervisor.createInstance(WasmContainer.typeId, new Message({
55+ data: readMem
56+ }))
57+ } catch (e) {
58+ console.log(e)
59+ }
5660 })
5761
5862 tape('wasm container - callbacks', async t => {
5963 t.plan(1)
6064 const hypervisor = new Hypervisor(node.dag)
6165 const callBackWasm = fs.readFileSync(`${__dirname}/wasm/callback.wasm`)
62- hypervisor.registerContainer('wasm', WasmContainer, {
66+ hypervisor.registerContainer(WasmContainer, {
6367 env: ContainerTestInterface,
6468 test: testInterface(t)
6569 })
66- hypervisor.createInstance('wasm', new Message({
70+ hypervisor.createInstance(WasmContainer.typeId, new Message({
6771 data: callBackWasm
6872 }))
6973 })
7074
7175 tape('wasm container - invalid', async t => {
7276 t.plan(1)
7377 const hypervisor = new Hypervisor(node.dag)
74- hypervisor.registerContainer('wasm', WasmContainer, {
78+ hypervisor.registerContainer(WasmContainer, {
7579 env: ContainerTestInterface,
7680 test: testInterface(t)
7781 })
7882
@@ -81,9 +85,9 @@
8185 })
8286
8387 const rp = message.responsePort = {destPort: {messages: []}}
8488
85- await hypervisor.createInstance('wasm', message)
89+ await hypervisor.createInstance(WasmContainer.typeId, message)
8690 t.equals(rp.destPort.messages[0].data.exception, true)
8791 })
8892
8993 tape('initailize', async t => {
@@ -114,16 +118,16 @@
114118 }
115119 }
116120
117121 const hypervisor = new Hypervisor(node.dag)
118- hypervisor.registerContainer('wasm', WasmContainer, {
122+ hypervisor.registerContainer(WasmContainer, {
119123 env: ContainerTestInterface,
120124 test: testInterface(t)
121125 })
122126
123127 const message = new Message({
124128 data: callBackWasm
125129 })
126130
127- hypervisor.createInstance('wasm', message)
131+ hypervisor.createInstance(WasmContainer.typeId, message)
128132 })
129133 })

Built with git-ssb-web