@@ -32,24 +32,44 @@ describe('name', function () {
32
32
33
33
it ( 'should republish entries' , async function ( ) {
34
34
republisher = new IpnsRepublisher ( sinon . stub ( ) , sinon . stub ( ) , sinon . stub ( ) , sinon . stub ( ) , {
35
- initialBroadcastInterval : 500 ,
36
- broadcastInterval : 1000
35
+ initialBroadcastInterval : 200 ,
36
+ broadcastInterval : 500
37
37
} )
38
38
republisher . _republishEntries = sinon . stub ( )
39
39
40
40
await republisher . start ( )
41
41
42
42
expect ( republisher . _republishEntries . calledOnce ) . to . equal ( false )
43
43
44
- // Initial republish should happen after ~500ms
45
- await delay ( 750 )
44
+ // Initial republish should happen after ~200ms
45
+ await delay ( 300 )
46
46
expect ( republisher . _republishEntries . calledOnce ) . to . equal ( true )
47
47
48
- // Subsequent republishes should happen after ~1500ms
49
- await delay ( 1000 )
48
+ // Subsequent republishes should happen after ~700
49
+ await delay ( 600 )
50
50
expect ( republisher . _republishEntries . calledTwice ) . to . equal ( true )
51
51
} )
52
52
53
+ it ( 'should not republish self key twice' , async function ( ) {
54
+ const mockKeychain = {
55
+ listKeys : ( ) => Promise . resolve ( [ { name : 'self' } ] )
56
+ }
57
+ republisher = new IpnsRepublisher ( sinon . stub ( ) , sinon . stub ( ) , sinon . stub ( ) , mockKeychain , {
58
+ initialBroadcastInterval : 100 ,
59
+ broadcastInterval : 1000 ,
60
+ pass : 'pass'
61
+ } )
62
+ republisher . _republishEntry = sinon . stub ( )
63
+
64
+ await republisher . start ( )
65
+
66
+ expect ( republisher . _republishEntry . calledOnce ) . to . equal ( false )
67
+
68
+ // Initial republish should happen after ~100ms
69
+ await delay ( 200 )
70
+ expect ( republisher . _republishEntry . calledOnce ) . to . equal ( true )
71
+ } )
72
+
53
73
it ( 'should error if run republish again' , async ( ) => {
54
74
republisher = new IpnsRepublisher ( sinon . stub ( ) , sinon . stub ( ) , sinon . stub ( ) , sinon . stub ( ) , {
55
75
initialBroadcastInterval : 50 ,
0 commit comments