git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 1083d2c0b8a6bbe729c7484eea2f03a5b54da970

clean up tests

wanderer committed on 5/15/2017, 3:28:56 PM
Parent: 16503279a2722f474cd5b0d92906f32e9da38577

Files changed

tests/index.jschanged
tests/index.jsView
@@ -22,9 +22,16 @@
2222 console.log(err)
2323 })
2424
2525 node.on('start', () => {
26+ tape.onFinish(() => {
27+ node.stop(() => {
28+ process.exit()
29+ })
30+ })
31+
2632 tape('basic', async t => {
33+ t.plan(2)
2734 const message = new Message()
2835 const expectedState = {
2936 '/': 'zdpuAntkdU7yBJojcBT5Q9wBhrK56NmLnwpHPKaEGMFnAXpv7'
3037 }
@@ -44,12 +51,12 @@
4451 await rootContainer.send(port, message)
4552
4653 const stateRoot = await hypervisor.createStateRoot(rootContainer, Infinity)
4754 t.deepEquals(stateRoot, expectedState, 'expected root!')
48- t.end()
4955 })
5056
5157 tape('one child contract', async t => {
58+ t.plan(4)
5259 let message = new Message()
5360 const expectedState = {
5461 '/': 'zdpuAofSzrBqwYs6z1r28fMeb8z5oSKF6CcWA6m22RqazgoTB'
5562 }
@@ -101,11 +108,8 @@
101108 root = await hypervisor.createInstance('test', stateRoot)
102109 port = await root.ports.get('first')
103110
104111 await root.send(port, message)
105- await hypervisor.createStateRoot(root, Infinity)
106-
107- t.end()
108112 })
109113
110114 tape('ping pong', async t => {
111115 class Ping extends BaseContainer {
@@ -145,8 +149,9 @@
145149 t.end()
146150 })
147151
148152 tape('queing multiple messages', async t => {
153+ t.plan(2)
149154 let runs = 0
150155
151156 class Root extends BaseContainer {
152157 async run (m) {
@@ -190,13 +195,12 @@
190195
191196 t.equals(runs, 3, 'the number of run should be 3')
192197 const nonce = await hypervisor.graph.get(root.state, 'ports/first/link/nonce/0')
193198 t.equals(nonce, 3, 'should have the correct nonce')
194-
195- t.end()
196199 })
197200
198201 tape('traps', async t => {
202+ t.plan(1)
199203 class Root extends BaseContainer {
200204 async run (m) {
201205 await Promise.all([
202206 this.kernel.ports.create('root', 'one'),
@@ -221,10 +225,8 @@
221225 nonce: [0],
222226 ports: {}
223227 }
224228 }, 'should revert the state')
225-
226- t.end()
227229 })
228230
229231 tape('message should arrive in the correct oder if sent in order', async t => {
230232 t.plan(2)
@@ -550,8 +552,9 @@
550552 await root.send(port, new Message())
551553 })
552554
553555 tape('should order parent messages correctly', async t => {
556+ t.plan(1)
554557 class Middle extends BaseContainer {
555558 async run (m) {
556559 if (!this.runs) {
557560 this.runs = 1
@@ -590,12 +593,7 @@
590593 const port = await root.ports.create('middle', 'first')
591594
592595 await root.send(port, new Message())
593596 await root.send(port, new Message())
594- await root.wait(Infinity)
595-
596- t.end()
597- node.stop(() => {
598- process.exit()
599- })
600597 })
601598 })
599+

Built with git-ssb-web