git ssb

0+

wanderer🌟 / js-primea-wasm-container



Commit 6731ea092f0166164cf1bbc8653439f46a7f6bd6

updated for caps

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 11/26/2017, 2:04:07 AM
Parent: ffdb87d7c148dcf9e6d3907b09c0d046966f782d

Files changed

package-lock.jsonchanged
tests/index.jschanged
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 182822 bytes
New file size: 182884 bytes
tests/index.jsView
@@ -45,14 +45,12 @@
4545 hypervisor.registerContainer(WasmContainer, {
4646 test: testInterface(t)
4747 })
4848
49- const port = hypervisor.creationService.getPort()
50-
51- let instance = await hypervisor.send(port, new Message({
52- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), main])
49 + let cap = await hypervisor.createActor(WasmContainer.typeId, new Message({
50 + data: main
5351 }))
54- instance.message(instance.createMessage())
52 + hypervisor.send(cap, new Message())
5553 })
5654
5755 tape('referances', async t => {
5856 t.plan(1)
@@ -61,14 +59,11 @@
6159 hypervisor.registerContainer(WasmContainer, {
6260 env: ContainerTestInterface,
6361 test: testInterface(t)
6462 })
65- const ports = hypervisor.createChannel()
66- const port = hypervisor.creationService.getPort()
6763
68- hypervisor.send(port, new Message({
69- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), main]),
70- ports: ports
64 + hypervisor.createActor(WasmContainer.typeId, new Message({
65 + data: main
7166 }))
7267 })
7368
7469 tape('wasm container - mem', async t => {
@@ -79,28 +74,31 @@
7974 env: ContainerTestInterface,
8075 test: testInterface(t)
8176 })
8277
83- const port = hypervisor.creationService.getPort()
84-
85- hypervisor.send(port, new Message({
86- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), readMem])
78 + hypervisor.createActor(WasmContainer.typeId, new Message({
79 + data: readMem
8780 }))
8881 })
8982
9083 tape('write mem', async t => {
9184 const hypervisor = new Hypervisor(tree)
9285 const readMem = fs.readFileSync(`${__dirname}/wasm/writeMem.wasm`)
93- hypervisor.registerContainer(WasmContainer, {
86 +
87 + class WasmContainerNoIdle extends WasmContainer {
88 + onIdle () {}
89 + }
90 +
91 + hypervisor.registerContainer(WasmContainerNoIdle, {
9492 env: ContainerTestInterface,
9593 test: testInterface(t)
9694 })
9795
98- const port = hypervisor.creationService.getPort()
99- const root = await hypervisor.send(port, new Message({
100- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), readMem])
96 + const cap = await hypervisor.createActor(WasmContainerNoIdle.typeId, new Message({
97 + data: readMem
10198 }))
102- const mem = root.container.getMemory(0, 1)
99 + const actor = await hypervisor.getActor(cap.destId)
100 + const mem = actor.container.getMemory(0, 1)
103101 t.equals(mem[0], 9)
104102 t.end()
105103 })
106104
@@ -112,11 +110,10 @@
112110 env: ContainerTestInterface,
113111 test: testInterface(t)
114112 })
115113
116- const port = hypervisor.creationService.getPort()
117- await hypervisor.send(port, new Message({
118- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), callBackWasm])
114 + await hypervisor.createActor(WasmContainer.typeId, new Message({
115 + data: callBackWasm
119116 }))
120117 })
121118
122119 tape('wasm container - invalid', async t => {
@@ -127,17 +124,17 @@
127124 test: testInterface(t)
128125 })
129126
130127 const message = new Message({
131- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), Buffer.from([0])])
128 + data: Buffer.from([0])
132129 })
133130
134- const rp = message.responsePort = {destPort: {messages: []}}
131 + message.on('execution:error', (e) => {
132 + console.log(e)
133 + t.pass('should cature error')
134 + })
135135
136- const port = hypervisor.creationService.getPort()
137- await hypervisor.send(port, message)
138-
139- t.equals(rp.destPort.messages[0].data.exception, true)
136 + await hypervisor.createActor(WasmContainer.typeId, message)
140137 })
141138
142139 tape('initailize', async t => {
143140 t.plan(2)
@@ -168,9 +165,8 @@
168165 env: ContainerTestInterface,
169166 test: testInterface(t)
170167 })
171168
172- const port = hypervisor.creationService.getPort()
173- hypervisor.send(port, new Message({
174- data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), callBackWasm])
169 + await hypervisor.createActor(WasmContainer.typeId, new Message({
170 + data: callBackWasm
175171 }))
176172 })

Built with git-ssb-web