@@ -10,67 +10,68 @@ const DefaultOptions = Store.DefaultOptions
10
10
11
11
// Test utils
12
12
const {
13
- config,
14
- testAPIs,
15
- startIpfs,
16
- stopIpfs,
17
- implementations
13
+ config,
14
+ testAPIs,
15
+ startIpfs,
16
+ stopIpfs,
17
+ implementations
18
18
} = require ( 'orbit-db-test-utils' )
19
19
20
20
const properLevelModule = implementations . filter ( i => i . key . indexOf ( 'memdown' ) > - 1 ) . map ( i => i . module ) [ 0 ]
21
21
const storage = require ( 'orbit-db-storage-adapter' ) ( properLevelModule )
22
22
23
23
Object . keys ( testAPIs ) . forEach ( ( IPFS ) => {
24
- describe ( `Events ${ IPFS } ` , function ( ) {
25
- let ipfs , testIdentity , identityStore , store , cacheStore
24
+ describe ( `Events ${ IPFS } ` , function ( ) {
25
+ let ipfsd , ipfs , testIdentity , identityStore , store , cacheStore
26
26
27
- this . timeout ( config . timeout )
27
+ this . timeout ( config . timeout )
28
28
29
- const ipfsConfig = Object . assign ( { } , config . defaultIpfsConfig , {
30
- repo : config . defaultIpfsConfig . repo + '-entry' + new Date ( ) . getTime ( )
31
- } )
32
- after ( async ( ) => {
33
- await store . close ( )
34
- await stopIpfs ( ipfs )
35
- await identityStore . close ( )
36
- await cacheStore . close ( )
37
- } )
29
+ const ipfsConfig = Object . assign ( { } , config . defaultIpfsConfig , {
30
+ repo : config . defaultIpfsConfig . repo + '-entry' + new Date ( ) . getTime ( )
31
+ } )
32
+ after ( async ( ) => {
33
+ await store . close ( )
34
+ await stopIpfs ( ipfsd )
35
+ await identityStore . close ( )
36
+ await cacheStore . close ( )
37
+ } )
38
38
39
- afterEach ( async ( ) => {
40
- await store . drop ( )
41
- await cacheStore . open ( )
42
- await identityStore . open ( )
43
- } )
44
- before ( async ( ) => {
45
- identityStore = await storage . createStore ( 'identity' )
46
- const keystore = new Keystore ( identityStore )
39
+ afterEach ( async ( ) => {
40
+ await store . drop ( )
41
+ await cacheStore . open ( )
42
+ await identityStore . open ( )
43
+ } )
47
44
48
- cacheStore = await storage . createStore ( 'cache' )
49
- const cache = new Cache ( cacheStore )
45
+ before ( async ( ) => {
46
+ identityStore = await storage . createStore ( 'identity' )
47
+ const keystore = new Keystore ( identityStore )
50
48
51
- testIdentity = await IdentityProvider . createIdentity ( { id : 'userA' , keystore } )
52
- ipfs = await startIpfs ( IPFS , ipfsConfig )
49
+ cacheStore = await storage . createStore ( 'cache' )
50
+ const cache = new Cache ( cacheStore )
53
51
54
- const address = 'test-address'
55
- const options = Object . assign ( { } , DefaultOptions , { cache } )
56
- store = new Store ( ipfs , testIdentity , address , options )
57
- } )
58
- it ( 'Specific log.op event' , ( done ) => {
59
- var data = {
60
- op : "SET" ,
61
- key : "transaction" ,
62
- value : "data"
63
- }
64
- store . events . on ( "log.op.SET" , ( id , address , payload ) => {
65
- var { op, key, value} = payload ;
66
- assert . strictEqual ( op , data . op ) ;
67
- assert . strictEqual ( key , data . key ) ;
68
- assert . strictEqual ( value , data . value ) ;
69
- assert . strictEqual ( id , 'test-address' ) ;
70
- done ( ) ;
71
- } )
72
- store . _addOperation ( data )
73
-
74
- } )
52
+ testIdentity = await IdentityProvider . createIdentity ( { id : 'userA' , keystore } )
53
+ ipfsd = await startIpfs ( IPFS , ipfsConfig )
54
+ ipfs = ipfsd . api
55
+
56
+ const address = 'test-address'
57
+ const options = Object . assign ( { } , DefaultOptions , { cache } )
58
+ store = new Store ( ipfs , testIdentity , address , options )
59
+ } )
60
+ it ( 'Specific log.op event' , ( done ) => {
61
+ var data = {
62
+ op : 'SET' ,
63
+ key : 'transaction' ,
64
+ value : 'data'
65
+ }
66
+ store . events . on ( 'log.op.SET' , ( id , address , payload ) => {
67
+ var { op, key, value } = payload
68
+ assert . strictEqual ( op , data . op )
69
+ assert . strictEqual ( key , data . key )
70
+ assert . strictEqual ( value , data . value )
71
+ assert . strictEqual ( id , 'test-address' )
72
+ done ( )
73
+ } )
74
+ store . _addOperation ( data )
75
75
} )
76
- } )
76
+ } )
77
+ } )
0 commit comments