Commit a2a7de1d43a86acb71ef0daf7d432510e659282d
clean up
Signed-off-by: wanderer <mjbecze@gmail.com>wanderer committed on 10/10/2017, 4:03:25 AM
Parent: a0c04bdafa14ebe4eecafb19828b204564ec9a90
Files changed
tests/index.js | changed |
tests/index.js | ||
---|---|---|
@@ -238,13 +238,13 @@ | ||
238 | 238 … | const [portRef1] = this.kernel.ports.createChannel() |
239 | 239 … | const [portRef3] = this.kernel.ports.createChannel() |
240 | 240 … | const [portRef5] = this.kernel.ports.createChannel() |
241 | 241 … | |
242 | - await Promise.all( | |
242 … | + await Promise.all([ | |
243 | 243 … | this.kernel.ports.bind('one', portRef1), |
244 | 244 … | this.kernel.ports.bind('two', portRef3), |
245 | 245 … | this.kernel.ports.bind('three', portRef5) |
246 | - ) | |
246 … | + ]) | |
247 | 247 … | |
248 | 248 … | throw new Error('it is a trap!!!') |
249 | 249 … | } |
250 | 250 … | } |
@@ -309,14 +309,11 @@ | ||
309 | 309 … | ]) |
310 | 310 … | } else if (runs === 1) { |
311 | 311 … | runs++ |
312 | 312 … | t.equals(m.data, 'first', 'should recive the first message') |
313 | - } else if (runs === 2) { | |
313 … | + } else { | |
314 | 314 … | runs++ |
315 | 315 … | t.equals(m.data, 'second', 'should recive the second message') |
316 | - } else if (runs === 3) { | |
317 | - runs++ | |
318 | - // t.equals(m.data, 'third', 'should recived the second message') | |
319 | 316 … | } |
320 | 317 … | } |
321 | 318 … | static get typeId () { |
322 | 319 … | return 299 |
@@ -423,9 +420,9 @@ | ||
423 | 420 … | t.equals(m.data, 'first', 'should recive the first message') |
424 | 421 … | } else if (runs === 2) { |
425 | 422 … | runs++ |
426 | 423 … | t.equals(m.data, 'second', 'should recive the second message') |
427 | - } else if (runs === 3) { | |
424 … | + } else { | |
428 | 425 … | runs++ |
429 | 426 … | t.equals(m.data, 'third', 'should recived the third message') |
430 | 427 … | } |
431 | 428 … | } |
@@ -795,19 +792,8 @@ | ||
795 | 792 … | } |
796 | 793 … | } |
797 | 794 … | |
798 | 795 … | class Sub extends BaseContainer { |
799 | - async onInitailize (message) { | |
800 | - await this.kernel.ports.bind('root', message.ports[0]) | |
801 | - const [portRef1, portRef2] = this.kernel.ports.createChannel() | |
802 | - await this.kernel.ports.bind('child', portRef1) | |
803 | - await this.kernel.send(creationPort, this.kernel.createMessage({ | |
804 | - data: { | |
805 | - type: Root.typeId | |
806 | - }, | |
807 | - ports: [portRef2] | |
808 | - })) | |
809 | - } | |
810 | 796 … | static get typeId () { |
811 | 797 … | return 299 |
812 | 798 … | } |
813 | 799 … | } |
@@ -892,9 +878,9 @@ | ||
892 | 878 … | data: 'bindPort', |
893 | 879 … | ports: [ports[1]] |
894 | 880 … | })) |
895 | 881 … | return this.kernel.ports.bind('channel', ports[0]) |
896 | - } else if (message.data === 'bindPort') { | |
882 … | + } else { | |
897 | 883 … | return this.kernel.ports.bind('channel', message.ports[0]) |
898 | 884 … | } |
899 | 885 … | } |
900 | 886 … | static get typeId () { |
@@ -985,52 +971,48 @@ | ||
985 | 971 … | data: 'bindPort', |
986 | 972 … | ports: [ports[1]] |
987 | 973 … | })) |
988 | 974 … | return this.kernel.ports.bind('channel', ports[0]) |
989 | - } else if (message.data === 'bindPort') { | |
975 … | + } else { | |
990 | 976 … | return this.kernel.ports.bind('channel', message.ports[0]) |
991 | 977 … | } |
992 | 978 … | } |
993 | 979 … | static get typeId () { |
994 | 980 … | return 299 |
995 | 981 … | } |
996 | 982 … | } |
997 | 983 … | |
998 | - try { | |
999 | - hypervisor.registerContainer(Root) | |
1000 | - hypervisor.registerContainer(Sub) | |
984 … | + hypervisor.registerContainer(Root) | |
985 … | + hypervisor.registerContainer(Sub) | |
1001 | 986 … | |
1002 | - let root = await hypervisor.send(creationPort, new Message({ | |
987 … | + let root = await hypervisor.send(creationPort, new Message({ | |
988 … | + data: { | |
989 … | + type: Root.typeId | |
990 … | + } | |
991 … | + })) | |
992 … | + | |
993 … | + root = await hypervisor.getInstance(root.id) | |
994 … | + hypervisor.pin(root) | |
995 … | + | |
996 … | + const [portRef1, portRef2] = root.ports.createChannel() | |
997 … | + await Promise.all([ | |
998 … | + root.ports.bind('first', portRef1), | |
999 … | + root.send(creationPort, root.createMessage({ | |
1003 | 1000 … | data: { |
1004 | 1001 … | type: Root.typeId |
1005 | - } | |
1006 | - })) | |
1002 … | + }, | |
1003 … | + ports: [portRef2] | |
1004 … | + })), | |
1005 … | + root.send(portRef1, root.createMessage()) | |
1006 … | + ]) | |
1007 | 1007 … | |
1008 | - root = await hypervisor.getInstance(root.id) | |
1009 | - hypervisor.pin(root) | |
1008 … | + root.shutdown() | |
1010 | 1009 … | |
1011 | - const [portRef1, portRef2] = root.ports.createChannel() | |
1012 | - await Promise.all([ | |
1013 | - root.ports.bind('first', portRef1), | |
1014 | - root.send(creationPort, root.createMessage({ | |
1015 | - data: { | |
1016 | - type: Root.typeId | |
1017 | - }, | |
1018 | - ports: [portRef2] | |
1019 | - })), | |
1020 | - root.send(portRef1, root.createMessage()) | |
1021 | - ]) | |
1010 … | + const sr = await hypervisor.createStateRoot() | |
1022 | 1011 … | |
1023 | - root.shutdown() | |
1012 … | + t.deepEquals(sr, expectedSr, 'should produce the corret state root') | |
1024 | 1013 … | |
1025 | - const sr = await hypervisor.createStateRoot() | |
1026 | - | |
1027 | - t.deepEquals(sr, expectedSr, 'should produce the corret state root') | |
1028 | - | |
1029 | - t.end() | |
1030 | - } catch (e) { | |
1031 | - console.log(e) | |
1032 | - } | |
1014 … | + t.end() | |
1033 | 1015 … | }) |
1034 | 1016 … | |
1035 | 1017 … | tape('response ports', async t => { |
1036 | 1018 … | t.plan(2) |
@@ -1093,11 +1075,10 @@ | ||
1093 | 1075 … | db: db |
1094 | 1076 … | }) |
1095 | 1077 … | |
1096 | 1078 … | class testVMContainer extends BaseContainer { |
1097 | - onMessage () {} | |
1098 | 1079 … | onStartup () { |
1099 | - t.true(true, 'should start up') | |
1080 … | + t.pass('should start up') | |
1100 | 1081 … | } |
1101 | 1082 … | } |
1102 | 1083 … | |
1103 | 1084 … | const hypervisor = new Hypervisor(tree) |
@@ -1116,11 +1097,9 @@ | ||
1116 | 1097 … | const tree = new RadixTree({ |
1117 | 1098 … | db: db |
1118 | 1099 … | }) |
1119 | 1100 … | const content = Buffer.from(new ArrayBuffer(1e6)) |
1120 | - class testVMContainer extends BaseContainer { | |
1121 | - onMessage () {} | |
1122 | - } | |
1101 … | + class testVMContainer extends BaseContainer {} | |
1123 | 1102 … | |
1124 | 1103 … | const hypervisor = new Hypervisor(tree) |
1125 | 1104 … | const creationPort = hypervisor.creationService.getPort() |
1126 | 1105 … | hypervisor.registerContainer(testVMContainer) |
Built with git-ssb-web