git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit dad0605968a7466f0c3307f31815166ff013d286

fix random test

wanderer committed on 4/21/2018, 2:00:32 AM
Parent: c74e7359bd1924e6814d6f8894e96e4fe4ed10b7

Files changed

actor.jschanged
package-lock.jsonchanged
tests/index.jschanged
actor.jsView
@@ -97,12 +97,11 @@
9797 * @param {Object} portRef - the port
9898 * @param {Message} message - the message
9999 */
100100 send (message) {
101- this.incrementTicks(message.funcRef.gas)
102-
103101 message._fromTicks = this.ticks
104102 message._fromId = this.id
105103
104+ this.incrementTicks(message.funcRef.gas)
106105 this.hypervisor.scheduler.queue([message])
107106 }
108107 }
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 365090 bytes
New file size: 365090 bytes
tests/index.jsView
@@ -541,9 +541,9 @@
541541 })
542542
543543 class testVMContainerA extends BaseContainer {
544544 main (funcRef) {
545- funcRef.gas = 100
545+ funcRef.gas = 10
546546 const message = new Message({
547547 funcRef,
548548 funcArguments: [2]
549549 })
@@ -642,18 +642,19 @@
642642 const refs = [...arguments]
643643 const ref = refs.pop()
644644 const last = messageOrder[this.actor.id.id.toString('hex')]
645645 const message = this.actor.currentMessage
646- if (last) {
646+ if (last !== undefined) {
647647 t.ok(last <= message._fromTicks, 'message should be in correct order')
648648 }
649649 messageOrder[this.actor.id.id.toString('hex')] = message._fromTicks
650650 numOfMsg++
651651
652+ this.actor.incrementTicks(10)
652653 if (ref) {
653- const newRef = new FunctionRef({ ...ref, gas: message.funcRef.gas / 10 })
654+ ref.gas = this.actor.currentMessage.funcRef.gas
654655 this.actor.send(new Message({
655- funcRef: newRef,
656+ funcRef: ref,
656657 funcArguments: refs
657658 }))
658659 }
659660 }
@@ -666,9 +667,8 @@
666667 let _numOfActors = numOfActors
667668 while (_numOfActors--) {
668669 const {module} = hypervisor.createActor(BenchmarkContainer.typeId)
669670 const funcRef = module.getFuncRef('main')
670- funcRef.gas = Math.pow(numOfActors, depth)
671671 references.push(funcRef)
672672 }
673673 _numOfActors = numOfActors
674674 const msgs = []
@@ -676,14 +676,17 @@
676676 let _depth = depth
677677 const funcArguments = []
678678 while (_depth--) {
679679 const r = Math.floor(Math.random() * numOfActors)
680- const ref = references[r]
680+ const ref = references[r].copy()
681681 funcArguments.push(ref)
682682 }
683+ const funcRef = references[_numOfActors]
684+ funcRef.gas = 1000000
685+
683686 const message = new Message({
684687 funcArguments,
685- funcRef: references[_numOfActors]
688+ funcRef
686689 })
687690 msgs.push(message)
688691 }
689692

Built with git-ssb-web