git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit eacc6aefd1d880bdcfc1c451260d67651c742adb

fixred reloading ports

wanderer committed on 4/28/2017, 5:55:19 PM
Parent: ca80f013bf0ad297f4a0e0ab0c5a57b5c3b84034

Files changed

kernel.jschanged
portManager.jschanged
tests/index.jschanged
kernel.jsView
@@ -106,25 +106,25 @@
106106 const nonce = new BN(this.state.nonce)
107107 nonce.iaddn(1)
108108 this.state.nonce = nonce.toArray()
109109
110- let port = this._opts.hypervisor.createPort(type, {
110+ let portRef = this._opts.hypervisor.createPort(type, {
111111 nonce: this.state.nonce,
112112 parent: this._opts.parentPort.id
113113 })
114- await manager.set(name, port)
115- return port
114+ await manager.set(name, portRef)
115+ return portRef
116116 }
117117
118118 getPort (manager, name) {
119- return manager.get(name)
119+ return manager.getRef(name)
120120 }
121121
122- async send (port, message) {
122+ async send (portRef, message) {
123123 message._ticks = this.ticks
124- const portObject = await this.ports.get(port)
125- portObject.hasSent = true
126- return this._opts.hypervisor.send(port, message)
124+ const portInstance = await this.ports.get(portRef)
125+ portInstance.hasSent = true
126+ return this._opts.hypervisor.send(portRef, message)
127127 }
128128 }
129129
130130 function clearObject (myObject) {
portManager.jsView
@@ -64,8 +64,12 @@
6464 const id = await this.hypervisor.generateID(port)
6565 return this._portMap.get(id)
6666 }
6767
68+ getRef (key) {
69+ return this.ports[key]
70+ }
71+
6872 // waits till all ports have reached a threshold tick count
6973 async wait (threshold) {
7074 // find the ports that have a smaller tick count then the threshold tick count
7175 const unkownPorts = [...this._portMap].filter(([id, port]) => {
tests/index.jsView
@@ -81,28 +81,24 @@
8181 await hypervisor.createStateRoot(port, Infinity)
8282 t.true(hasResolved, 'should resolve before generating the state root')
8383 t.deepEquals(port, expectedState, 'expected state')
8484
85+ // test reviving the state
8586 class testVMContainer3 extends BaseContainer {
8687 async run (m) {
87- console.log('here!!')
88- const port = await this.kernel.getPort(this.kernel.ports, 'child')
88+ const port = this.kernel.getPort(this.kernel.ports, 'child')
8989 await this.kernel.send(port, m)
9090 this.kernel.incrementTicks(1)
9191 }
9292 }
9393
9494 hypervisor.addVM('test', testVMContainer3)
9595
9696 // revive ports
97- try {
98- message = new Message()
99- await hypervisor.graph.tree(expectedState, 1)
100- console.log(expectedState)
101- await hypervisor.send(expectedState['/'], message)
102- } catch (e) {
103- console.log(e)
104- }
97+ message = new Message()
98+ await hypervisor.graph.tree(expectedState, 1)
99+ await hypervisor.send(expectedState['/'], message)
100+ await hypervisor.createStateRoot(expectedState['/'], Infinity)
105101
106102 t.end()
107103 node.stop(() => {
108104 process.exit()

Built with git-ssb-web