|
@@ -9,16 +9,39 @@ describe('basic', (context) => {
|
9
|
9
|
context('inherits from cobox-group-base', async (assert, next) => {
|
10
|
10
|
var storage = tmp()
|
11
|
11
|
var address = crypto.address()
|
12
|
|
- var group = BlindReplictor(storage, address)
|
13
|
|
- assert.ok(group.config, 'has a config')
|
14
|
|
- assert.ok(group.address, 'group created')
|
15
|
|
- assert.ok(Buffer.isBuffer(group.address), 'address is a buffer')
|
16
|
|
- assert.same(group.path, path.join(storage, address.toString('hex')))
|
17
|
|
- assert.ok(group.storage, 'has random access file storage')
|
18
|
|
- assert.ok(group.multifeed, 'has a multifeed instance')
|
19
|
|
- assert.ok(typeof group.replicate === 'function', 'has a replicate function')
|
20
|
|
-
|
21
|
|
- await group.ready()
|
|
12
|
+ var replicator = BlindReplictor(storage, address)
|
|
13
|
+ assert.ok(replicator.config, 'has a config')
|
|
14
|
+ assert.ok(replicator.address, 'replicator created')
|
|
15
|
+ assert.ok(Buffer.isBuffer(replicator.address), 'address is a buffer')
|
|
16
|
+ assert.same(replicator.path, path.join(storage, address.toString('hex')))
|
|
17
|
+ assert.ok(replicator.storage, 'has random access file storage')
|
|
18
|
+ assert.ok(replicator.multifeed, 'has a multifeed instance')
|
|
19
|
+ assert.ok(typeof replicator.replicate === 'function', 'has a replicate function')
|
|
20
|
+
|
|
21
|
+ await replicator.ready()
|
|
22
|
+
|
|
23
|
+ cleanup(storage, next)
|
|
24
|
+ })
|
|
25
|
+
|
|
26
|
+ context('swarm', async (assert, next) => {
|
|
27
|
+ var storage = tmp()
|
|
28
|
+ var address = crypto.address()
|
|
29
|
+ var replicator = BlindReplictor(storage, address)
|
|
30
|
+
|
|
31
|
+ assert.ok(typeof replicator.swarm === 'function', 'has a swarm function')
|
|
32
|
+ assert.ok(typeof replicator.unswarm === 'function', 'has an unswarm function')
|
|
33
|
+ assert.ok(replicator._connection === null, 'connection starts as null')
|
|
34
|
+
|
|
35
|
+ await replicator.ready()
|
|
36
|
+ replicator.swarm()
|
|
37
|
+
|
|
38
|
+ assert.ok(replicator._connection, 'caches a swarm connection')
|
|
39
|
+ assert.ok(replicator._isSwarming, 'stores isSwarming')
|
|
40
|
+
|
|
41
|
+ replicator.unswarm()
|
|
42
|
+
|
|
43
|
+ assert.notOk(replicator._connection, 'destroys the connection')
|
|
44
|
+ asser.notOk(repicator._isSwarming, 'stops swarming')
|
22
|
45
|
|
23
|
46
|
cleanup(storage, next)
|
24
|
47
|
})
|