git ssb

0+

wanderer🌟 / js-primea-hypervisor



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.jschanged
tests/index.jsView
@@ -238,13 +238,13 @@
238238 const [portRef1] = this.kernel.ports.createChannel()
239239 const [portRef3] = this.kernel.ports.createChannel()
240240 const [portRef5] = this.kernel.ports.createChannel()
241241
242- await Promise.all(
242 + await Promise.all([
243243 this.kernel.ports.bind('one', portRef1),
244244 this.kernel.ports.bind('two', portRef3),
245245 this.kernel.ports.bind('three', portRef5)
246- )
246 + ])
247247
248248 throw new Error('it is a trap!!!')
249249 }
250250 }
@@ -309,14 +309,11 @@
309309 ])
310310 } else if (runs === 1) {
311311 runs++
312312 t.equals(m.data, 'first', 'should recive the first message')
313- } else if (runs === 2) {
313 + } else {
314314 runs++
315315 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')
319316 }
320317 }
321318 static get typeId () {
322319 return 299
@@ -423,9 +420,9 @@
423420 t.equals(m.data, 'first', 'should recive the first message')
424421 } else if (runs === 2) {
425422 runs++
426423 t.equals(m.data, 'second', 'should recive the second message')
427- } else if (runs === 3) {
424 + } else {
428425 runs++
429426 t.equals(m.data, 'third', 'should recived the third message')
430427 }
431428 }
@@ -795,19 +792,8 @@
795792 }
796793 }
797794
798795 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- }
810796 static get typeId () {
811797 return 299
812798 }
813799 }
@@ -892,9 +878,9 @@
892878 data: 'bindPort',
893879 ports: [ports[1]]
894880 }))
895881 return this.kernel.ports.bind('channel', ports[0])
896- } else if (message.data === 'bindPort') {
882 + } else {
897883 return this.kernel.ports.bind('channel', message.ports[0])
898884 }
899885 }
900886 static get typeId () {
@@ -985,52 +971,48 @@
985971 data: 'bindPort',
986972 ports: [ports[1]]
987973 }))
988974 return this.kernel.ports.bind('channel', ports[0])
989- } else if (message.data === 'bindPort') {
975 + } else {
990976 return this.kernel.ports.bind('channel', message.ports[0])
991977 }
992978 }
993979 static get typeId () {
994980 return 299
995981 }
996982 }
997983
998- try {
999- hypervisor.registerContainer(Root)
1000- hypervisor.registerContainer(Sub)
984 + hypervisor.registerContainer(Root)
985 + hypervisor.registerContainer(Sub)
1001986
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({
10031000 data: {
10041001 type: Root.typeId
1005- }
1006- }))
1002 + },
1003 + ports: [portRef2]
1004 + })),
1005 + root.send(portRef1, root.createMessage())
1006 + ])
10071007
1008- root = await hypervisor.getInstance(root.id)
1009- hypervisor.pin(root)
1008 + root.shutdown()
10101009
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()
10221011
1023- root.shutdown()
1012 + t.deepEquals(sr, expectedSr, 'should produce the corret state root')
10241013
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()
10331015 })
10341016
10351017 tape('response ports', async t => {
10361018 t.plan(2)
@@ -1093,11 +1075,10 @@
10931075 db: db
10941076 })
10951077
10961078 class testVMContainer extends BaseContainer {
1097- onMessage () {}
10981079 onStartup () {
1099- t.true(true, 'should start up')
1080 + t.pass('should start up')
11001081 }
11011082 }
11021083
11031084 const hypervisor = new Hypervisor(tree)
@@ -1116,11 +1097,9 @@
11161097 const tree = new RadixTree({
11171098 db: db
11181099 })
11191100 const content = Buffer.from(new ArrayBuffer(1e6))
1120- class testVMContainer extends BaseContainer {
1121- onMessage () {}
1122- }
1101 + class testVMContainer extends BaseContainer {}
11231102
11241103 const hypervisor = new Hypervisor(tree)
11251104 const creationPort = hypervisor.creationService.getPort()
11261105 hypervisor.registerContainer(testVMContainer)

Built with git-ssb-web