Commit 1083d2c0b8a6bbe729c7484eea2f03a5b54da970
clean up tests
wanderer committed on 5/15/2017, 3:28:56 PMParent: 16503279a2722f474cd5b0d92906f32e9da38577
Files changed
tests/index.js | changed |
tests/index.js | ||
---|---|---|
@@ -22,9 +22,16 @@ | ||
22 | 22 | console.log(err) |
23 | 23 | }) |
24 | 24 | |
25 | 25 | node.on('start', () => { |
26 | + tape.onFinish(() => { | |
27 | + node.stop(() => { | |
28 | + process.exit() | |
29 | + }) | |
30 | + }) | |
31 | + | |
26 | 32 | tape('basic', async t => { |
33 | + t.plan(2) | |
27 | 34 | const message = new Message() |
28 | 35 | const expectedState = { |
29 | 36 | '/': 'zdpuAntkdU7yBJojcBT5Q9wBhrK56NmLnwpHPKaEGMFnAXpv7' |
30 | 37 | } |
@@ -44,12 +51,12 @@ | ||
44 | 51 | await rootContainer.send(port, message) |
45 | 52 | |
46 | 53 | const stateRoot = await hypervisor.createStateRoot(rootContainer, Infinity) |
47 | 54 | t.deepEquals(stateRoot, expectedState, 'expected root!') |
48 | - t.end() | |
49 | 55 | }) |
50 | 56 | |
51 | 57 | tape('one child contract', async t => { |
58 | + t.plan(4) | |
52 | 59 | let message = new Message() |
53 | 60 | const expectedState = { |
54 | 61 | '/': 'zdpuAofSzrBqwYs6z1r28fMeb8z5oSKF6CcWA6m22RqazgoTB' |
55 | 62 | } |
@@ -101,11 +108,8 @@ | ||
101 | 108 | root = await hypervisor.createInstance('test', stateRoot) |
102 | 109 | port = await root.ports.get('first') |
103 | 110 | |
104 | 111 | await root.send(port, message) |
105 | - await hypervisor.createStateRoot(root, Infinity) | |
106 | - | |
107 | - t.end() | |
108 | 112 | }) |
109 | 113 | |
110 | 114 | tape('ping pong', async t => { |
111 | 115 | class Ping extends BaseContainer { |
@@ -145,8 +149,9 @@ | ||
145 | 149 | t.end() |
146 | 150 | }) |
147 | 151 | |
148 | 152 | tape('queing multiple messages', async t => { |
153 | + t.plan(2) | |
149 | 154 | let runs = 0 |
150 | 155 | |
151 | 156 | class Root extends BaseContainer { |
152 | 157 | async run (m) { |
@@ -190,13 +195,12 @@ | ||
190 | 195 | |
191 | 196 | t.equals(runs, 3, 'the number of run should be 3') |
192 | 197 | const nonce = await hypervisor.graph.get(root.state, 'ports/first/link/nonce/0') |
193 | 198 | t.equals(nonce, 3, 'should have the correct nonce') |
194 | - | |
195 | - t.end() | |
196 | 199 | }) |
197 | 200 | |
198 | 201 | tape('traps', async t => { |
202 | + t.plan(1) | |
199 | 203 | class Root extends BaseContainer { |
200 | 204 | async run (m) { |
201 | 205 | await Promise.all([ |
202 | 206 | this.kernel.ports.create('root', 'one'), |
@@ -221,10 +225,8 @@ | ||
221 | 225 | nonce: [0], |
222 | 226 | ports: {} |
223 | 227 | } |
224 | 228 | }, 'should revert the state') |
225 | - | |
226 | - t.end() | |
227 | 229 | }) |
228 | 230 | |
229 | 231 | tape('message should arrive in the correct oder if sent in order', async t => { |
230 | 232 | t.plan(2) |
@@ -550,8 +552,9 @@ | ||
550 | 552 | await root.send(port, new Message()) |
551 | 553 | }) |
552 | 554 | |
553 | 555 | tape('should order parent messages correctly', async t => { |
556 | + t.plan(1) | |
554 | 557 | class Middle extends BaseContainer { |
555 | 558 | async run (m) { |
556 | 559 | if (!this.runs) { |
557 | 560 | this.runs = 1 |
@@ -590,12 +593,7 @@ | ||
590 | 593 | const port = await root.ports.create('middle', 'first') |
591 | 594 | |
592 | 595 | await root.send(port, new Message()) |
593 | 596 | await root.send(port, new Message()) |
594 | - await root.wait(Infinity) | |
595 | - | |
596 | - t.end() | |
597 | - node.stop(() => { | |
598 | - process.exit() | |
599 | - }) | |
600 | 597 | }) |
601 | 598 | }) |
599 | + |
Built with git-ssb-web