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.js | changed |
tests/index.js | ||
---|---|---|
@@ -32,47 +32,51 @@ | ||
32 | 32 | tape('wasm container - main', async t => { |
33 | 33 | t.plan(1) |
34 | 34 | const hypervisor = new Hypervisor(node.dag) |
35 | 35 | const main = fs.readFileSync(`${__dirname}/wasm/run.wasm`) |
36 | - hypervisor.registerContainer('wasm', WasmContainer, { | |
36 | + hypervisor.registerContainer(WasmContainer, { | |
37 | 37 | test: testInterface(t) |
38 | 38 | }) |
39 | - const instance = await hypervisor.createInstance('wasm', new Message({ | |
39 | + const instance = await hypervisor.createInstance(WasmContainer.typeId, new Message({ | |
40 | 40 | data: main |
41 | 41 | })) |
42 | 42 | instance.message(instance.createMessage()) |
43 | 43 | }) |
44 | 44 | |
45 | 45 | tape('wasm container - mem', async t => { |
46 | 46 | 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 | + } | |
56 | 60 | }) |
57 | 61 | |
58 | 62 | tape('wasm container - callbacks', async t => { |
59 | 63 | t.plan(1) |
60 | 64 | const hypervisor = new Hypervisor(node.dag) |
61 | 65 | const callBackWasm = fs.readFileSync(`${__dirname}/wasm/callback.wasm`) |
62 | - hypervisor.registerContainer('wasm', WasmContainer, { | |
66 | + hypervisor.registerContainer(WasmContainer, { | |
63 | 67 | env: ContainerTestInterface, |
64 | 68 | test: testInterface(t) |
65 | 69 | }) |
66 | - hypervisor.createInstance('wasm', new Message({ | |
70 | + hypervisor.createInstance(WasmContainer.typeId, new Message({ | |
67 | 71 | data: callBackWasm |
68 | 72 | })) |
69 | 73 | }) |
70 | 74 | |
71 | 75 | tape('wasm container - invalid', async t => { |
72 | 76 | t.plan(1) |
73 | 77 | const hypervisor = new Hypervisor(node.dag) |
74 | - hypervisor.registerContainer('wasm', WasmContainer, { | |
78 | + hypervisor.registerContainer(WasmContainer, { | |
75 | 79 | env: ContainerTestInterface, |
76 | 80 | test: testInterface(t) |
77 | 81 | }) |
78 | 82 | |
@@ -81,9 +85,9 @@ | ||
81 | 85 | }) |
82 | 86 | |
83 | 87 | const rp = message.responsePort = {destPort: {messages: []}} |
84 | 88 | |
85 | - await hypervisor.createInstance('wasm', message) | |
89 | + await hypervisor.createInstance(WasmContainer.typeId, message) | |
86 | 90 | t.equals(rp.destPort.messages[0].data.exception, true) |
87 | 91 | }) |
88 | 92 | |
89 | 93 | tape('initailize', async t => { |
@@ -114,16 +118,16 @@ | ||
114 | 118 | } |
115 | 119 | } |
116 | 120 | |
117 | 121 | const hypervisor = new Hypervisor(node.dag) |
118 | - hypervisor.registerContainer('wasm', WasmContainer, { | |
122 | + hypervisor.registerContainer(WasmContainer, { | |
119 | 123 | env: ContainerTestInterface, |
120 | 124 | test: testInterface(t) |
121 | 125 | }) |
122 | 126 | |
123 | 127 | const message = new Message({ |
124 | 128 | data: callBackWasm |
125 | 129 | }) |
126 | 130 | |
127 | - hypervisor.createInstance('wasm', message) | |
131 | + hypervisor.createInstance(WasmContainer.typeId, message) | |
128 | 132 | }) |
129 | 133 | }) |
Built with git-ssb-web