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.json | changed |
tests/index.js | changed |
package-lock.json | ||
---|---|---|
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.js | |||
---|---|---|---|
@@ -45,14 +45,12 @@ | |||
45 | 45 … | hypervisor.registerContainer(WasmContainer, { | |
46 | 46 … | test: testInterface(t) | |
47 | 47 … | }) | |
48 | 48 … | ||
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 | ||
53 | 51 … | })) | |
54 | - instance.message(instance.createMessage()) | ||
52 … | + hypervisor.send(cap, new Message()) | ||
55 | 53 … | }) | |
56 | 54 … | ||
57 | 55 … | tape('referances', async t => { | |
58 | 56 … | t.plan(1) | |
@@ -61,14 +59,11 @@ | |||
61 | 59 … | hypervisor.registerContainer(WasmContainer, { | |
62 | 60 … | env: ContainerTestInterface, | |
63 | 61 … | test: testInterface(t) | |
64 | 62 … | }) | |
65 | - const ports = hypervisor.createChannel() | ||
66 | - const port = hypervisor.creationService.getPort() | ||
67 | 63 … | ||
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 | ||
71 | 66 … | })) | |
72 | 67 … | }) | |
73 | 68 … | ||
74 | 69 … | tape('wasm container - mem', async t => { | |
@@ -79,28 +74,31 @@ | |||
79 | 74 … | env: ContainerTestInterface, | |
80 | 75 … | test: testInterface(t) | |
81 | 76 … | }) | |
82 | 77 … | ||
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 | ||
87 | 80 … | })) | |
88 | 81 … | }) | |
89 | 82 … | ||
90 | 83 … | tape('write mem', async t => { | |
91 | 84 … | const hypervisor = new Hypervisor(tree) | |
92 | 85 … | 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, { | ||
94 | 92 … | env: ContainerTestInterface, | |
95 | 93 … | test: testInterface(t) | |
96 | 94 … | }) | |
97 | 95 … | ||
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 | ||
101 | 98 … | })) | |
102 | - const mem = root.container.getMemory(0, 1) | ||
99 … | + const actor = await hypervisor.getActor(cap.destId) | ||
100 … | + const mem = actor.container.getMemory(0, 1) | ||
103 | 101 … | t.equals(mem[0], 9) | |
104 | 102 … | t.end() | |
105 | 103 … | }) | |
106 | 104 … | ||
@@ -112,11 +110,10 @@ | |||
112 | 110 … | env: ContainerTestInterface, | |
113 | 111 … | test: testInterface(t) | |
114 | 112 … | }) | |
115 | 113 … | ||
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 | ||
119 | 116 … | })) | |
120 | 117 … | }) | |
121 | 118 … | ||
122 | 119 … | tape('wasm container - invalid', async t => { | |
@@ -127,17 +124,17 @@ | |||
127 | 124 … | test: testInterface(t) | |
128 | 125 … | }) | |
129 | 126 … | ||
130 | 127 … | const message = new Message({ | |
131 | - data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), Buffer.from([0])]) | ||
128 … | + data: Buffer.from([0]) | ||
132 | 129 … | }) | |
133 | 130 … | ||
134 | - const rp = message.responsePort = {destPort: {messages: []}} | ||
131 … | + message.on('execution:error', (e) => { | ||
132 … | + console.log(e) | ||
133 … | + t.pass('should cature error') | ||
134 … | + }) | ||
135 | 135 … | ||
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) | ||
140 | 137 … | }) | |
141 | 138 … | ||
142 | 139 … | tape('initailize', async t => { | |
143 | 140 … | t.plan(2) | |
@@ -168,9 +165,8 @@ | |||
168 | 165 … | env: ContainerTestInterface, | |
169 | 166 … | test: testInterface(t) | |
170 | 167 … | }) | |
171 | 168 … | ||
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 | ||
175 | 171 … | })) | |
176 | 172 … | }) |
Built with git-ssb-web