git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 818c7e2b325f1dac05933b54857443ddadc56c93

updated deps

wanderer committed on 12/21/2017, 4:00:10 AM
Parent: 783d84ab7ec65979b1dad49a2e84dd41de2a555d

Files changed

actor.jschanged
inbox.jschanged
package-lock.jsonchanged
package.jsonchanged
tests/index.jschanged
actor.jsView
@@ -56,9 +56,8 @@
5656 * @returns {Promise}
5757 */
5858 create (message) {
5959 this.running = true
60- this.inbox.currentMessage = message
6160 return this.runMessage(message, 'onCreation').then(() => {
6261 this._startMessageLoop()
6362 })
6463 }
@@ -123,24 +122,13 @@
123122 * @param {String} method - which method to run
124123 * @returns {Promise}
125124 */
126125 async runMessage (message, method = 'onMessage') {
127- let result
128126 try {
129- result = await this.container[method](message)
127+ await this.container[method](message)
130128 } catch (e) {
131129 message.emit('execution:error', e)
132- result = {
133- exception: true,
134- exceptionError: e
135- }
136130 }
137-
138- if (message.responseCap) {
139- this.send(message.responseCap, new Message({
140- data: result
141- }))
142- }
143131 }
144132
145133 /**
146134 * updates the number of ticks that the actor has run
inbox.jsView
@@ -122,10 +122,9 @@
122122 })
123123 ])
124124 oldestTime = this.hypervisor.scheduler.leastNumberOfTicks(this.actor.id)
125125 }
126- this.currentMessage = this._deQueueMessage()
127- return this.currentMessage
126+ return this._deQueueMessage()
128127 }
129128
130129 // returns a promise that resolve when a message older then the given message
131130 // is recived
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 345851 bytes
New file size: 342236 bytes
package.jsonView
@@ -31,9 +31,9 @@
3131 "contributors": "Alex Beregszaszi <alex@rtfs.hu>",
3232 "license": "MPL-2.0",
3333 "dependencies": {
3434 "binary-search-insert": "^1.0.3",
35- "buffer-pipe": "0.0.1",
35+ "buffer-pipe": "0.0.2",
3636 "leb128": "0.0.4",
3737 "primea-capability": "0.0.1",
3838 "primea-message": "0.6.1",
3939 "safe-buffer": "^5.1.1",
@@ -44,9 +44,9 @@
4444 "coveralls": "^3.0.0",
4545 "dfinity-radix-tree": "0.0.9",
4646 "documentation": "^5.3.5",
4747 "level-browserify": "^1.1.1",
48- "nyc": "^11.3.0",
48+ "nyc": "^11.4.1",
4949 "primea-abstract-container": "0.0.6",
5050 "standard": "10.0.3",
5151 "tape": "^4.6.3"
5252 }
tests/index.jsView
@@ -178,9 +178,9 @@
178178
179179 t.deepEquals(stateRoot, expectedState, 'expected root!')
180180 })
181181
182-tape('response caps', async t => {
182+tape('errors', async t => {
183183 t.plan(3)
184184 let message
185185 const expectedState = {
186186 '/': Buffer.from('a4c7ceacd8c867ae1d0b472d8bffa3cb10048331', 'hex')
@@ -192,67 +192,18 @@
192192
193193 class testVMContainerA extends BaseContainer {
194194 onCreation (m) {
195195 message = new Message()
196- message.responseCap = this.actor.mintCap()
196+ message.on('execution:error', () => {
197+ t.pass('should recive a exeption')
198+ })
197199 this.actor.send(m.caps[0], message)
198200 }
199-
200- onMessage (m) {
201- t.true(m, 'should recive a response message')
202- }
203201 }
204202
205203 class testVMContainerB extends BaseContainer {
206204 onMessage (m) {
207205 t.true(m === message, 'should recive a message')
208- }
209-
210- static get typeId () {
211- return 8
212- }
213- }
214-
215- const hypervisor = new Hypervisor(tree)
216- hypervisor.registerContainer(testVMContainerA)
217- hypervisor.registerContainer(testVMContainerB)
218-
219- let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
220- await hypervisor.createActor(testVMContainerA.typeId, new Message({
221- caps: [capB]
222- }))
223-
224- const stateRoot = await hypervisor.createStateRoot()
225-
226- t.deepEquals(stateRoot, expectedState, 'expected root!')
227-})
228-
229-tape('response caps for errors', async t => {
230- t.plan(3)
231- let message
232- const expectedState = {
233- '/': Buffer.from('a4c7ceacd8c867ae1d0b472d8bffa3cb10048331', 'hex')
234- }
235-
236- const tree = new RadixTree({
237- db: db
238- })
239-
240- class testVMContainerA extends BaseContainer {
241- onCreation (m) {
242- message = new Message()
243- message.responseCap = this.actor.mintCap()
244- this.actor.send(m.caps[0], message)
245- }
246-
247- onMessage (m) {
248- t.true(m.data.exceptionError instanceof Error, 'should recive a response message')
249- }
250- }
251-
252- class testVMContainerB extends BaseContainer {
253- onMessage (m) {
254- t.true(m === message, 'should recive a message')
255206 throw new Error('test error')
256207 }
257208
258209 static get typeId () {
@@ -454,10 +405,9 @@
454405 class testVMContainerA extends BaseContainer {
455406 async onMessage (m) {
456407 t.true(m, 'should recive first message')
457408 const rCap = this.actor.mintCap(1)
458- const message = new Message()
459- message.responseCap = rCap
409+ const message = new Message({caps: [rCap]})
460410 this.actor.send(m.caps[0], message)
461411 const rMessage = await this.actor.inbox.nextTaggedMessage([1], 44)
462412 t.true(rMessage, 'should recive a response message')
463413 }
@@ -465,8 +415,9 @@
465415
466416 class testVMContainerB extends BaseContainer {
467417 onMessage (m) {
468418 t.true(m, 'should recive a message')
419+ this.actor.send(m.caps[0], new Message())
469420 }
470421
471422 static get typeId () {
472423 return 8
@@ -502,10 +453,9 @@
502453 t.true(m, 'should recive second message')
503454 } else {
504455 t.true(m, 'should recive first message')
505456 const rCap = this.actor.mintCap(1)
506- const message = new Message()
507- message.responseCap = rCap
457+ const message = new Message({caps: [rCap]})
508458 this.actor.send(m.caps[0], message)
509459 this.actor.inbox.nextTaggedMessage([1], 44)
510460 }
511461 }
@@ -513,8 +463,9 @@
513463
514464 class testVMContainerB extends BaseContainer {
515465 onMessage (m) {
516466 t.true(m, 'should recive a message')
467+ this.actor.send(m.caps[0], new Message())
517468 }
518469
519470 static get typeId () {
520471 return 8
@@ -548,9 +499,8 @@
548499 async onMessage (m) {
549500 t.true(m, 'should recive first message')
550501 const rCap = this.actor.mintCap(1)
551502 const message = new Message({data: 'first'})
552- message.responseCap = rCap
553503 this.actor.send(m.caps[0], message)
554504 const promise = this.actor.inbox.nextTaggedMessage([1], 44)
555505 try {
556506 await this.actor.inbox.nextTaggedMessage([1], 44)

Built with git-ssb-web