tests/index.jsView |
---|
44 | 44 | data: Buffer.from('test code'), |
45 | 45 | ports: [portRef2] |
46 | 46 | }) |
47 | 47 | |
48 | | - rootContainer.ports.create('test', initMessage) |
| 48 | + rootContainer.createInstance('test', initMessage) |
49 | 49 | |
50 | 50 | rootContainer.ports.bind('first', portRef1) |
51 | 51 | message = rootContainer.createMessage() |
52 | 52 | rootContainer.send(portRef1, message) |
71 | 71 | const root = await hypervisor.createInstance('test') |
72 | 72 | const [portRef1, portRef2] = root.ports.createChannel() |
73 | 73 | |
74 | 74 | root.ports.bind('one', portRef1) |
75 | | - root.ports.create('test', root.createMessage({ |
| 75 | + root.createInstance('test', root.createMessage({ |
76 | 76 | ports: [portRef2] |
77 | 77 | })) |
78 | 78 | |
79 | 79 | const stateRoot = await hypervisor.createStateRoot(Infinity) |
95 | 95 | |
96 | 96 | class testVMContainer extends BaseContainer { |
97 | 97 | run (m) { |
98 | 98 | const [portRef1, portRef2] = this.exInterface.ports.createChannel() |
99 | | - this.exInterface.ports.create('test2', this.exInterface.createMessage({ |
| 99 | + this.exInterface.createInstance('test2', this.exInterface.createMessage({ |
100 | 100 | ports: [portRef2] |
101 | 101 | })) |
102 | 102 | this.exInterface.ports.bind('child', portRef1) |
103 | 103 | this.exInterface.incrementTicks(2) |
110 | 110 | hypervisor.registerContainer('test2', testVMContainer2) |
111 | 111 | |
112 | 112 | const root = await hypervisor.createInstance('test') |
113 | 113 | const [portRef1, portRef2] = root.ports.createChannel() |
114 | | - root.ports.create('test', root.createMessage({ |
| 114 | + root.createInstance('test', root.createMessage({ |
115 | 115 | ports: [portRef2] |
116 | 116 | })) |
117 | 117 | |
118 | 118 | root.ports.bind('first', portRef1) |
148 | 148 | |
149 | 149 | class testVMContainer extends BaseContainer { |
150 | 150 | run (m) { |
151 | 151 | const [portRef1, portRef2] = this.exInterface.ports.createChannel() |
152 | | - this.exInterface.ports.create('test2', this.exInterface.createMessage({ |
| 152 | + this.exInterface.createInstance('test2', this.exInterface.createMessage({ |
153 | 153 | ports: [portRef2] |
154 | 154 | })) |
155 | 155 | this.exInterface.ports.bind('child', portRef1) |
156 | 156 | this.exInterface.send(portRef1, m) |
164 | 164 | |
165 | 165 | let root = await hypervisor.createInstance('test') |
166 | 166 | const rootId = root.id |
167 | 167 | const [portRef1, portRef2] = root.ports.createChannel() |
168 | | - root.ports.create('test', root.createMessage({ |
| 168 | + root.createInstance('test', root.createMessage({ |
169 | 169 | ports: [portRef2] |
170 | 170 | })) |
171 | 171 | |
172 | 172 | root.ports.bind('first', portRef1) |
213 | 213 | const message3 = this.exInterface.createMessage({ |
214 | 214 | ports: [portRef6] |
215 | 215 | }) |
216 | 216 | |
217 | | - this.exInterface.ports.create('root', message1) |
218 | | - this.exInterface.ports.create('root', message2) |
219 | | - this.exInterface.ports.create('root', message3) |
| 217 | + this.exInterface.createInstance('root', message1) |
| 218 | + this.exInterface.createInstance('root', message2) |
| 219 | + this.exInterface.createInstance('root', message3) |
220 | 220 | |
221 | 221 | throw new Error('it is a trap!!!') |
222 | 222 | } |
223 | 223 | } |
255 | 255 | const message2 = this.exInterface.createMessage({ |
256 | 256 | ports: [portRef4] |
257 | 257 | }) |
258 | 258 | |
259 | | - this.exInterface.ports.create('first', message1) |
260 | | - this.exInterface.ports.create('second', message2) |
| 259 | + this.exInterface.createInstance('first', message1) |
| 260 | + this.exInterface.createInstance('second', message2) |
261 | 261 | |
262 | 262 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
263 | 263 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
264 | 264 | } else if (runs === 1) { |
296 | 296 | |
297 | 297 | const root = await hypervisor.createInstance('root') |
298 | 298 | |
299 | 299 | const [portRef1, portRef2] = root.ports.createChannel() |
300 | | - root.ports.create('root', root.createMessage({ |
| 300 | + root.createInstance('root', root.createMessage({ |
301 | 301 | ports: [portRef2] |
302 | 302 | })) |
303 | 303 | |
304 | 304 | root.ports.bind('first', portRef1) |
327 | 327 | const message2 = this.exInterface.createMessage({ |
328 | 328 | ports: [portRef4] |
329 | 329 | }) |
330 | 330 | |
331 | | - this.exInterface.ports.create('first', message1) |
332 | | - this.exInterface.ports.create('second', message2) |
| 331 | + this.exInterface.createInstance('first', message1) |
| 332 | + this.exInterface.createInstance('second', message2) |
333 | 333 | |
334 | 334 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
335 | 335 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
336 | 336 | } else if (runs === 1) { |
368 | 368 | |
369 | 369 | const root = await hypervisor.createInstance('root') |
370 | 370 | |
371 | 371 | const [portRef1, portRef2] = root.ports.createChannel() |
372 | | - root.ports.create('root', root.createMessage({ |
| 372 | + root.createInstance('root', root.createMessage({ |
373 | 373 | ports: [portRef2] |
374 | 374 | })) |
375 | 375 | |
376 | 376 | root.ports.bind('first', portRef1) |
398 | 398 | const message2 = this.exInterface.createMessage({ |
399 | 399 | ports: [portRef4] |
400 | 400 | }) |
401 | 401 | |
402 | | - this.exInterface.ports.create('first', message1) |
403 | | - this.exInterface.ports.create('second', message2) |
| 402 | + this.exInterface.createInstance('first', message1) |
| 403 | + this.exInterface.createInstance('second', message2) |
404 | 404 | |
405 | 405 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
406 | 406 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
407 | 407 | |
440 | 440 | hypervisor.registerContainer('second', Second) |
441 | 441 | |
442 | 442 | const root = await hypervisor.createInstance('root') |
443 | 443 | const [portRef1, portRef2] = root.ports.createChannel() |
444 | | - root.ports.create('root', root.createMessage({ |
| 444 | + root.createInstance('root', root.createMessage({ |
445 | 445 | ports: [portRef2] |
446 | 446 | })) |
447 | 447 | |
448 | 448 | root.ports.bind('first', portRef1) |
470 | 470 | const message2 = this.exInterface.createMessage({ |
471 | 471 | ports: [portRef4] |
472 | 472 | }) |
473 | 473 | |
474 | | - this.exInterface.ports.create('first', message1) |
475 | | - this.exInterface.ports.create('second', message2) |
| 474 | + this.exInterface.createInstance('first', message1) |
| 475 | + this.exInterface.createInstance('second', message2) |
476 | 476 | |
477 | 477 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
478 | 478 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
479 | 479 | |
528 | 528 | |
529 | 529 | const message = root.createMessage() |
530 | 530 | root.send(portRef1, message) |
531 | 531 | root.ports.bind('first', portRef1) |
532 | | - root.ports.create('root', root.createMessage({ |
| 532 | + root.createInstance('root', root.createMessage({ |
533 | 533 | ports: [portRef2] |
534 | 534 | })) |
535 | 535 | |
536 | 536 | const [portRef3, portRef4] = root.ports.createChannel() |
537 | 537 | root.ports.bind('sencond', portRef3) |
538 | | - root.ports.create('waiter', root.createMessage({ |
| 538 | + root.createInstance('waiter', root.createMessage({ |
539 | 539 | ports: [portRef4] |
540 | 540 | })) |
541 | 541 | |
542 | 542 | root.incrementTicks(100) |
565 | 565 | const message2 = this.exInterface.createMessage({ |
566 | 566 | ports: [portRef4] |
567 | 567 | }) |
568 | 568 | |
569 | | - this.exInterface.ports.create('first', message1) |
570 | | - this.exInterface.ports.create('second', message2) |
| 569 | + this.exInterface.createInstance('first', message1) |
| 570 | + this.exInterface.createInstance('second', message2) |
571 | 571 | |
572 | 572 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
573 | 573 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
574 | 574 | |
611 | 611 | const message = root.createMessage() |
612 | 612 | |
613 | 613 | root.send(portRef1, message) |
614 | 614 | root.ports.bind('first', portRef1) |
615 | | - root.ports.create('root', root.createMessage({ |
| 615 | + root.createInstance('root', root.createMessage({ |
616 | 616 | ports: [portRef2] |
617 | 617 | })) |
618 | 618 | }) |
619 | 619 | |
638 | 638 | const message2 = this.exInterface.createMessage({ |
639 | 639 | ports: [portRef4] |
640 | 640 | }) |
641 | 641 | |
642 | | - this.exInterface.ports.create('first', message1) |
643 | | - this.exInterface.ports.create('second', message2) |
| 642 | + this.exInterface.createInstance('first', message1) |
| 643 | + this.exInterface.createInstance('second', message2) |
644 | 644 | |
645 | 645 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
646 | 646 | this.exInterface.send(portRef3, this.exInterface.createMessage()) |
647 | 647 | |
684 | 684 | const message = root.createMessage() |
685 | 685 | |
686 | 686 | root.send(portRef1, message) |
687 | 687 | root.ports.bind('first', portRef1) |
688 | | - root.ports.create('root', root.createMessage({ |
| 688 | + root.createInstance('root', root.createMessage({ |
689 | 689 | ports: [portRef2] |
690 | 690 | })) |
691 | 691 | }) |
692 | 692 | |
704 | 704 | this.exInterface.ports.bind('one', portRef1) |
705 | 705 | const message1 = this.exInterface.createMessage({ |
706 | 706 | ports: [portRef2] |
707 | 707 | }) |
708 | | - this.exInterface.ports.create('first', message1) |
| 708 | + this.exInterface.createInstance('first', message1) |
709 | 709 | } else { |
710 | 710 | this.exInterface.send(one, this.exInterface.createMessage()) |
711 | 711 | this.exInterface.send(one, this.exInterface.createMessage()) |
712 | 712 | } |
731 | 731 | |
732 | 732 | const root = await hypervisor.createInstance('root') |
733 | 733 | const [portRef1, portRef2] = root.ports.createChannel() |
734 | 734 | root.ports.bind('first', portRef1) |
735 | | - root.ports.create('root', root.createMessage({ |
| 735 | + root.createInstance('root', root.createMessage({ |
736 | 736 | ports: [portRef2] |
737 | 737 | })) |
738 | 738 | |
739 | 739 | const message = root.createMessage() |
751 | 751 | |
752 | 752 | const root = await hypervisor.createInstance('base') |
753 | 753 | |
754 | 754 | const [portRef1, portRef2] = root.ports.createChannel() |
755 | | - root.ports.create('base', root.createMessage({ |
| 755 | + root.createInstance('base', root.createMessage({ |
756 | 756 | ports: [portRef2] |
757 | 757 | })) |
758 | 758 | root.ports.bind('test', portRef1) |
759 | 759 | |
796 | 796 | const message1 = this.exInterface.createMessage({ |
797 | 797 | ports: [portRef2] |
798 | 798 | }) |
799 | 799 | |
800 | | - this.exInterface.ports.create('first', message1) |
| 800 | + this.exInterface.createInstance('first', message1) |
801 | 801 | this.exInterface.send(portRef1, this.exInterface.createMessage()) |
802 | 802 | this.exInterface.incrementTicks(6) |
803 | 803 | } |
804 | 804 | } |
817 | 817 | |
818 | 818 | const root = await hypervisor.createInstance('root') |
819 | 819 | const [portRef1, portRef2] = root.ports.createChannel() |
820 | 820 | root.ports.bind('first', portRef1) |
821 | | - root.ports.create('root', root.createMessage({ |
| 821 | + root.createInstance('root', root.createMessage({ |
822 | 822 | ports: [portRef2] |
823 | 823 | })) |
824 | 824 | |
825 | 825 | const message = root.createMessage() |
836 | 836 | '/': 'zdpuB2QXxn1KQtLFfBqaritTRoe5BuKP5sNFSrPtRT6sxkY7Z' |
837 | 837 | } |
838 | 838 | class Root extends BaseContainer { |
839 | 839 | run (m) { |
840 | | - this.exInterface.ports.create('root') |
| 840 | + this.exInterface.createInstance('root') |
841 | 841 | } |
842 | 842 | } |
843 | 843 | |
844 | 844 | const hypervisor = new Hypervisor(node.dag) |
847 | 847 | |
848 | 848 | const root = await hypervisor.createInstance('root') |
849 | 849 | const [portRef1, portRef2] = root.ports.createChannel() |
850 | 850 | root.ports.bind('first', portRef1) |
851 | | - root.ports.create('root', root.createMessage({ |
| 851 | + root.createInstance('root', root.createMessage({ |
852 | 852 | ports: [portRef2] |
853 | 853 | })) |
854 | 854 | |
855 | 855 | const message = root.createMessage() |
866 | 866 | } |
867 | 867 | class Root extends BaseContainer { |
868 | 868 | run (m) { |
869 | 869 | const [, portRef2] = this.exInterface.ports.createChannel() |
870 | | - this.exInterface.ports.create('sub', this.exInterface.createMessage({ |
| 870 | + this.exInterface.createInstance('sub', this.exInterface.createMessage({ |
871 | 871 | ports: [portRef2] |
872 | 872 | })) |
873 | 873 | } |
874 | 874 | } |
877 | 877 | initailize (message) { |
878 | 878 | this.exInterface.ports.bind('root', message.ports[0]) |
879 | 879 | const [portRef1, portRef2] = root.ports.createChannel() |
880 | 880 | root.ports.bind('child', portRef1) |
881 | | - root.ports.create('root', root.createMessage({ |
| 881 | + root.createInstance('root', root.createMessage({ |
882 | 882 | ports: [portRef2] |
883 | 883 | })) |
884 | 884 | } |
885 | 885 | } |
891 | 891 | |
892 | 892 | const root = await hypervisor.createInstance('root') |
893 | 893 | const [portRef1, portRef2] = root.ports.createChannel() |
894 | 894 | root.ports.bind('first', portRef1) |
895 | | - root.ports.create('root', root.createMessage({ |
| 895 | + root.createInstance('root', root.createMessage({ |
896 | 896 | ports: [portRef2] |
897 | 897 | })) |
898 | 898 | |
899 | 899 | root.send(portRef1, root.createMessage()) |
914 | 914 | this.exInterface.send(port, m) |
915 | 915 | this.exInterface.ports.unbind('test1') |
916 | 916 | } else { |
917 | 917 | const [portRef1, portRef2] = this.exInterface.ports.createChannel() |
918 | | - this.exInterface.ports.create('sub', this.exInterface.createMessage({ |
| 918 | + this.exInterface.createInstance('sub', this.exInterface.createMessage({ |
919 | 919 | ports: [portRef2] |
920 | 920 | })) |
921 | 921 | this.exInterface.ports.bind('test1', portRef1) |
922 | 922 | |
923 | 923 | const [portRef3, portRef4] = this.exInterface.ports.createChannel() |
924 | | - this.exInterface.ports.create('sub', this.exInterface.createMessage({ |
| 924 | + this.exInterface.createInstance('sub', this.exInterface.createMessage({ |
925 | 925 | ports: [portRef4] |
926 | 926 | })) |
927 | 927 | this.exInterface.ports.bind('test2', portRef3) |
928 | 928 | this.exInterface.send(portRef3, this.exInterface.createMessage({ |
954 | 954 | |
955 | 955 | const root = await hypervisor.createInstance('root') |
956 | 956 | const [portRef1, portRef2] = root.ports.createChannel() |
957 | 957 | root.ports.bind('first', portRef1) |
958 | | - root.ports.create('root', root.createMessage({ |
| 958 | + root.createInstance('root', root.createMessage({ |
959 | 959 | ports: [portRef2] |
960 | 960 | })) |
961 | 961 | |
962 | 962 | root.send(portRef1, root.createMessage()) |
979 | 979 | this.exInterface.ports.unbind('test1') |
980 | 980 | this.exInterface.ports.unbind('test2') |
981 | 981 | } else { |
982 | 982 | const [portRef1, portRef2] = this.exInterface.ports.createChannel() |
983 | | - this.exInterface.ports.create('sub', this.exInterface.createMessage({ |
| 983 | + this.exInterface.createInstance('sub', this.exInterface.createMessage({ |
984 | 984 | ports: [portRef2] |
985 | 985 | })) |
986 | 986 | this.exInterface.ports.bind('test1', portRef1) |
987 | 987 | |
988 | 988 | const [portRef3, portRef4] = this.exInterface.ports.createChannel() |
989 | | - this.exInterface.ports.create('sub', this.exInterface.createMessage({ |
| 989 | + this.exInterface.createInstance('sub', this.exInterface.createMessage({ |
990 | 990 | ports: [portRef4] |
991 | 991 | })) |
992 | 992 | this.exInterface.ports.bind('test2', portRef3) |
993 | 993 | this.exInterface.send(portRef3, this.exInterface.createMessage({ |
1020 | 1020 | const root = await hypervisor.createInstance('root') |
1021 | 1021 | |
1022 | 1022 | const [portRef1, portRef2] = root.ports.createChannel() |
1023 | 1023 | root.ports.bind('first', portRef1) |
1024 | | - root.ports.create('root', root.createMessage({ |
| 1024 | + root.createInstance('root', root.createMessage({ |
1025 | 1025 | ports: [portRef2] |
1026 | 1026 | })) |
1027 | 1027 | |
1028 | 1028 | root.send(portRef1, root.createMessage()) |
1059 | 1059 | const initMessage = rootContainer.createMessage({ |
1060 | 1060 | ports: [portRef2] |
1061 | 1061 | }) |
1062 | 1062 | |
1063 | | - rootContainer.ports.create('test', initMessage) |
| 1063 | + rootContainer.createInstance('test', initMessage) |
1064 | 1064 | |
1065 | 1065 | rootContainer.ports.bind('first', portRef1) |
1066 | 1066 | const message = rootContainer.createMessage() |
1067 | 1067 | const rPort = rootContainer.getResponsePort(message) |