Commit dad0605968a7466f0c3307f31815166ff013d286
fix random test
wanderer committed on 4/21/2018, 2:00:32 AMParent: c74e7359bd1924e6814d6f8894e96e4fe4ed10b7
Files changed
actor.js | changed |
package-lock.json | changed |
tests/index.js | changed |
actor.js | ||
---|---|---|
@@ -97,12 +97,11 @@ | ||
97 | 97 | * @param {Object} portRef - the port |
98 | 98 | * @param {Message} message - the message |
99 | 99 | */ |
100 | 100 | send (message) { |
101 | - this.incrementTicks(message.funcRef.gas) | |
102 | - | |
103 | 101 | message._fromTicks = this.ticks |
104 | 102 | message._fromId = this.id |
105 | 103 | |
104 | + this.incrementTicks(message.funcRef.gas) | |
106 | 105 | this.hypervisor.scheduler.queue([message]) |
107 | 106 | } |
108 | 107 | } |
package-lock.json | ||
---|---|---|
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.js | ||
---|---|---|
@@ -541,9 +541,9 @@ | ||
541 | 541 | }) |
542 | 542 | |
543 | 543 | class testVMContainerA extends BaseContainer { |
544 | 544 | main (funcRef) { |
545 | - funcRef.gas = 100 | |
545 | + funcRef.gas = 10 | |
546 | 546 | const message = new Message({ |
547 | 547 | funcRef, |
548 | 548 | funcArguments: [2] |
549 | 549 | }) |
@@ -642,18 +642,19 @@ | ||
642 | 642 | const refs = [...arguments] |
643 | 643 | const ref = refs.pop() |
644 | 644 | const last = messageOrder[this.actor.id.id.toString('hex')] |
645 | 645 | const message = this.actor.currentMessage |
646 | - if (last) { | |
646 | + if (last !== undefined) { | |
647 | 647 | t.ok(last <= message._fromTicks, 'message should be in correct order') |
648 | 648 | } |
649 | 649 | messageOrder[this.actor.id.id.toString('hex')] = message._fromTicks |
650 | 650 | numOfMsg++ |
651 | 651 | |
652 | + this.actor.incrementTicks(10) | |
652 | 653 | if (ref) { |
653 | - const newRef = new FunctionRef({ ...ref, gas: message.funcRef.gas / 10 }) | |
654 | + ref.gas = this.actor.currentMessage.funcRef.gas | |
654 | 655 | this.actor.send(new Message({ |
655 | - funcRef: newRef, | |
656 | + funcRef: ref, | |
656 | 657 | funcArguments: refs |
657 | 658 | })) |
658 | 659 | } |
659 | 660 | } |
@@ -666,9 +667,8 @@ | ||
666 | 667 | let _numOfActors = numOfActors |
667 | 668 | while (_numOfActors--) { |
668 | 669 | const {module} = hypervisor.createActor(BenchmarkContainer.typeId) |
669 | 670 | const funcRef = module.getFuncRef('main') |
670 | - funcRef.gas = Math.pow(numOfActors, depth) | |
671 | 671 | references.push(funcRef) |
672 | 672 | } |
673 | 673 | _numOfActors = numOfActors |
674 | 674 | const msgs = [] |
@@ -676,14 +676,17 @@ | ||
676 | 676 | let _depth = depth |
677 | 677 | const funcArguments = [] |
678 | 678 | while (_depth--) { |
679 | 679 | const r = Math.floor(Math.random() * numOfActors) |
680 | - const ref = references[r] | |
680 | + const ref = references[r].copy() | |
681 | 681 | funcArguments.push(ref) |
682 | 682 | } |
683 | + const funcRef = references[_numOfActors] | |
684 | + funcRef.gas = 1000000 | |
685 | + | |
683 | 686 | const message = new Message({ |
684 | 687 | funcArguments, |
685 | - funcRef: references[_numOfActors] | |
688 | + funcRef | |
686 | 689 | }) |
687 | 690 | msgs.push(message) |
688 | 691 | } |
689 | 692 |
Built with git-ssb-web