tests/index.jsView |
---|
69 | 69 | |
70 | 70 | class testVMContainerA extends BaseContainer { |
71 | 71 | onCreation (m) { |
72 | 72 | message = new Message() |
73 | | - return this.actor.send(m.caps[0], message) |
| 73 | + this.actor.send(m.caps[0], message) |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | class testVMContainerB extends BaseContainer { |
111 | 111 | |
112 | 112 | class testVMContainerA extends BaseContainer { |
113 | 113 | onCreation (m) { |
114 | 114 | message = new Message() |
115 | | - return this.actor.send(m.caps[0], message) |
| 115 | + this.actor.send(m.caps[0], message) |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | class testVMContainerB extends BaseContainer { |
161 | 161 | async onCreation (m) { |
162 | 162 | this.actor.incrementTicks(ticks) |
163 | 163 | ticks++ |
164 | 164 | message = new Message() |
165 | | - await this.actor.send(m.caps[0], message) |
| 165 | + this.actor.send(m.caps[0], message) |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | class testVMContainerB extends BaseContainer { |
170 | 170 | onMessage (m) { |
171 | 171 | t.true(m, 'should recive a message') |
172 | | - return new Promise((resolve, reject) => { |
173 | | - setTimeout(resolve, 200) |
174 | | - }) |
175 | 172 | } |
176 | 173 | |
177 | 174 | static get typeId () { |
178 | 175 | return 8 |
183 | 180 | hypervisor.registerContainer(testVMContainerA) |
184 | 181 | hypervisor.registerContainer(testVMContainerB) |
185 | 182 | |
186 | 183 | let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message()) |
187 | | - hypervisor.createActor(testVMContainerA.typeId, new Message({ |
| 184 | + await hypervisor.createActor(testVMContainerA.typeId, new Message({ |
188 | 185 | caps: [capB] |
189 | 186 | })) |
190 | 187 | |
191 | 188 | await hypervisor.createActor(testVMContainerA.typeId, new Message({ |
211 | 208 | class testVMContainerA extends BaseContainer { |
212 | 209 | onCreation (m) { |
213 | 210 | message = new Message() |
214 | 211 | message.responseCap = this.actor.mintCap() |
215 | | - return this.actor.send(m.caps[0], message) |
| 212 | + this.actor.send(m.caps[0], message) |
216 | 213 | } |
217 | 214 | |
218 | 215 | onMessage (m) { |
219 | 216 | t.true(m, 'should recive a response message') |
258 | 255 | class testVMContainerA extends BaseContainer { |
259 | 256 | onCreation (m) { |
260 | 257 | message = new Message() |
261 | 258 | message.responseCap = this.actor.mintCap() |
262 | | - return this.actor.send(m.caps[0], message) |
| 259 | + this.actor.send(m.caps[0], message) |
263 | 260 | } |
264 | 261 | |
265 | 262 | onMessage (m) { |
266 | 263 | t.true(m.data.exceptionError instanceof Error, 'should recive a response message') |
318 | 315 | |
319 | 316 | class testVMContainerB extends BaseContainer { |
320 | 317 | onCreation (m) { |
321 | 318 | const cap = m.caps[0] |
322 | | - return this.actor.send(cap, new Message({data: 'test'})) |
| 319 | + this.actor.send(cap, new Message({data: 'test'})) |
323 | 320 | } |
324 | 321 | |
325 | 322 | static get typeId () { |
326 | 323 | return 8 |
362 | 359 | this.actor.send(m.caps[0], message1) |
363 | 360 | this.actor.incrementTicks(1) |
364 | 361 | this.actor.send(m.caps[0], message2) |
365 | 362 | this.actor.incrementTicks(1) |
366 | | - return this.actor.send(m.caps[0], message3) |
| 363 | + this.actor.send(m.caps[0], message3) |
367 | 364 | } |
368 | 365 | } |
369 | 366 | |
370 | 367 | let recMsg = 0 |
431 | 428 | } else { |
432 | 429 | t.equal(m.data, 'third', 'should recive third message') |
433 | 430 | } |
434 | 431 | recMsg++ |
435 | | - |
436 | | - return new Promise((resolve, reject) => { |
437 | | - setTimeout(resolve, 200) |
438 | | - }) |
439 | 432 | } |
440 | 433 | |
441 | 434 | static get typeId () { |
442 | 435 | return 8 |
447 | 440 | hypervisor.registerContainer(testVMContainerA) |
448 | 441 | hypervisor.registerContainer(testVMContainerB) |
449 | 442 | |
450 | 443 | let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message()) |
451 | | - hypervisor.send(capB, new Message({ |
| 444 | + await hypervisor.send(capB, new Message({ |
452 | 445 | data: 'first' |
453 | 446 | })) |
| 447 | + |
454 | 448 | await hypervisor.createActor(testVMContainerA.typeId, new Message({ |
455 | 449 | caps: [capB], |
456 | 450 | data: 'second' |
457 | 451 | })) |
481 | 475 | t.true(m, 'should recive first message') |
482 | 476 | const rCap = this.actor.mintCap(1) |
483 | 477 | const message = new Message() |
484 | 478 | message.responseCap = rCap |
485 | | - await this.actor.send(m.caps[0], message) |
| 479 | + this.actor.send(m.caps[0], message) |
486 | 480 | const rMessage = await this.actor.inbox.nextTaggedMessage([1], 44) |
487 | 481 | t.true(rMessage, 'should recive a response message') |
488 | 482 | } |
489 | 483 | } |
527 | 521 | t.true(m, 'should recive first message') |
528 | 522 | const rCap = this.actor.mintCap(1) |
529 | 523 | const message = new Message({data: 'first'}) |
530 | 524 | message.responseCap = rCap |
531 | | - await this.actor.send(m.caps[0], message) |
| 525 | + this.actor.send(m.caps[0], message) |
532 | 526 | const promise = this.actor.inbox.nextTaggedMessage([1], 44) |
533 | 527 | try { |
534 | 528 | await this.actor.inbox.nextTaggedMessage([1], 44) |
535 | 529 | } catch (e) { |
586 | 580 | data: 'second' |
587 | 581 | }) |
588 | 582 | message1.caps.push(cap1) |
589 | 583 | message2.caps.push(cap2) |
590 | | - await Promise.all([ |
591 | | - this.actor.send(m.caps[0], message1), |
592 | | - this.actor.send(m.caps[1], message2) |
593 | | - ]) |
| 584 | + this.actor.send(m.caps[0], message1) |
| 585 | + this.actor.send(m.caps[1], message2) |
594 | 586 | const rMessage = await this.actor.inbox.nextTaggedMessage([1, 2], 44) |
595 | 587 | t.true(rMessage, 'should recive a response message') |
596 | 588 | } |
597 | 589 | } |
598 | 590 | } |
599 | 591 | |
600 | 592 | class testVMContainerB extends BaseContainer { |
601 | | - async onMessage (m) { |
| 593 | + onMessage (m) { |
602 | 594 | t.true(m, 'should recive a message') |
603 | 595 | const cap = m.caps[0] |
604 | 596 | this.actor.incrementTicks(1) |
605 | | - await this.actor.send(cap, new Message({data: m.data})) |
606 | | - |
607 | | - return new Promise((resolve, reject) => { |
608 | | - setTimeout(resolve, 200) |
609 | | - }) |
| 597 | + this.actor.send(cap, new Message({data: m.data})) |
610 | 598 | } |
611 | 599 | |
612 | 600 | static get typeId () { |
613 | 601 | return 8 |
652 | 640 | data: 'second' |
653 | 641 | }) |
654 | 642 | message1.caps.push(cap1) |
655 | 643 | message2.caps.push(cap2) |
656 | | - await this.actor.send(m.caps[0], message1) |
657 | | - await this.actor.send(m.caps[1], message2) |
| 644 | + this.actor.send(m.caps[0], message1) |
| 645 | + this.actor.send(m.caps[1], message2) |
658 | 646 | const rMessage = await this.actor.inbox.nextTaggedMessage([1, 2], 44) |
659 | 647 | t.true(rMessage, 'should recive a response message') |
660 | 648 | } |
661 | 649 | } |
665 | 653 | async onMessage (m) { |
666 | 654 | t.true(m, 'should recive a message') |
667 | 655 | const cap = m.caps[0] |
668 | 656 | this.actor.incrementTicks(1) |
669 | | - await this.actor.send(cap, new Message({data: m.data})) |
670 | | - |
671 | | - return new Promise((resolve, reject) => { |
672 | | - setTimeout(resolve, 200) |
673 | | - }) |
| 657 | + this.actor.send(cap, new Message({data: m.data})) |
674 | 658 | } |
675 | 659 | |
676 | 660 | static get typeId () { |
677 | 661 | return 8 |
729 | 713 | async onMessage (m) { |
730 | 714 | t.true(m, 'should recive a message') |
731 | 715 | const cap = m.caps[0] |
732 | 716 | this.actor.incrementTicks(1) |
733 | | - await this.actor.send(cap, new Message({data: m.data})) |
734 | | - |
735 | | - return new Promise((resolve, reject) => { |
736 | | - setTimeout(resolve, 200) |
737 | | - }) |
| 717 | + this.actor.send(cap, new Message({data: m.data})) |
738 | 718 | } |
739 | 719 | |
740 | 720 | static get typeId () { |
741 | 721 | return 8 |