This repository was archived by the owner on Mar 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +96
-4
lines changed
Expand file tree Collapse file tree 5 files changed +96
-4
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,39 @@ language: node_js
22cache : npm
33stages :
44 - check
5+ - test
6+ - cov
57
68node_js :
79 - ' 10'
10+ - ' 12'
811
9- script :
10- - npm run lint
12+ os :
13+ - linux
14+ - osx
15+ - windows
16+
17+ script : npx nyc -s npm run test:node -- --bail
18+ after_success : npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
19+
20+ jobs :
21+ include :
22+ - stage : check
23+ script :
24+ - npx aegir dep-check
25+ - npm run lint
26+
27+ - stage : test
28+ name : chrome
29+ addons :
30+ chrome : stable
31+ script : npx aegir test -t browser -t webworker
32+
33+ - stage : test
34+ name : firefox
35+ addons :
36+ firefox : latest
37+ script : npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
38+
39+ notifications :
40+ email : false
Original file line number Diff line number Diff line change 4040 "devDependencies" : {
4141 "aegir" : " ^20.3.1" ,
4242 "chai" : " ^4.2.0" ,
43- "dirty-chai" : " ^2.0.1"
43+ "dirty-chai" : " ^2.0.1" ,
44+ "peer-id" : " ^0.13.3" ,
45+ "peer-info" : " ^0.17.0"
4446 },
4547 "engines" : {
4648 "node" : " >=10.0.0" ,
Original file line number Diff line number Diff line change 1+ /* eslint-env mocha */
2+ 'use strict'
3+
4+ const tests = require ( '../src' )
5+ const MockDiscovery = require ( './mock-discovery' )
6+
7+ describe ( 'compliance tests' , ( ) => {
8+ tests ( {
9+ setup ( ) {
10+ return new MockDiscovery ( )
11+ }
12+ } )
13+ } )
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const { EventEmitter } = require ( 'events' )
4+
5+ const PeerId = require ( 'peer-id' )
6+ const PeerInfo = require ( 'peer-info' )
7+
8+ /**
9+ * Emits 'peer' events on discovery.
10+ */
11+ class MockDiscovery extends EventEmitter {
12+ /**
13+ * Constructs a new Bootstrap.
14+ *
15+ * @param {Object } options
16+ * @param {number } options.discoveryDelay - the delay to find a peer (in milli-seconds)
17+ */
18+ constructor ( options = { } ) {
19+ super ( )
20+
21+ this . options = options
22+ this . _isRunning = false
23+ this . _timer = null
24+ }
25+
26+ start ( ) {
27+ this . _isRunning = true
28+ this . _discoverPeer ( )
29+ }
30+
31+ stop ( ) {
32+ clearTimeout ( this . _timer )
33+ this . _isRunning = false
34+ }
35+
36+ async _discoverPeer ( ) {
37+ if ( ! this . _isRunning ) return
38+
39+ const peerId = await PeerId . create ( { bits : 512 } )
40+ const peerInfo = new PeerInfo ( peerId )
41+
42+ this . _timer = setTimeout ( ( ) => {
43+ this . emit ( 'peer' , peerInfo )
44+ } , this . options . discoveryDelay || 1000 )
45+ }
46+ }
47+
48+ module . exports = MockDiscovery
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments