Commit 80537e8058ad78a6a1619e7b40eeff757a9a8751
Merge pull request #142 from primea/container-types
added container-typeswanderer authored on 8/2/2017, 7:45:25 PM
GitHub committed on 8/2/2017, 7:45:25 PM
Parent: 36f1183644629e1bce9bd63c53e167c37596441c
Parent: 82c187594235aeef4c9dffa91cd872681a12c968
Files changed
index.js | changed |
tests/index.js | changed |
index.js | ||
---|---|---|
@@ -168,15 +168,14 @@ | ||
168 | 168 … | } |
169 | 169 … | |
170 | 170 … | /** |
171 | 171 … | * regirsters a container with the hypervisor |
172 | - * @param {String} type - the name of the type | |
173 | 172 … | * @param {Class} Constructor - a Class for instantiating the container |
174 | 173 … | * @param {*} args - any args that the contructor takes |
174 … | + * @param {interger} typeId - the container's type identification ID | |
175 | 175 … | */ |
176 | - registerContainer (type, Constructor, args) { | |
177 | - Constructor.type = type | |
178 | - this._containerTypes[type] = { | |
176 … | + registerContainer (Constructor, args, typeId = Constructor.typeId) { | |
177 … | + this._containerTypes[typeId] = { | |
179 | 178 … | Constructor: Constructor, |
180 | 179 … | args: args |
181 | 180 … | } |
182 | 181 … | } |
tests/index.js | |||
---|---|---|---|
@@ -16,16 +16,19 @@ | |||
16 | 16 … | if (port) { | |
17 | 17 … | this.kernel.ports.bind('root', port) | |
18 | 18 … | } | |
19 | 19 … | } | |
20 … | + static get typeId () { | ||
21 … | + return 9 | ||
22 … | + } | ||
20 | 23 … | } | |
21 | 24 … | ||
22 | 25 … | node.on('ready', () => { | |
23 | 26 … | tape('basic', async t => { | |
24 | 27 … | t.plan(3) | |
25 | 28 … | let message | |
26 | 29 … | const expectedState = { | |
27 | - '/': 'zdpuB1wc9Pb6jUzfNt4nAxAEUxB7kNhg4vbq7YLcEyBUb6iAB' | ||
30 … | + '/': 'zdpuAmN9VSrvNbArWkAEhEYaKhhCT3rk8xMhUam6eUfQmr6aZ' | ||
28 | 31 … | } | |
29 | 32 … | ||
30 | 33 … | class testVMContainer extends BaseContainer { | |
31 | 34 … | onMessage (m) { | |
@@ -33,19 +36,19 @@ | |||
33 | 36 … | } | |
34 | 37 … | } | |
35 | 38 … | ||
36 | 39 … | const hypervisor = new Hypervisor(node.dag) | |
37 | - hypervisor.registerContainer('test', testVMContainer) | ||
40 … | + hypervisor.registerContainer(testVMContainer) | ||
38 | 41 … | ||
39 | - const rootContainer = await hypervisor.createInstance('test') | ||
42 … | + const rootContainer = await hypervisor.createInstance(testVMContainer.typeId) | ||
40 | 43 … | ||
41 | 44 … | const [portRef1, portRef2] = rootContainer.ports.createChannel() | |
42 | 45 … | const initMessage = rootContainer.createMessage({ | |
43 | 46 … | data: Buffer.from('test code'), | |
44 | 47 … | ports: [portRef2] | |
45 | 48 … | }) | |
46 | 49 … | ||
47 | - rootContainer.createInstance('test', initMessage) | ||
50 … | + rootContainer.createInstance(testVMContainer.typeId, initMessage) | ||
48 | 51 … | ||
49 | 52 … | rootContainer.ports.bind('first', portRef1) | |
50 | 53 … | message = rootContainer.createMessage() | |
51 | 54 … | rootContainer.send(portRef1, message) | |
@@ -57,23 +60,23 @@ | |||
57 | 60 … | ||
58 | 61 … | tape('basic - do not store containers with no ports bound', async t => { | |
59 | 62 … | t.plan(1) | |
60 | 63 … | const expectedState = { | |
61 | - '/': 'zdpuAozDi6tKPbqmHJxo7aNES2xVt1MkaCLyxcioEKzz3M2WH' | ||
64 … | + '/': 'zdpuAxGvPHM4DRbq7GeyGjwuPA8NT7DZLszcDDX9R5iwHWnTo' | ||
62 | 65 … | } | |
63 | 66 … | ||
64 | 67 … | class testVMContainer extends BaseContainer { | |
65 | 68 … | onCreation () {} | |
66 | 69 … | } | |
67 | 70 … | ||
68 | 71 … | const hypervisor = new Hypervisor(node.dag) | |
69 | - hypervisor.registerContainer('test', testVMContainer) | ||
72 … | + hypervisor.registerContainer(testVMContainer) | ||
70 | 73 … | ||
71 | - const root = await hypervisor.createInstance('test') | ||
74 … | + const root = await hypervisor.createInstance(testVMContainer.typeId) | ||
72 | 75 … | const [portRef1, portRef2] = root.ports.createChannel() | |
73 | 76 … | ||
74 | 77 … | root.ports.bind('one', portRef1) | |
75 | - root.createInstance('test', root.createMessage({ | ||
78 … | + root.createInstance(testVMContainer.typeId, root.createMessage({ | ||
76 | 79 … | ports: [portRef2] | |
77 | 80 … | })) | |
78 | 81 … | ||
79 | 82 … | const stateRoot = await hypervisor.createStateRoot(Infinity) | |
@@ -83,21 +86,24 @@ | |||
83 | 86 … | tape('one child contract with saturated ports', async t => { | |
84 | 87 … | t.plan(2) | |
85 | 88 … | let message | |
86 | 89 … | const expectedState = { | |
87 | - '/': 'zdpuAtVcH6MUnvt2RXnLsDXyLB3CBSQ7aydfh2ogSKGCejJCQ' | ||
90 … | + '/': 'zdpuAvWT2E1Hg6cvFNLTDbmjGRLSDbMnRtrA6s17oSdBX5EWs' | ||
88 | 91 … | } | |
89 | 92 … | ||
90 | 93 … | class testVMContainer2 extends BaseContainer { | |
91 | 94 … | onMessage (m) { | |
92 | 95 … | t.true(m === message, 'should recive a message') | |
93 | 96 … | } | |
97 … | + static get typeId () { | ||
98 … | + return 99 | ||
99 … | + } | ||
94 | 100 … | } | |
95 | 101 … | ||
96 | 102 … | class testVMContainer extends BaseContainer { | |
97 | 103 … | onMessage (m) { | |
98 | 104 … | const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
99 | - this.kernel.createInstance('test2', this.kernel.createMessage({ | ||
105 … | + this.kernel.createInstance(testVMContainer2.typeId, this.kernel.createMessage({ | ||
100 | 106 … | ports: [portRef2] | |
101 | 107 … | })) | |
102 | 108 … | this.kernel.ports.bind('child', portRef1) | |
103 | 109 … | this.kernel.incrementTicks(2) | |
@@ -105,14 +111,14 @@ | |||
105 | 111 … | } | |
106 | 112 … | } | |
107 | 113 … | ||
108 | 114 … | const hypervisor = new Hypervisor(node.dag) | |
109 | - hypervisor.registerContainer('test', testVMContainer) | ||
110 | - hypervisor.registerContainer('test2', testVMContainer2) | ||
115 … | + hypervisor.registerContainer(testVMContainer) | ||
116 … | + hypervisor.registerContainer(testVMContainer2) | ||
111 | 117 … | ||
112 | - const root = await hypervisor.createInstance('test') | ||
118 … | + const root = await hypervisor.createInstance(testVMContainer.typeId) | ||
113 | 119 … | const [portRef1, portRef2] = root.ports.createChannel() | |
114 | - root.createInstance('test', root.createMessage({ | ||
120 … | + root.createInstance(testVMContainer.typeId, root.createMessage({ | ||
115 | 121 … | ports: [portRef2] | |
116 | 122 … | })) | |
117 | 123 … | ||
118 | 124 … | root.ports.bind('first', portRef1) | |
@@ -128,9 +134,9 @@ | |||
128 | 134 … | tape('one child contract', async t => { | |
129 | 135 … | t.plan(4) | |
130 | 136 … | let message | |
131 | 137 … | const expectedState = { | |
132 | - '/': 'zdpuAtVcH6MUnvt2RXnLsDXyLB3CBSQ7aydfh2ogSKGCejJCQ' | ||
138 … | + '/': 'zdpuAvWT2E1Hg6cvFNLTDbmjGRLSDbMnRtrA6s17oSdBX5EWs' | ||
133 | 139 … | } | |
134 | 140 … | let hasResolved = false | |
135 | 141 … | ||
136 | 142 … | class testVMContainer2 extends BaseContainer { | |
@@ -143,14 +149,18 @@ | |||
143 | 149 … | resolve() | |
144 | 150 … | }, 200) | |
145 | 151 … | }) | |
146 | 152 … | } | |
153 … | + | ||
154 … | + static get typeId () { | ||
155 … | + return 99 | ||
156 … | + } | ||
147 | 157 … | } | |
148 | 158 … | ||
149 | 159 … | class testVMContainer extends BaseContainer { | |
150 | 160 … | onMessage (m) { | |
151 | 161 … | const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
152 | - this.kernel.createInstance('test2', this.kernel.createMessage({ | ||
162 … | + this.kernel.createInstance(testVMContainer2.typeId, this.kernel.createMessage({ | ||
153 | 163 … | ports: [portRef2] | |
154 | 164 … | })) | |
155 | 165 … | this.kernel.ports.bind('child', portRef1) | |
156 | 166 … | this.kernel.send(portRef1, m) | |
@@ -158,15 +168,15 @@ | |||
158 | 168 … | } | |
159 | 169 … | } | |
160 | 170 … | ||
161 | 171 … | const hypervisor = new Hypervisor(node.dag) | |
162 | - hypervisor.registerContainer('test', testVMContainer) | ||
163 | - hypervisor.registerContainer('test2', testVMContainer2) | ||
172 … | + hypervisor.registerContainer(testVMContainer) | ||
173 … | + hypervisor.registerContainer(testVMContainer2) | ||
164 | 174 … | ||
165 | - let root = await hypervisor.createInstance('test') | ||
175 … | + let root = await hypervisor.createInstance(testVMContainer.typeId) | ||
166 | 176 … | const rootId = root.id | |
167 | 177 … | const [portRef1, portRef2] = root.ports.createChannel() | |
168 | - root.createInstance('test', root.createMessage({ | ||
178 … | + root.createInstance(testVMContainer.typeId, root.createMessage({ | ||
169 | 179 … | ports: [portRef2] | |
170 | 180 … | })) | |
171 | 181 … | ||
172 | 182 … | root.ports.bind('first', portRef1) | |
@@ -185,9 +195,9 @@ | |||
185 | 195 … | this.kernel.incrementTicks(1) | |
186 | 196 … | } | |
187 | 197 … | } | |
188 | 198 … | ||
189 | - hypervisor.registerContainer('test', testVMContainer3) | ||
199 … | + hypervisor.registerContainer(testVMContainer3) | ||
190 | 200 … | root = await hypervisor.getInstance(rootId) | |
191 | 201 … | const port = root.ports.get('first') | |
192 | 202 … | root.send(port, message) | |
193 | 203 … | }) | |
@@ -213,25 +223,25 @@ | |||
213 | 223 … | const message3 = this.kernel.createMessage({ | |
214 | 224 … | ports: [portRef6] | |
215 | 225 … | }) | |
216 | 226 … | ||
217 | - this.kernel.createInstance('root', message1) | ||
218 | - this.kernel.createInstance('root', message2) | ||
219 | - this.kernel.createInstance('root', message3) | ||
227 … | + this.kernel.createInstance(Root.typeId, message1) | ||
228 … | + this.kernel.createInstance(Root.typeId, message2) | ||
229 … | + this.kernel.createInstance(Root.typeId, message3) | ||
220 | 230 … | ||
221 | 231 … | throw new Error('it is a trap!!!') | |
222 | 232 … | } | |
223 | 233 … | } | |
224 | 234 … | ||
225 | 235 … | const hypervisor = new Hypervisor(node.dag) | |
226 | 236 … | ||
227 | - hypervisor.registerContainer('root', Root) | ||
228 | - const root = await hypervisor.createInstance('root') | ||
237 … | + hypervisor.registerContainer(Root) | ||
238 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
229 | 239 … | await root.message(root.createMessage()) | |
230 | 240 … | const stateRoot = await hypervisor.createStateRoot() | |
231 | 241 … | ||
232 | 242 … | t.deepEquals(stateRoot, { | |
233 | - '/': 'zdpuAwrMmQXqFusve7zcRYxVUuji4NVzZR5GyjwyStsjteCoW' | ||
243 … | + '/': 'zdpuAwxK8kAM3SkxSyALurpFHTobp6sFJef9gZJ8ZDQRww1LN' | ||
234 | 244 … | }, 'should revert the state') | |
235 | 245 … | }) | |
236 | 246 … | ||
237 | 247 … | tape('message should arrive in the correct oder if sent in order', async t => { | |
@@ -255,10 +265,10 @@ | |||
255 | 265 … | const message2 = this.kernel.createMessage({ | |
256 | 266 … | ports: [portRef4] | |
257 | 267 … | }) | |
258 | 268 … | ||
259 | - this.kernel.createInstance('first', message1) | ||
260 | - this.kernel.createInstance('second', message2) | ||
269 … | + this.kernel.createInstance(First.typeId, message1) | ||
270 … | + this.kernel.createInstance(Second.typeId, message2) | ||
261 | 271 … | ||
262 | 272 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
263 | 273 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
264 | 274 … | } else if (runs === 1) { | |
@@ -276,8 +286,12 @@ | |||
276 | 286 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
277 | 287 … | data: 'first' | |
278 | 288 … | })) | |
279 | 289 … | } | |
290 … | + | ||
291 … | + static get typeId () { | ||
292 … | + return 99 | ||
293 … | + } | ||
280 | 294 … | } | |
281 | 295 … | ||
282 | 296 … | class Second extends BaseContainer { | |
283 | 297 … | onMessage (m) { | |
@@ -285,20 +299,24 @@ | |||
285 | 299 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
286 | 300 … | data: 'second' | |
287 | 301 … | })) | |
288 | 302 … | } | |
303 … | + | ||
304 … | + static get typeId () { | ||
305 … | + return 299 | ||
306 … | + } | ||
289 | 307 … | } | |
290 | 308 … | ||
291 | 309 … | const hypervisor = new Hypervisor(node.dag) | |
292 | 310 … | ||
293 | - hypervisor.registerContainer('root', Root) | ||
294 | - hypervisor.registerContainer('first', First) | ||
295 | - hypervisor.registerContainer('second', Second) | ||
311 … | + hypervisor.registerContainer(Root) | ||
312 … | + hypervisor.registerContainer(First) | ||
313 … | + hypervisor.registerContainer(Second) | ||
296 | 314 … | ||
297 | - const root = await hypervisor.createInstance('root') | ||
315 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
298 | 316 … | ||
299 | 317 … | const [portRef1, portRef2] = root.ports.createChannel() | |
300 | - root.createInstance('root', root.createMessage({ | ||
318 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
301 | 319 … | ports: [portRef2] | |
302 | 320 … | })) | |
303 | 321 … | ||
304 | 322 … | root.ports.bind('first', portRef1) | |
@@ -327,10 +345,10 @@ | |||
327 | 345 … | const message2 = this.kernel.createMessage({ | |
328 | 346 … | ports: [portRef4] | |
329 | 347 … | }) | |
330 | 348 … | ||
331 | - this.kernel.createInstance('first', message1) | ||
332 | - this.kernel.createInstance('second', message2) | ||
349 … | + this.kernel.createInstance(First.typeId, message1) | ||
350 … | + this.kernel.createInstance(Second.typeId, message2) | ||
333 | 351 … | ||
334 | 352 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
335 | 353 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
336 | 354 … | } else if (runs === 1) { | |
@@ -339,8 +357,12 @@ | |||
339 | 357 … | } else if (runs === 2) { | |
340 | 358 … | t.equals(m.data, 'first', 'should recive the first message') | |
341 | 359 … | } | |
342 | 360 … | } | |
361 … | + | ||
362 … | + static get typeId () { | ||
363 … | + return 99 | ||
364 … | + } | ||
343 | 365 … | } | |
344 | 366 … | ||
345 | 367 … | class First extends BaseContainer { | |
346 | 368 … | onMessage (m) { | |
@@ -348,8 +370,12 @@ | |||
348 | 370 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
349 | 371 … | data: 'first' | |
350 | 372 … | })) | |
351 | 373 … | } | |
374 … | + | ||
375 … | + static get typeId () { | ||
376 … | + return 299 | ||
377 … | + } | ||
352 | 378 … | } | |
353 | 379 … | ||
354 | 380 … | class Second extends BaseContainer { | |
355 | 381 … | onMessage (m) { | |
@@ -361,16 +387,16 @@ | |||
361 | 387 … | } | |
362 | 388 … | ||
363 | 389 … | const hypervisor = new Hypervisor(node.dag) | |
364 | 390 … | ||
365 | - hypervisor.registerContainer('root', Root) | ||
366 | - hypervisor.registerContainer('first', First) | ||
367 | - hypervisor.registerContainer('second', Second) | ||
391 … | + hypervisor.registerContainer(Root) | ||
392 … | + hypervisor.registerContainer(First) | ||
393 … | + hypervisor.registerContainer(Second) | ||
368 | 394 … | ||
369 | - const root = await hypervisor.createInstance('root') | ||
395 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
370 | 396 … | ||
371 | 397 … | const [portRef1, portRef2] = root.ports.createChannel() | |
372 | - root.createInstance('root', root.createMessage({ | ||
398 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
373 | 399 … | ports: [portRef2] | |
374 | 400 … | })) | |
375 | 401 … | ||
376 | 402 … | root.ports.bind('first', portRef1) | |
@@ -398,10 +424,10 @@ | |||
398 | 424 … | const message2 = this.kernel.createMessage({ | |
399 | 425 … | ports: [portRef4] | |
400 | 426 … | }) | |
401 | 427 … | ||
402 | - this.kernel.createInstance('first', message1) | ||
403 | - this.kernel.createInstance('second', message2) | ||
428 … | + this.kernel.createInstance(First.typeId, message1) | ||
429 … | + this.kernel.createInstance(Second.typeId, message2) | ||
404 | 430 … | ||
405 | 431 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
406 | 432 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
407 | 433 … | ||
@@ -412,8 +438,11 @@ | |||
412 | 438 … | } else if (runs === 2) { | |
413 | 439 … | t.equals(m.data, 'second', 'should recived the second message') | |
414 | 440 … | } | |
415 | 441 … | } | |
442 … | + static get typeId () { | ||
443 … | + return 299 | ||
444 … | + } | ||
416 | 445 … | } | |
417 | 446 … | ||
418 | 447 … | class First extends BaseContainer { | |
419 | 448 … | onMessage (m) { | |
@@ -421,8 +450,11 @@ | |||
421 | 450 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
422 | 451 … | data: 'first' | |
423 | 452 … | })) | |
424 | 453 … | } | |
454 … | + static get typeId () { | ||
455 … | + return 2 | ||
456 … | + } | ||
425 | 457 … | } | |
426 | 458 … | ||
427 | 459 … | class Second extends BaseContainer { | |
428 | 460 … | onMessage (m) { | |
@@ -434,15 +466,15 @@ | |||
434 | 466 … | } | |
435 | 467 … | ||
436 | 468 … | const hypervisor = new Hypervisor(node.dag) | |
437 | 469 … | ||
438 | - hypervisor.registerContainer('root', Root) | ||
439 | - hypervisor.registerContainer('first', First) | ||
440 | - hypervisor.registerContainer('second', Second) | ||
470 … | + hypervisor.registerContainer(Root) | ||
471 … | + hypervisor.registerContainer(First) | ||
472 … | + hypervisor.registerContainer(Second) | ||
441 | 473 … | ||
442 | - const root = await hypervisor.createInstance('root') | ||
474 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
443 | 475 … | const [portRef1, portRef2] = root.ports.createChannel() | |
444 | - root.createInstance('root', root.createMessage({ | ||
476 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
445 | 477 … | ports: [portRef2] | |
446 | 478 … | })) | |
447 | 479 … | ||
448 | 480 … | root.ports.bind('first', portRef1) | |
@@ -470,10 +502,10 @@ | |||
470 | 502 … | const message2 = this.kernel.createMessage({ | |
471 | 503 … | ports: [portRef4] | |
472 | 504 … | }) | |
473 | 505 … | ||
474 | - this.kernel.createInstance('first', message1) | ||
475 | - this.kernel.createInstance('second', message2) | ||
506 … | + this.kernel.createInstance(First.typeId, message1) | ||
507 … | + this.kernel.createInstance(Second.typeId, message2) | ||
476 | 508 … | ||
477 | 509 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
478 | 510 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
479 | 511 … | ||
@@ -485,8 +517,11 @@ | |||
485 | 517 … | runs++ | |
486 | 518 … | t.equals(m.data, 'second', 'should recived the second message') | |
487 | 519 … | } | |
488 | 520 … | } | |
521 … | + static get typeId () { | ||
522 … | + return 299 | ||
523 … | + } | ||
489 | 524 … | } | |
490 | 525 … | ||
491 | 526 … | class First extends BaseContainer { | |
492 | 527 … | onMessage (m) { | |
@@ -494,8 +529,11 @@ | |||
494 | 529 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
495 | 530 … | data: 'first' | |
496 | 531 … | })) | |
497 | 532 … | } | |
533 … | + static get typeId () { | ||
534 … | + return 29 | ||
535 … | + } | ||
498 | 536 … | } | |
499 | 537 … | ||
500 | 538 … | class Second extends BaseContainer { | |
501 | 539 … | onMessage (m) { | |
@@ -503,8 +541,11 @@ | |||
503 | 541 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
504 | 542 … | data: 'second' | |
505 | 543 … | })) | |
506 | 544 … | } | |
545 … | + static get typeId () { | ||
546 … | + return 2 | ||
547 … | + } | ||
507 | 548 … | } | |
508 | 549 … | ||
509 | 550 … | class Waiter extends BaseContainer { | |
510 | 551 … | onCreation () { | |
@@ -517,26 +558,26 @@ | |||
517 | 558 … | } | |
518 | 559 … | ||
519 | 560 … | const hypervisor = new Hypervisor(node.dag) | |
520 | 561 … | ||
521 | - hypervisor.registerContainer('root', Root) | ||
522 | - hypervisor.registerContainer('first', First) | ||
523 | - hypervisor.registerContainer('second', Second) | ||
524 | - hypervisor.registerContainer('waiter', Waiter) | ||
562 … | + hypervisor.registerContainer(Root) | ||
563 … | + hypervisor.registerContainer(First) | ||
564 … | + hypervisor.registerContainer(Second) | ||
565 … | + hypervisor.registerContainer(Waiter) | ||
525 | 566 … | ||
526 | - const root = await hypervisor.createInstance('root') | ||
567 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
527 | 568 … | const [portRef1, portRef2] = root.ports.createChannel() | |
528 | 569 … | ||
529 | 570 … | const message = root.createMessage() | |
530 | 571 … | root.send(portRef1, message) | |
531 | 572 … | root.ports.bind('first', portRef1) | |
532 | - root.createInstance('root', root.createMessage({ | ||
573 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
533 | 574 … | ports: [portRef2] | |
534 | 575 … | })) | |
535 | 576 … | ||
536 | 577 … | const [portRef3, portRef4] = root.ports.createChannel() | |
537 | 578 … | root.ports.bind('sencond', portRef3) | |
538 | - root.createInstance('waiter', root.createMessage({ | ||
579 … | + root.createInstance(Waiter.typeId, root.createMessage({ | ||
539 | 580 … | ports: [portRef4] | |
540 | 581 … | })) | |
541 | 582 … | ||
542 | 583 … | root.incrementTicks(100) | |
@@ -565,10 +606,10 @@ | |||
565 | 606 … | const message2 = this.kernel.createMessage({ | |
566 | 607 … | ports: [portRef4] | |
567 | 608 … | }) | |
568 | 609 … | ||
569 | - this.kernel.createInstance('first', message1) | ||
570 | - this.kernel.createInstance('second', message2) | ||
610 … | + this.kernel.createInstance(First.typeId, message1) | ||
611 … | + this.kernel.createInstance(Second.typeId, message2) | ||
571 | 612 … | ||
572 | 613 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
573 | 614 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
574 | 615 … | ||
@@ -579,8 +620,11 @@ | |||
579 | 620 … | } else if (runs === 2) { | |
580 | 621 … | t.equals(m.data, 'first', 'should recive the first message') | |
581 | 622 … | } | |
582 | 623 … | } | |
624 … | + static get typeId () { | ||
625 … | + return 299 | ||
626 … | + } | ||
583 | 627 … | } | |
584 | 628 … | ||
585 | 629 … | class First extends BaseContainer { | |
586 | 630 … | onMessage (m) { | |
@@ -588,8 +632,11 @@ | |||
588 | 632 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
589 | 633 … | data: 'first' | |
590 | 634 … | })) | |
591 | 635 … | } | |
636 … | + static get typeId () { | ||
637 … | + return 29 | ||
638 … | + } | ||
592 | 639 … | } | |
593 | 640 … | ||
594 | 641 … | class Second extends BaseContainer { | |
595 | 642 … | onMessage (m) { | |
@@ -597,23 +644,26 @@ | |||
597 | 644 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
598 | 645 … | data: 'second' | |
599 | 646 … | })) | |
600 | 647 … | } | |
648 … | + static get typeId () { | ||
649 … | + return 2 | ||
650 … | + } | ||
601 | 651 … | } | |
602 | 652 … | ||
603 | 653 … | const hypervisor = new Hypervisor(node.dag) | |
604 | 654 … | ||
605 | - hypervisor.registerContainer('root', Root) | ||
606 | - hypervisor.registerContainer('first', First) | ||
607 | - hypervisor.registerContainer('second', Second) | ||
655 … | + hypervisor.registerContainer(Root) | ||
656 … | + hypervisor.registerContainer(First) | ||
657 … | + hypervisor.registerContainer(Second) | ||
608 | 658 … | ||
609 | - const root = await hypervisor.createInstance('root') | ||
659 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
610 | 660 … | const [portRef1, portRef2] = root.ports.createChannel() | |
611 | 661 … | const message = root.createMessage() | |
612 | 662 … | ||
613 | 663 … | root.send(portRef1, message) | |
614 | 664 … | root.ports.bind('first', portRef1) | |
615 | - root.createInstance('root', root.createMessage({ | ||
665 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
616 | 666 … | ports: [portRef2] | |
617 | 667 … | })) | |
618 | 668 … | }) | |
619 | 669 … | ||
@@ -638,10 +688,10 @@ | |||
638 | 688 … | const message2 = this.kernel.createMessage({ | |
639 | 689 … | ports: [portRef4] | |
640 | 690 … | }) | |
641 | 691 … | ||
642 | - this.kernel.createInstance('first', message1) | ||
643 | - this.kernel.createInstance('second', message2) | ||
692 … | + this.kernel.createInstance(First.typeId, message1) | ||
693 … | + this.kernel.createInstance(Second.typeId, message2) | ||
644 | 694 … | ||
645 | 695 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
646 | 696 … | this.kernel.send(portRef3, this.kernel.createMessage()) | |
647 | 697 … | ||
@@ -652,8 +702,11 @@ | |||
652 | 702 … | } else if (runs === 2) { | |
653 | 703 … | t.equals(m.data, 'second', 'should recived the second message') | |
654 | 704 … | } | |
655 | 705 … | } | |
706 … | + static get typeId () { | ||
707 … | + return 299 | ||
708 … | + } | ||
656 | 709 … | } | |
657 | 710 … | ||
658 | 711 … | class First extends BaseContainer { | |
659 | 712 … | onMessage (m) { | |
@@ -661,8 +714,11 @@ | |||
661 | 714 … | this.kernel.send(m.fromPort, this.kernel.createMessage({ | |
662 | 715 … | data: 'first' | |
663 | 716 … | })) | |
664 | 717 … | } | |
718 … | + static get typeId () { | ||
719 … | + return 29 | ||
720 … | + } | ||
665 | 721 … | } | |
666 | 722 … | ||
667 | 723 … | class Second extends BaseContainer { | |
668 | 724 … | onMessage (m) { | |
@@ -674,19 +730,19 @@ | |||
674 | 730 … | } | |
675 | 731 … | ||
676 | 732 … | const hypervisor = new Hypervisor(node.dag) | |
677 | 733 … | ||
678 | - hypervisor.registerContainer('root', Root) | ||
679 | - hypervisor.registerContainer('first', First) | ||
680 | - hypervisor.registerContainer('second', Second) | ||
734 … | + hypervisor.registerContainer(Root) | ||
735 … | + hypervisor.registerContainer(First) | ||
736 … | + hypervisor.registerContainer(Second) | ||
681 | 737 … | ||
682 | - const root = await hypervisor.createInstance('root') | ||
738 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
683 | 739 … | const [portRef1, portRef2] = root.ports.createChannel() | |
684 | 740 … | const message = root.createMessage() | |
685 | 741 … | ||
686 | 742 … | root.send(portRef1, message) | |
687 | 743 … | root.ports.bind('first', portRef1) | |
688 | - root.createInstance('root', root.createMessage({ | ||
744 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
689 | 745 … | ports: [portRef2] | |
690 | 746 … | })) | |
691 | 747 … | }) | |
692 | 748 … | ||
@@ -704,14 +760,17 @@ | |||
704 | 760 … | this.kernel.ports.bind('one', portRef1) | |
705 | 761 … | const message1 = this.kernel.createMessage({ | |
706 | 762 … | ports: [portRef2] | |
707 | 763 … | }) | |
708 | - this.kernel.createInstance('first', message1) | ||
764 … | + this.kernel.createInstance(First.typeId, message1) | ||
709 | 765 … | } else { | |
710 | 766 … | this.kernel.send(one, this.kernel.createMessage()) | |
711 | 767 … | this.kernel.send(one, this.kernel.createMessage()) | |
712 | 768 … | } | |
713 | 769 … | } | |
770 … | + static get typeId () { | ||
771 … | + return 299 | ||
772 … | + } | ||
714 | 773 … | } | |
715 | 774 … | ||
716 | 775 … | class First extends BaseContainer { | |
717 | 776 … | onMessage (m) { | |
@@ -725,15 +784,15 @@ | |||
725 | 784 … | } | |
726 | 785 … | ||
727 | 786 … | const hypervisor = new Hypervisor(node.dag) | |
728 | 787 … | ||
729 | - hypervisor.registerContainer('root', Root) | ||
730 | - hypervisor.registerContainer('first', First) | ||
788 … | + hypervisor.registerContainer(Root) | ||
789 … | + hypervisor.registerContainer(First) | ||
731 | 790 … | ||
732 | - const root = await hypervisor.createInstance('root') | ||
791 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
733 | 792 … | const [portRef1, portRef2] = root.ports.createChannel() | |
734 | 793 … | root.ports.bind('first', portRef1) | |
735 | - root.createInstance('root', root.createMessage({ | ||
794 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
736 | 795 … | ports: [portRef2] | |
737 | 796 … | })) | |
738 | 797 … | ||
739 | 798 … | const message = root.createMessage() | |
@@ -746,14 +805,14 @@ | |||
746 | 805 … | ||
747 | 806 … | tape('checking ports', async t => { | |
748 | 807 … | t.plan(4) | |
749 | 808 … | const hypervisor = new Hypervisor(node.dag) | |
750 | - hypervisor.registerContainer('base', BaseContainer) | ||
809 … | + hypervisor.registerContainer(BaseContainer) | ||
751 | 810 … | ||
752 | - const root = await hypervisor.createInstance('base') | ||
811 … | + const root = await hypervisor.createInstance(BaseContainer.typeId) | ||
753 | 812 … | ||
754 | 813 … | const [portRef1, portRef2] = root.ports.createChannel() | |
755 | - root.createInstance('base', root.createMessage({ | ||
814 … | + root.createInstance(BaseContainer.typeId, root.createMessage({ | ||
756 | 815 … | ports: [portRef2] | |
757 | 816 … | })) | |
758 | 817 … | root.ports.bind('test', portRef1) | |
759 | 818 … | ||
@@ -786,9 +845,9 @@ | |||
786 | 845 … | }) | |
787 | 846 … | ||
788 | 847 … | tape('port deletion', async t => { | |
789 | 848 … | const expectedSr = { | |
790 | - '/': 'zdpuB2QXxn1KQtLFfBqaritTRoe5BuKP5sNFSrPtRT6sxkY7Z' | ||
849 … | + '/': 'zdpuAqFMWKsATaU1gJwMTegcw18GFQ7szZix3QNgMN2sYm2vh' | ||
791 | 850 … | } | |
792 | 851 … | class Root extends BaseContainer { | |
793 | 852 … | onMessage (m) { | |
794 | 853 … | const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
@@ -796,9 +855,9 @@ | |||
796 | 855 … | const message1 = this.kernel.createMessage({ | |
797 | 856 … | ports: [portRef2] | |
798 | 857 … | }) | |
799 | 858 … | ||
800 | - this.kernel.createInstance('first', message1) | ||
859 … | + this.kernel.createInstance(First.typeId, message1) | ||
801 | 860 … | this.kernel.send(portRef1, this.kernel.createMessage()) | |
802 | 861 … | this.kernel.incrementTicks(6) | |
803 | 862 … | } | |
804 | 863 … | } | |
@@ -807,19 +866,22 @@ | |||
807 | 866 … | onMessage (m) { | |
808 | 867 … | this.kernel.incrementTicks(2) | |
809 | 868 … | this.kernel.ports.delete('root') | |
810 | 869 … | } | |
870 … | + static get typeId () { | ||
871 … | + return 299 | ||
872 … | + } | ||
811 | 873 … | } | |
812 | 874 … | ||
813 | 875 … | const hypervisor = new Hypervisor(node.dag) | |
814 | 876 … | ||
815 | - hypervisor.registerContainer('root', Root) | ||
816 | - hypervisor.registerContainer('first', First) | ||
877 … | + hypervisor.registerContainer(Root) | ||
878 … | + hypervisor.registerContainer(First) | ||
817 | 879 … | ||
818 | - const root = await hypervisor.createInstance('root') | ||
880 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
819 | 881 … | const [portRef1, portRef2] = root.ports.createChannel() | |
820 | 882 … | root.ports.bind('first', portRef1) | |
821 | - root.createInstance('root', root.createMessage({ | ||
883 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
822 | 884 … | ports: [portRef2] | |
823 | 885 … | })) | |
824 | 886 … | ||
825 | 887 … | const message = root.createMessage() | |
@@ -832,24 +894,24 @@ | |||
832 | 894 … | }) | |
833 | 895 … | ||
834 | 896 … | tape('clear unbounded ports', async t => { | |
835 | 897 … | const expectedSr = { | |
836 | - '/': 'zdpuB2QXxn1KQtLFfBqaritTRoe5BuKP5sNFSrPtRT6sxkY7Z' | ||
898 … | + '/': 'zdpuAqFMWKsATaU1gJwMTegcw18GFQ7szZix3QNgMN2sYm2vh' | ||
837 | 899 … | } | |
838 | 900 … | class Root extends BaseContainer { | |
839 | 901 … | onMessage (m) { | |
840 | - this.kernel.createInstance('root') | ||
902 … | + this.kernel.createInstance(Root.typeId) | ||
841 | 903 … | } | |
842 | 904 … | } | |
843 | 905 … | ||
844 | 906 … | const hypervisor = new Hypervisor(node.dag) | |
845 | 907 … | ||
846 | - hypervisor.registerContainer('root', Root) | ||
908 … | + hypervisor.registerContainer(Root) | ||
847 | 909 … | ||
848 | - const root = await hypervisor.createInstance('root') | ||
910 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
849 | 911 … | const [portRef1, portRef2] = root.ports.createChannel() | |
850 | 912 … | root.ports.bind('first', portRef1) | |
851 | - root.createInstance('root', root.createMessage({ | ||
913 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
852 | 914 … | ports: [portRef2] | |
853 | 915 … | })) | |
854 | 916 … | ||
855 | 917 … | const message = root.createMessage() | |
@@ -861,14 +923,14 @@ | |||
861 | 923 … | }) | |
862 | 924 … | ||
863 | 925 … | tape('should remove subgraphs', async t => { | |
864 | 926 … | const expectedSr = { | |
865 | - '/': 'zdpuB2QXxn1KQtLFfBqaritTRoe5BuKP5sNFSrPtRT6sxkY7Z' | ||
927 … | + '/': 'zdpuAqFMWKsATaU1gJwMTegcw18GFQ7szZix3QNgMN2sYm2vh' | ||
866 | 928 … | } | |
867 | 929 … | class Root extends BaseContainer { | |
868 | 930 … | onMessage (m) { | |
869 | 931 … | const [, portRef2] = this.kernel.ports.createChannel() | |
870 | - this.kernel.createInstance('sub', this.kernel.createMessage({ | ||
932 … | + this.kernel.createInstance(Sub.typeId, this.kernel.createMessage({ | ||
871 | 933 … | ports: [portRef2] | |
872 | 934 … | })) | |
873 | 935 … | } | |
874 | 936 … | } | |
@@ -877,23 +939,26 @@ | |||
877 | 939 … | onInitailize (message) { | |
878 | 940 … | this.kernel.ports.bind('root', message.ports[0]) | |
879 | 941 … | const [portRef1, portRef2] = root.ports.createChannel() | |
880 | 942 … | root.ports.bind('child', portRef1) | |
881 | - root.createInstance('root', root.createMessage({ | ||
943 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
882 | 944 … | ports: [portRef2] | |
883 | 945 … | })) | |
884 | 946 … | } | |
947 … | + static get typeId () { | ||
948 … | + return 299 | ||
949 … | + } | ||
885 | 950 … | } | |
886 | 951 … | ||
887 | 952 … | const hypervisor = new Hypervisor(node.dag) | |
888 | 953 … | ||
889 | - hypervisor.registerContainer('root', Root) | ||
890 | - hypervisor.registerContainer('sub', Sub) | ||
954 … | + hypervisor.registerContainer(Root) | ||
955 … | + hypervisor.registerContainer(Sub) | ||
891 | 956 … | ||
892 | - const root = await hypervisor.createInstance('root') | ||
957 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
893 | 958 … | const [portRef1, portRef2] = root.ports.createChannel() | |
894 | 959 … | root.ports.bind('first', portRef1) | |
895 | - root.createInstance('root', root.createMessage({ | ||
960 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
896 | 961 … | ports: [portRef2] | |
897 | 962 … | })) | |
898 | 963 … | ||
899 | 964 … | root.send(portRef1, root.createMessage()) | |
@@ -904,9 +969,9 @@ | |||
904 | 969 … | }) | |
905 | 970 … | ||
906 | 971 … | tape('should not remove connected nodes', async t => { | |
907 | 972 … | const expectedSr = { | |
908 | - '/': 'zdpuAwsZTd5mRZBCYA1FJSHrpYDPgSZSiaTQp9xkUeajaoMHM' | ||
973 … | + '/': 'zdpuAppPTaXwHnfU2yjtTyT9XsY7SJAkDwQWUZnkHU7myRzaj' | ||
909 | 974 … | } | |
910 | 975 … | class Root extends BaseContainer { | |
911 | 976 … | onMessage (m) { | |
912 | 977 … | if (m.ports.length) { | |
@@ -914,15 +979,15 @@ | |||
914 | 979 … | this.kernel.send(port, m) | |
915 | 980 … | this.kernel.ports.unbind('test1') | |
916 | 981 … | } else { | |
917 | 982 … | const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
918 | - this.kernel.createInstance('sub', this.kernel.createMessage({ | ||
983 … | + this.kernel.createInstance(Sub.typeId, this.kernel.createMessage({ | ||
919 | 984 … | ports: [portRef2] | |
920 | 985 … | })) | |
921 | 986 … | this.kernel.ports.bind('test1', portRef1) | |
922 | 987 … | ||
923 | 988 … | const [portRef3, portRef4] = this.kernel.ports.createChannel() | |
924 | - this.kernel.createInstance('sub', this.kernel.createMessage({ | ||
989 … | + this.kernel.createInstance(Sub.typeId, this.kernel.createMessage({ | ||
925 | 990 … | ports: [portRef4] | |
926 | 991 … | })) | |
927 | 992 … | this.kernel.ports.bind('test2', portRef3) | |
928 | 993 … | this.kernel.send(portRef3, this.kernel.createMessage({ | |
@@ -944,19 +1009,22 @@ | |||
944 | 1009 … | } else if (message.data === 'bindPort') { | |
945 | 1010 … | this.kernel.ports.bind('channel', message.ports[0]) | |
946 | 1011 … | } | |
947 | 1012 … | } | |
1013 … | + static get typeId () { | ||
1014 … | + return 299 | ||
1015 … | + } | ||
948 | 1016 … | } | |
949 | 1017 … | ||
950 | 1018 … | const hypervisor = new Hypervisor(node.dag) | |
951 | 1019 … | ||
952 | - hypervisor.registerContainer('root', Root) | ||
953 | - hypervisor.registerContainer('sub', Sub) | ||
1020 … | + hypervisor.registerContainer(Root) | ||
1021 … | + hypervisor.registerContainer(Sub) | ||
954 | 1022 … | ||
955 | - const root = await hypervisor.createInstance('root') | ||
1023 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
956 | 1024 … | const [portRef1, portRef2] = root.ports.createChannel() | |
957 | 1025 … | root.ports.bind('first', portRef1) | |
958 | - root.createInstance('root', root.createMessage({ | ||
1026 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
959 | 1027 … | ports: [portRef2] | |
960 | 1028 … | })) | |
961 | 1029 … | ||
962 | 1030 … | root.send(portRef1, root.createMessage()) | |
@@ -968,9 +1036,9 @@ | |||
968 | 1036 … | }) | |
969 | 1037 … | ||
970 | 1038 … | tape('should remove multiple subgraphs', async t => { | |
971 | 1039 … | const expectedSr = { | |
972 | - '/': 'zdpuAmi9tkYTpoVsZvqQgxpQFRhCgYFVv4W3fjjfVhf1j8swv' | ||
1040 … | + '/': 'zdpuAvQqoEnojZHaw6dMDy8ACRVqfarfD2RCKTwFBYsj8suRC' | ||
973 | 1041 … | } | |
974 | 1042 … | class Root extends BaseContainer { | |
975 | 1043 … | onMessage (m) { | |
976 | 1044 … | if (m.ports.length) { | |
@@ -979,15 +1047,15 @@ | |||
979 | 1047 … | this.kernel.ports.unbind('test1') | |
980 | 1048 … | this.kernel.ports.unbind('test2') | |
981 | 1049 … | } else { | |
982 | 1050 … | const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
983 | - this.kernel.createInstance('sub', this.kernel.createMessage({ | ||
1051 … | + this.kernel.createInstance(Sub.typeId, this.kernel.createMessage({ | ||
984 | 1052 … | ports: [portRef2] | |
985 | 1053 … | })) | |
986 | 1054 … | this.kernel.ports.bind('test1', portRef1) | |
987 | 1055 … | ||
988 | 1056 … | const [portRef3, portRef4] = this.kernel.ports.createChannel() | |
989 | - this.kernel.createInstance('sub', this.kernel.createMessage({ | ||
1057 … | + this.kernel.createInstance(Sub.typeId, this.kernel.createMessage({ | ||
990 | 1058 … | ports: [portRef4] | |
991 | 1059 … | })) | |
992 | 1060 … | this.kernel.ports.bind('test2', portRef3) | |
993 | 1061 … | this.kernel.send(portRef3, this.kernel.createMessage({ | |
@@ -1009,20 +1077,23 @@ | |||
1009 | 1077 … | } else if (message.data === 'bindPort') { | |
1010 | 1078 … | this.kernel.ports.bind('channel', message.ports[0]) | |
1011 | 1079 … | } | |
1012 | 1080 … | } | |
1081 … | + static get typeId () { | ||
1082 … | + return 299 | ||
1083 … | + } | ||
1013 | 1084 … | } | |
1014 | 1085 … | ||
1015 | 1086 … | const hypervisor = new Hypervisor(node.dag) | |
1016 | 1087 … | ||
1017 | - hypervisor.registerContainer('root', Root) | ||
1018 | - hypervisor.registerContainer('sub', Sub) | ||
1088 … | + hypervisor.registerContainer(Root) | ||
1089 … | + hypervisor.registerContainer(Sub) | ||
1019 | 1090 … | ||
1020 | - const root = await hypervisor.createInstance('root') | ||
1091 … | + const root = await hypervisor.createInstance(Root.typeId) | ||
1021 | 1092 … | ||
1022 | 1093 … | const [portRef1, portRef2] = root.ports.createChannel() | |
1023 | 1094 … | root.ports.bind('first', portRef1) | |
1024 | - root.createInstance('root', root.createMessage({ | ||
1095 … | + root.createInstance(Root.typeId, root.createMessage({ | ||
1025 | 1096 … | ports: [portRef2] | |
1026 | 1097 … | })) | |
1027 | 1098 … | ||
1028 | 1099 … | root.send(portRef1, root.createMessage()) | |
@@ -1050,18 +1121,18 @@ | |||
1050 | 1121 … | } | |
1051 | 1122 … | ||
1052 | 1123 … | const hypervisor = new Hypervisor(node.dag) | |
1053 | 1124 … | ||
1054 | - hypervisor.registerContainer('test', testVMContainer) | ||
1125 … | + hypervisor.registerContainer(testVMContainer) | ||
1055 | 1126 … | ||
1056 | - const rootContainer = await hypervisor.createInstance('test') | ||
1127 … | + const rootContainer = await hypervisor.createInstance(testVMContainer.typeId) | ||
1057 | 1128 … | ||
1058 | 1129 … | const [portRef1, portRef2] = rootContainer.ports.createChannel() | |
1059 | 1130 … | const initMessage = rootContainer.createMessage({ | |
1060 | 1131 … | ports: [portRef2] | |
1061 | 1132 … | }) | |
1062 | 1133 … | ||
1063 | - rootContainer.createInstance('test', initMessage) | ||
1134 … | + rootContainer.createInstance(testVMContainer.typeId, initMessage) | ||
1064 | 1135 … | ||
1065 | 1136 … | rootContainer.ports.bind('first', portRef1) | |
1066 | 1137 … | const message = rootContainer.createMessage() | |
1067 | 1138 … | const rPort = rootContainer.getResponsePort(message) | |
@@ -1082,10 +1153,10 @@ | |||
1082 | 1153 … | } | |
1083 | 1154 … | } | |
1084 | 1155 … | ||
1085 | 1156 … | const hypervisor = new Hypervisor(node.dag) | |
1086 | - hypervisor.registerContainer('test', testVMContainer) | ||
1087 | - await hypervisor.createInstance('test') | ||
1157 … | + hypervisor.registerContainer(testVMContainer) | ||
1158 … | + await hypervisor.createInstance(testVMContainer.typeId) | ||
1088 | 1159 … | hypervisor.getInstance(hypervisor.ROOT_ID) | |
1089 | 1160 … | }) | |
1090 | 1161 … | ||
1091 | 1162 … | tape('large code size', async t => { | |
@@ -1095,10 +1166,10 @@ | |||
1095 | 1166 … | onMessage () {} | |
1096 | 1167 … | } | |
1097 | 1168 … | ||
1098 | 1169 … | const hypervisor = new Hypervisor(node.dag) | |
1099 | - hypervisor.registerContainer('test', testVMContainer) | ||
1100 | - await hypervisor.createInstance('test', new Message({data: content})) | ||
1170 … | + hypervisor.registerContainer(testVMContainer) | ||
1171 … | + await hypervisor.createInstance(testVMContainer.typeId, new Message({data: content})) | ||
1101 | 1172 … | const instance = await hypervisor.getInstance(hypervisor.ROOT_ID) | |
1102 | 1173 … | t.equals(content.length, instance.code.length) | |
1103 | 1174 … | }) | |
1104 | 1175 … | }) |
Built with git-ssb-web