|
@@ -1,11 +1,11 @@
|
1
|
1
|
const { describe } = require('tape-plus')
|
2
|
2
|
const Config = require('cobox-config')
|
3
|
3
|
const crypto = require('cobox-crypto')
|
4
|
|
-const Store = require('../')
|
|
4
|
+const Group = require('cobox-group')
|
|
5
|
+const Replicator = require('cobox-replicator')
|
5
|
6
|
|
|
7
|
+const Store = require('../')
|
6
|
8
|
const { tmp, cleanup } = require('./util')
|
7
|
|
-const Group = require('cobox-group/test/mock')
|
8
|
|
-const BlindReplicator = require('cobox-blind-replicator/test/mock')
|
9
|
9
|
|
10
|
10
|
describe('group store: basic', (context) => {
|
11
|
11
|
context('ready()', async function (assert, next) {
|
|
@@ -19,13 +19,9 @@ describe('group store: basic', (context) => {
|
19
|
19
|
const store = Store(storage, Group, { config })
|
20
|
20
|
store.seed(collection)
|
21
|
21
|
|
22
|
|
- try {
|
23
|
|
- await store.ready()
|
24
|
|
- assert.same(Object.values(store.collection).length, 1, 'builds then caches groups from the config')
|
25
|
|
- assert.ok(store.collection[params.address.toString('hex')], 'accessible using address hex string')
|
26
|
|
- } catch (err) {
|
27
|
|
- assert.error(err, 'no error')
|
28
|
|
- }
|
|
22
|
+ await store.ready()
|
|
23
|
+ assert.same(Object.values(store.collection).length, 1, 'builds then caches groups from the config')
|
|
24
|
+ assert.ok(store.collection[params.address.toString('hex')], 'accessible using address hex string')
|
29
|
25
|
|
30
|
26
|
cleanup(storage, next)
|
31
|
27
|
})
|
|
@@ -41,14 +37,10 @@ describe('group store: basic', (context) => {
|
41
|
37
|
const store = Store(storage, Group, { config })
|
42
|
38
|
store.seed(collection)
|
43
|
39
|
|
44
|
|
- try {
|
45
|
|
- await store.ready()
|
46
|
|
- var response = await store.all(params)
|
47
|
|
- assert.ok(Array.isArray(response), 'returns an array')
|
48
|
|
- assert.same(response.length, 1, 'returns the correct number')
|
49
|
|
- } catch (err) {
|
50
|
|
- assert.error(err, 'no error')
|
51
|
|
- }
|
|
40
|
+ await store.ready()
|
|
41
|
+ var response = await store.all(params)
|
|
42
|
+ assert.ok(Array.isArray(response), 'returns an array')
|
|
43
|
+ assert.same(response.length, 1, 'returns the correct number')
|
52
|
44
|
|
53
|
45
|
cleanup(storage, next)
|
54
|
46
|
})
|
|
@@ -65,20 +57,16 @@ describe('group store: basic', (context) => {
|
65
|
57
|
const store = Store(storage, Group, { config })
|
66
|
58
|
store.seed(collection)
|
67
|
59
|
|
68
|
|
- try {
|
69
|
|
- await store.ready()
|
70
|
|
- var response = await store.where({
|
71
|
|
- name: 'magma',
|
72
|
|
- address: params.address
|
73
|
|
- })
|
|
60
|
+ await store.ready()
|
|
61
|
+ var response = await store.where({
|
|
62
|
+ name: 'magma',
|
|
63
|
+ address: params.address
|
|
64
|
+ })
|
74
|
65
|
|
75
|
|
- assert.ok(Array.isArray(response), 'returns an array')
|
76
|
|
- var entry = response[0]
|
77
|
|
- assert.ok(entry, 'finds a entry')
|
78
|
|
- assert.same(entry && entry.address, params.address, 'finds the correct entry')
|
79
|
|
- } catch (err) {
|
80
|
|
- assert.error(err, 'no error')
|
81
|
|
- }
|
|
66
|
+ assert.ok(Array.isArray(response), 'returns an array')
|
|
67
|
+ var entry = response[0]
|
|
68
|
+ assert.ok(entry, 'finds a entry')
|
|
69
|
+ assert.same(entry && entry.address, params.address, 'finds the correct entry')
|
82
|
70
|
|
83
|
71
|
cleanup(storage, next)
|
84
|
72
|
|
|
@@ -330,7 +318,7 @@ describe('multiple', (context) => {
|
330
|
318
|
store: Store(storage, Group, { config })
|
331
|
319
|
},
|
332
|
320
|
replicators: {
|
333
|
|
- store: Store(storage, BlindReplicator, { config })
|
|
321
|
+ store: Store(storage, Replicator, { config })
|
334
|
322
|
}
|
335
|
323
|
}
|
336
|
324
|
|