pickynode-bchd 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +27 -3
- data/.ruby-version +1 -1
- data/.travis.yml +1 -2
- data/Gemfile +7 -7
- data/Gemfile.lock +46 -42
- data/Rakefile +0 -0
- data/lib/pickynode_bchd.rb +10 -4
- data/pickynode_bchd.gemspec +7 -7
- data/spec/mocks.rb +79 -79
- data/spec/pickynode_spec.rb +30 -30
- metadata +22 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9692b329159e6e8e00860297e0fb3dc457bbad1814508488bfb94e5fd0fcb682
|
|
4
|
+
data.tar.gz: 6e559ec2bf8ca99ac97c0756ac669732b91667ef4dc5031ee418104b8dbfbfca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e45bb66b87212835db831295b587a745292a546aa8e0042eaa084d8ebf5dfe03c6baf29e1fb3e86e7adc370ec50b03326fbaf2eb66d90705837b74b25e9983fe
|
|
7
|
+
data.tar.gz: 1b542757f321eb737817a9b3af2a9d393edc0e49b3c327bdeae3b00877d0cfd94a91d037d013c0498fa6273316f3a3e133a645316c3466d74368020649b02a4e
|
data/.rubocop.yml
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
ClassLength:
|
|
1
|
+
Metrics/ClassLength:
|
|
2
2
|
Enabled: false
|
|
3
3
|
Metrics/BlockLength:
|
|
4
4
|
ExcludedMethods: ['describe', 'context']
|
|
5
|
-
Style/IndentHeredoc:
|
|
6
|
-
Enabled: false
|
|
7
5
|
Style/NumericPredicate:
|
|
8
6
|
Enabled: false
|
|
7
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
8
|
+
Enabled: true
|
|
9
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
10
|
+
Enabled: true
|
|
11
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
12
|
+
Enabled: true
|
|
13
|
+
Lint/MixedRegexpCaptureTypes:
|
|
14
|
+
Enabled: true
|
|
15
|
+
Lint/RaiseException:
|
|
16
|
+
Enabled: true
|
|
17
|
+
Lint/StructNewOverride:
|
|
18
|
+
Enabled: true
|
|
19
|
+
Style/ExponentialNotation:
|
|
20
|
+
Enabled: true
|
|
21
|
+
Style/HashEachMethods:
|
|
22
|
+
Enabled: true
|
|
23
|
+
Style/HashTransformKeys:
|
|
24
|
+
Enabled: true
|
|
25
|
+
Style/HashTransformValues:
|
|
26
|
+
Enabled: true
|
|
27
|
+
Style/RedundantRegexpCharacterClass:
|
|
28
|
+
Enabled: true
|
|
29
|
+
Style/RedundantRegexpEscape:
|
|
30
|
+
Enabled: true
|
|
31
|
+
Style/SlicingWithRange:
|
|
32
|
+
Enabled: true
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.5.8
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
|
-
ruby '>= 2.
|
|
4
|
+
ruby '>= 2.5'
|
|
5
5
|
|
|
6
|
-
gem 'awesome_print', '~> 1.
|
|
7
|
-
gem 'optimist', '~> 3.0'
|
|
8
|
-
gem 'rake', '~>
|
|
9
|
-
gem 'rspec', '~> 3.
|
|
10
|
-
gem 'rubocop', '~> 0.
|
|
11
|
-
gem 'simplecov', '~> 0.
|
|
6
|
+
gem 'awesome_print', '~> 1.8.0'
|
|
7
|
+
gem 'optimist', '~> 3.0.1'
|
|
8
|
+
gem 'rake', '~> 13.0.1'
|
|
9
|
+
gem 'rspec', '~> 3.9.0'
|
|
10
|
+
gem 'rubocop', '~> 0.85.1'
|
|
11
|
+
gem 'simplecov', '~> 0.18.5', require: false, group: :test
|
data/Gemfile.lock
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
ast (2.
|
|
5
|
-
awesome_print (1.
|
|
4
|
+
ast (2.4.1)
|
|
5
|
+
awesome_print (1.8.0)
|
|
6
6
|
diff-lcs (1.3)
|
|
7
|
-
docile (1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
parser (2.
|
|
11
|
-
ast (~> 2.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
rspec (3.
|
|
17
|
-
rspec-core (~> 3.
|
|
18
|
-
rspec-expectations (~> 3.
|
|
19
|
-
rspec-mocks (~> 3.
|
|
20
|
-
rspec-core (3.
|
|
21
|
-
rspec-support (~> 3.
|
|
22
|
-
rspec-expectations (3.
|
|
7
|
+
docile (1.3.2)
|
|
8
|
+
optimist (3.0.1)
|
|
9
|
+
parallel (1.19.1)
|
|
10
|
+
parser (2.7.1.3)
|
|
11
|
+
ast (~> 2.4.0)
|
|
12
|
+
rainbow (3.0.0)
|
|
13
|
+
rake (13.0.1)
|
|
14
|
+
regexp_parser (1.7.1)
|
|
15
|
+
rexml (3.2.4)
|
|
16
|
+
rspec (3.9.0)
|
|
17
|
+
rspec-core (~> 3.9.0)
|
|
18
|
+
rspec-expectations (~> 3.9.0)
|
|
19
|
+
rspec-mocks (~> 3.9.0)
|
|
20
|
+
rspec-core (3.9.2)
|
|
21
|
+
rspec-support (~> 3.9.3)
|
|
22
|
+
rspec-expectations (3.9.2)
|
|
23
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
-
rspec-support (~> 3.
|
|
25
|
-
rspec-mocks (3.
|
|
24
|
+
rspec-support (~> 3.9.0)
|
|
25
|
+
rspec-mocks (3.9.1)
|
|
26
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
-
rspec-support (~> 3.
|
|
28
|
-
rspec-support (3.
|
|
29
|
-
rubocop (0.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
rainbow (>=
|
|
27
|
+
rspec-support (~> 3.9.0)
|
|
28
|
+
rspec-support (3.9.3)
|
|
29
|
+
rubocop (0.85.1)
|
|
30
|
+
parallel (~> 1.10)
|
|
31
|
+
parser (>= 2.7.0.1)
|
|
32
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
33
|
+
regexp_parser (>= 1.7)
|
|
34
|
+
rexml
|
|
35
|
+
rubocop-ast (>= 0.0.3)
|
|
33
36
|
ruby-progressbar (~> 1.7)
|
|
34
|
-
unicode-display_width (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
38
|
+
rubocop-ast (0.0.3)
|
|
39
|
+
parser (>= 2.7.0.1)
|
|
40
|
+
ruby-progressbar (1.10.1)
|
|
41
|
+
simplecov (0.18.5)
|
|
42
|
+
docile (~> 1.1)
|
|
43
|
+
simplecov-html (~> 0.11)
|
|
44
|
+
simplecov-html (0.12.2)
|
|
45
|
+
unicode-display_width (1.7.0)
|
|
42
46
|
|
|
43
47
|
PLATFORMS
|
|
44
48
|
ruby
|
|
45
49
|
|
|
46
50
|
DEPENDENCIES
|
|
47
|
-
awesome_print (~> 1.
|
|
48
|
-
optimist (~> 3.0)
|
|
49
|
-
rake (~>
|
|
50
|
-
rspec (~> 3.
|
|
51
|
-
rubocop (~> 0.
|
|
52
|
-
simplecov (~> 0.
|
|
51
|
+
awesome_print (~> 1.8.0)
|
|
52
|
+
optimist (~> 3.0.1)
|
|
53
|
+
rake (~> 13.0.1)
|
|
54
|
+
rspec (~> 3.9.0)
|
|
55
|
+
rubocop (~> 0.85.1)
|
|
56
|
+
simplecov (~> 0.18.5)
|
|
53
57
|
|
|
54
58
|
RUBY VERSION
|
|
55
|
-
ruby 2.
|
|
59
|
+
ruby 2.5.8p224
|
|
56
60
|
|
|
57
61
|
BUNDLED WITH
|
|
58
|
-
1.
|
|
62
|
+
2.1.4
|
data/Rakefile
CHANGED
|
File without changes
|
data/lib/pickynode_bchd.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'uri'
|
|
|
9
9
|
# Allows you to easily add/remove/connect/disconnect nodes
|
|
10
10
|
# based on User Agent.
|
|
11
11
|
class PickynodeBCHD
|
|
12
|
-
VERSION = '0.
|
|
12
|
+
VERSION = '0.2.0'
|
|
13
13
|
|
|
14
14
|
def initialize(opts = {})
|
|
15
15
|
@opts = opts
|
|
@@ -24,6 +24,7 @@ class PickynodeBCHD
|
|
|
24
24
|
.select { |_, v| v.include?(filter) }
|
|
25
25
|
.each_with_index do |(k, _), i|
|
|
26
26
|
break if limit == i
|
|
27
|
+
|
|
27
28
|
run_cmd(%(bchctl addnode "#{k}" add))
|
|
28
29
|
end
|
|
29
30
|
end
|
|
@@ -37,6 +38,7 @@ class PickynodeBCHD
|
|
|
37
38
|
.select { |_, v| v.include?(filter) }
|
|
38
39
|
.each_with_index do |(k, _), i|
|
|
39
40
|
break if limit == i
|
|
41
|
+
|
|
40
42
|
run_cmd(%(bchctl node remove "#{k}"))
|
|
41
43
|
end
|
|
42
44
|
end
|
|
@@ -50,6 +52,7 @@ class PickynodeBCHD
|
|
|
50
52
|
.select { |_, v| v.include?(filter) }
|
|
51
53
|
.each_with_index do |(k, _), i|
|
|
52
54
|
break if limit == i
|
|
55
|
+
|
|
53
56
|
run_cmd(%(bchctl node connect "#{k}"))
|
|
54
57
|
end
|
|
55
58
|
end
|
|
@@ -63,6 +66,7 @@ class PickynodeBCHD
|
|
|
63
66
|
.select { |_, v| v.include?(filter) }
|
|
64
67
|
.each_with_index do |(k, _), i|
|
|
65
68
|
break if limit == i
|
|
69
|
+
|
|
66
70
|
run_cmd(%(bchctl node disconnect "#{k}"))
|
|
67
71
|
end
|
|
68
72
|
end
|
|
@@ -104,6 +108,7 @@ class PickynodeBCHD
|
|
|
104
108
|
|
|
105
109
|
def addr_types
|
|
106
110
|
return @addr_types if @addr_types
|
|
111
|
+
|
|
107
112
|
nodes = getpeerinfo
|
|
108
113
|
parsed_nodes = JSON.parse(nodes)
|
|
109
114
|
@addr_types = parsed_nodes.map do |n|
|
|
@@ -115,10 +120,11 @@ class PickynodeBCHD
|
|
|
115
120
|
|
|
116
121
|
def blockchair_addr_types
|
|
117
122
|
return @blockchair_addr_types if @blockchair_addr_types
|
|
123
|
+
|
|
118
124
|
parsed_nodelist = JSON.parse(blockchair_snapshot)
|
|
119
|
-
@blockchair_addr_types = parsed_nodelist['data']['nodes'].
|
|
120
|
-
|
|
121
|
-
end
|
|
125
|
+
@blockchair_addr_types = parsed_nodelist['data']['nodes'].transform_values do |v|
|
|
126
|
+
v['version']
|
|
127
|
+
end
|
|
122
128
|
rescue JSON::ParserError
|
|
123
129
|
{}
|
|
124
130
|
end
|
data/pickynode_bchd.gemspec
CHANGED
|
@@ -15,13 +15,13 @@ bitcoin cash nodes they connect to with bchd."
|
|
|
15
15
|
s.executables << 'pickynode-bchd'
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
|
17
17
|
s.require_paths = ['lib']
|
|
18
|
-
s.required_ruby_version = '>= 2.
|
|
18
|
+
s.required_ruby_version = '>= 2.5'
|
|
19
19
|
|
|
20
|
-
s.add_dependency 'awesome_print', '~> 1.
|
|
21
|
-
s.add_dependency 'optimist', '~> 3.0'
|
|
20
|
+
s.add_dependency 'awesome_print', '~> 1.8.0'
|
|
21
|
+
s.add_dependency 'optimist', '~> 3.0.1'
|
|
22
22
|
|
|
23
|
-
s.add_development_dependency '
|
|
24
|
-
s.add_development_dependency '
|
|
25
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
|
26
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
|
23
|
+
s.add_development_dependency 'rake', '~> 13.0.1'
|
|
24
|
+
s.add_development_dependency 'rspec', '~> 3.9.0'
|
|
25
|
+
s.add_development_dependency 'rubocop', '~> 0.85.1'
|
|
26
|
+
s.add_development_dependency 'simplecov', '~> 0.18.5'
|
|
27
27
|
end
|
data/spec/mocks.rb
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
BLOCKCHAIR_SNAPSHOT =
|
|
4
|
-
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
BLOCKCHAIR_SNAPSHOT = <<~HEREDOC
|
|
4
|
+
{
|
|
5
|
+
"data": {
|
|
6
|
+
"nodes": {
|
|
7
|
+
"88.99.199.87:8333": {
|
|
8
|
+
"version": "\/BitcoinUnlimited:1.0.2(EB16; AD12)\/",
|
|
9
|
+
"country": "US",
|
|
10
|
+
"height": 555417,
|
|
11
|
+
"flags": 37
|
|
12
|
+
},
|
|
13
|
+
"[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333": {
|
|
14
|
+
"version": "\/Bitcoin ABC:0.18.2(EB32.0)\/",
|
|
15
|
+
"country": "US",
|
|
16
|
+
"height": 555416,
|
|
17
|
+
"flags": 37
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
-
HEREDOC
|
|
23
|
-
|
|
24
|
-
NODE_INFO = <<-HEREDOC
|
|
25
|
-
{
|
|
26
|
-
"version": 120000,
|
|
27
|
-
"protocolversion": 70013,
|
|
28
|
-
"blocks": 310554,
|
|
29
|
-
"timeoffset": 0,
|
|
30
|
-
"connections": 41,
|
|
31
|
-
"proxy": "",
|
|
32
|
-
"difficulty": 17336316978.50783,
|
|
33
|
-
"testnet": false,
|
|
34
|
-
"relayfee": 0.00001,
|
|
35
|
-
"errors": ""
|
|
36
|
-
}
|
|
37
22
|
HEREDOC
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
[
|
|
41
|
-
{
|
|
42
|
-
"id": 10,
|
|
43
|
-
"addr": "131.114.88.218:33422",
|
|
44
|
-
"addrlocal": "67.188.11.253:8333",
|
|
45
|
-
"services": "00000001",
|
|
46
|
-
"servicesStr": "SFNodeNetwork",
|
|
47
|
-
"relaytxes": true,
|
|
48
|
-
"lastsend": 1541490162,
|
|
49
|
-
"lastrecv": 1541490162,
|
|
50
|
-
"bytessent": 1587,
|
|
51
|
-
"bytesrecv": 3258,
|
|
52
|
-
"conntime": 1541486322,
|
|
53
|
-
"timeoffset": 0,
|
|
54
|
-
"pingtime": 125312,
|
|
55
|
-
"version": 70013,
|
|
56
|
-
"subver": "/FirstClient/",
|
|
57
|
-
"inbound": false,
|
|
58
|
-
"startingheight": 555420,
|
|
59
|
-
"currentheight": 555420,
|
|
60
|
-
"banscore": 0,
|
|
61
|
-
"whitelisted": false,
|
|
62
|
-
"feefilter": 18,
|
|
63
|
-
"syncnode": false
|
|
64
|
-
},
|
|
24
|
+
NODE_INFO = <<~HEREDOC
|
|
65
25
|
{
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"services": "00000053",
|
|
70
|
-
"servicesStr": "SFNodeNetwork|SFNodeBloom|SFNodeXthin|SFNodeBitcoinCash",
|
|
71
|
-
"relaytxes": true,
|
|
72
|
-
"lastsend": 1541490073,
|
|
73
|
-
"lastrecv": 1541490140,
|
|
74
|
-
"bytessent": 2163,
|
|
75
|
-
"bytesrecv": 6515,
|
|
76
|
-
"conntime": 1541486352,
|
|
26
|
+
"version": 120000,
|
|
27
|
+
"protocolversion": 70013,
|
|
28
|
+
"blocks": 310554,
|
|
77
29
|
"timeoffset": 0,
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"banscore": 0,
|
|
85
|
-
"whitelisted": false,
|
|
86
|
-
"feefilter": 0,
|
|
87
|
-
"syncnode": false
|
|
30
|
+
"connections": 41,
|
|
31
|
+
"proxy": "",
|
|
32
|
+
"difficulty": 17336316978.50783,
|
|
33
|
+
"testnet": false,
|
|
34
|
+
"relayfee": 0.00001,
|
|
35
|
+
"errors": ""
|
|
88
36
|
}
|
|
89
|
-
|
|
37
|
+
HEREDOC
|
|
38
|
+
|
|
39
|
+
PEER_INFO = <<~HEREDOC
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
"id": 10,
|
|
43
|
+
"addr": "131.114.88.218:33422",
|
|
44
|
+
"addrlocal": "67.188.11.253:8333",
|
|
45
|
+
"services": "00000001",
|
|
46
|
+
"servicesStr": "SFNodeNetwork",
|
|
47
|
+
"relaytxes": true,
|
|
48
|
+
"lastsend": 1541490162,
|
|
49
|
+
"lastrecv": 1541490162,
|
|
50
|
+
"bytessent": 1587,
|
|
51
|
+
"bytesrecv": 3258,
|
|
52
|
+
"conntime": 1541486322,
|
|
53
|
+
"timeoffset": 0,
|
|
54
|
+
"pingtime": 125312,
|
|
55
|
+
"version": 70013,
|
|
56
|
+
"subver": "/FirstClient/",
|
|
57
|
+
"inbound": false,
|
|
58
|
+
"startingheight": 555420,
|
|
59
|
+
"currentheight": 555420,
|
|
60
|
+
"banscore": 0,
|
|
61
|
+
"whitelisted": false,
|
|
62
|
+
"feefilter": 18,
|
|
63
|
+
"syncnode": false
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": 12,
|
|
67
|
+
"addr": "[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333",
|
|
68
|
+
"addrlocal": "[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333",
|
|
69
|
+
"services": "00000053",
|
|
70
|
+
"servicesStr": "SFNodeNetwork|SFNodeBloom|SFNodeXthin|SFNodeBitcoinCash",
|
|
71
|
+
"relaytxes": true,
|
|
72
|
+
"lastsend": 1541490073,
|
|
73
|
+
"lastrecv": 1541490140,
|
|
74
|
+
"bytessent": 2163,
|
|
75
|
+
"bytesrecv": 6515,
|
|
76
|
+
"conntime": 1541486352,
|
|
77
|
+
"timeoffset": 0,
|
|
78
|
+
"pingtime": 180911,
|
|
79
|
+
"version": 80003,
|
|
80
|
+
"subver": "/SecondClient/",
|
|
81
|
+
"inbound": false,
|
|
82
|
+
"startingheight": 555420,
|
|
83
|
+
"currentheight": 555420,
|
|
84
|
+
"banscore": 0,
|
|
85
|
+
"whitelisted": false,
|
|
86
|
+
"feefilter": 0,
|
|
87
|
+
"syncnode": false
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
90
|
HEREDOC
|
data/spec/pickynode_spec.rb
CHANGED
|
@@ -29,7 +29,7 @@ describe PickynodeBCHD do
|
|
|
29
29
|
describe '.add' do
|
|
30
30
|
it 'should add nodes based on user agent' do
|
|
31
31
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
32
|
-
|
|
32
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
33
33
|
expect(subject).to receive(:run_cmd)
|
|
34
34
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
|
35
35
|
subject.add('ABC')
|
|
@@ -47,7 +47,7 @@ describe PickynodeBCHD do
|
|
|
47
47
|
|
|
48
48
|
it 'should recover gracefully if json is malformed' do
|
|
49
49
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
50
|
-
|
|
50
|
+
.and_return(json_error)
|
|
51
51
|
expect(subject).to_not receive(:run_cmd)
|
|
52
52
|
subject.add('Anything')
|
|
53
53
|
end
|
|
@@ -62,7 +62,7 @@ describe PickynodeBCHD do
|
|
|
62
62
|
context 'with a limit' do
|
|
63
63
|
it 'should respect a limit parameter of 1' do
|
|
64
64
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
65
|
-
|
|
65
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
66
66
|
expect(subject).to receive(:run_cmd)
|
|
67
67
|
.with('bchctl addnode "88.99.199.87:8333" add')
|
|
68
68
|
subject.add('i', 1)
|
|
@@ -70,7 +70,7 @@ describe PickynodeBCHD do
|
|
|
70
70
|
|
|
71
71
|
it 'should respect a limit parameter greater than 1' do
|
|
72
72
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
73
|
-
|
|
73
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
74
74
|
expect(subject).to receive(:run_cmd)
|
|
75
75
|
.with('bchctl addnode "88.99.199.87:8333" add')
|
|
76
76
|
expect(subject).to receive(:run_cmd)
|
|
@@ -83,7 +83,7 @@ describe PickynodeBCHD do
|
|
|
83
83
|
describe '.remove' do
|
|
84
84
|
it 'should remove nodes based on user agent' do
|
|
85
85
|
expect(subject).to receive(:`).once
|
|
86
|
-
|
|
86
|
+
.and_return(PEER_INFO)
|
|
87
87
|
expect(subject).to receive(:run_cmd)
|
|
88
88
|
.with(%(bchctl node remove "#{ipv6_ip}"))
|
|
89
89
|
subject.remove('SecondClient')
|
|
@@ -101,7 +101,7 @@ describe PickynodeBCHD do
|
|
|
101
101
|
|
|
102
102
|
it 'should recover gracefully if json is malformed' do
|
|
103
103
|
expect(subject).to receive(:`).once
|
|
104
|
-
|
|
104
|
+
.and_return(json_error)
|
|
105
105
|
expect(subject).to_not receive(:run_cmd)
|
|
106
106
|
subject.remove('Anything')
|
|
107
107
|
end
|
|
@@ -110,7 +110,7 @@ describe PickynodeBCHD do
|
|
|
110
110
|
describe '.connect' do
|
|
111
111
|
it 'should connect to nodes based on user agent' do
|
|
112
112
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
113
|
-
|
|
113
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
114
114
|
expect(subject).to receive(:run_cmd)
|
|
115
115
|
.with('bchctl node connect "88.99.199.87:8333"')
|
|
116
116
|
subject.connect('Unlimited')
|
|
@@ -128,7 +128,7 @@ describe PickynodeBCHD do
|
|
|
128
128
|
|
|
129
129
|
it 'should recover gracefully if json is malformed' do
|
|
130
130
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
131
|
-
|
|
131
|
+
.and_return(json_error)
|
|
132
132
|
expect(subject).to_not receive(:run_cmd)
|
|
133
133
|
subject.connect('Anything')
|
|
134
134
|
end
|
|
@@ -143,7 +143,7 @@ describe PickynodeBCHD do
|
|
|
143
143
|
context 'with a limit' do
|
|
144
144
|
it 'should respect a limit parameter of 1' do
|
|
145
145
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
146
|
-
|
|
146
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
147
147
|
expect(subject).to receive(:run_cmd)
|
|
148
148
|
.with('bchctl node connect "88.99.199.87:8333"')
|
|
149
149
|
subject.connect('i', 1)
|
|
@@ -151,7 +151,7 @@ describe PickynodeBCHD do
|
|
|
151
151
|
|
|
152
152
|
it 'should respect a limit parameter greater than 1' do
|
|
153
153
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
154
|
-
|
|
154
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
155
155
|
expect(subject).to receive(:run_cmd)
|
|
156
156
|
.with('bchctl node connect "88.99.199.87:8333"')
|
|
157
157
|
expect(subject).to receive(:run_cmd)
|
|
@@ -164,7 +164,7 @@ describe PickynodeBCHD do
|
|
|
164
164
|
describe '.disconnect' do
|
|
165
165
|
it 'should disconnect nodes based on user agent' do
|
|
166
166
|
expect(subject).to receive(:`).once
|
|
167
|
-
|
|
167
|
+
.and_return(PEER_INFO)
|
|
168
168
|
expect(subject).to receive(:run_cmd)
|
|
169
169
|
.with(%(bchctl node disconnect "#{ipv6_ip}"))
|
|
170
170
|
subject.disconnect('SecondClient')
|
|
@@ -182,7 +182,7 @@ describe PickynodeBCHD do
|
|
|
182
182
|
|
|
183
183
|
it 'should recover gracefully if json is malformed' do
|
|
184
184
|
expect(subject).to receive(:`).once
|
|
185
|
-
|
|
185
|
+
.and_return(json_error)
|
|
186
186
|
expect(subject).to_not receive(:run_cmd)
|
|
187
187
|
subject.disconnect('Anything')
|
|
188
188
|
end
|
|
@@ -191,14 +191,14 @@ describe PickynodeBCHD do
|
|
|
191
191
|
describe '.display' do
|
|
192
192
|
it 'should display connected nodes' do
|
|
193
193
|
expect(subject).to receive(:`).once
|
|
194
|
-
|
|
194
|
+
.and_return(PEER_INFO)
|
|
195
195
|
expect(subject).to receive(:ap).with(node_hash).and_return(node_hash)
|
|
196
196
|
expect(subject.display).to eq(node_hash)
|
|
197
197
|
end
|
|
198
198
|
|
|
199
199
|
it 'should recover gracefully if json is malformed' do
|
|
200
200
|
expect(subject).to receive(:`).once
|
|
201
|
-
|
|
201
|
+
.and_return(json_error)
|
|
202
202
|
expect(subject).to receive(:ap).with({}).and_return({})
|
|
203
203
|
expect(subject.display).to eq({})
|
|
204
204
|
end
|
|
@@ -207,15 +207,15 @@ describe PickynodeBCHD do
|
|
|
207
207
|
describe '.info' do
|
|
208
208
|
it 'should display local node info' do
|
|
209
209
|
expect(subject).to receive(:`).once
|
|
210
|
-
|
|
210
|
+
.and_return(NODE_INFO)
|
|
211
211
|
expect(subject).to receive(:ap).with(parsed_node_info)
|
|
212
|
-
|
|
212
|
+
.and_return(parsed_node_info)
|
|
213
213
|
expect(subject.info).to eq(parsed_node_info)
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
it 'should recover gracefully if json is malformed' do
|
|
217
217
|
expect(subject).to receive(:`).once
|
|
218
|
-
|
|
218
|
+
.and_return(json_error)
|
|
219
219
|
expect(subject).to receive(:ap).with({}).and_return({})
|
|
220
220
|
expect(subject.info).to eq({})
|
|
221
221
|
end
|
|
@@ -237,15 +237,15 @@ describe PickynodeBCHD do
|
|
|
237
237
|
|
|
238
238
|
it 'should call add, connect, remove, disconnect and info' do
|
|
239
239
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
240
|
-
|
|
240
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
241
241
|
expect(subject).to receive(:getpeerinfo).once
|
|
242
|
-
|
|
242
|
+
.and_return(PEER_INFO)
|
|
243
243
|
expect(subject).to receive(:add).with(opts[:add], opts[:limit])
|
|
244
|
-
|
|
244
|
+
.and_call_original
|
|
245
245
|
expect(subject).to receive(:connect).with(opts[:connect], opts[:limit])
|
|
246
|
-
|
|
246
|
+
.and_call_original
|
|
247
247
|
expect(subject).to receive(:remove).with(opts[:remove], opts[:limit])
|
|
248
|
-
|
|
248
|
+
.and_call_original
|
|
249
249
|
expect(subject).to receive(:disconnect)
|
|
250
250
|
.with(opts[:disconnect], opts[:limit])
|
|
251
251
|
.and_call_original
|
|
@@ -256,9 +256,9 @@ describe PickynodeBCHD do
|
|
|
256
256
|
|
|
257
257
|
it 'should recover gracefully if json is malformed' do
|
|
258
258
|
expect(subject).to receive(:blockchair_snapshot).at_least(1)
|
|
259
|
-
|
|
259
|
+
.and_return(json_error)
|
|
260
260
|
expect(subject).to receive(:getpeerinfo).at_least(1)
|
|
261
|
-
|
|
261
|
+
.and_return(json_error)
|
|
262
262
|
expect(subject).to receive(:`)
|
|
263
263
|
.and_return(json_error)
|
|
264
264
|
expect(subject).to receive(:info)
|
|
@@ -276,7 +276,7 @@ describe PickynodeBCHD do
|
|
|
276
276
|
|
|
277
277
|
it 'should call display' do
|
|
278
278
|
expect(subject).to receive(:`).once
|
|
279
|
-
|
|
279
|
+
.and_return(PEER_INFO)
|
|
280
280
|
expect(subject).to receive(:ap).with(node_hash).and_return(node_hash)
|
|
281
281
|
expect(subject).to receive(:display).and_call_original
|
|
282
282
|
subject.run
|
|
@@ -284,7 +284,7 @@ describe PickynodeBCHD do
|
|
|
284
284
|
|
|
285
285
|
it 'should recover gracefully if json is malformed' do
|
|
286
286
|
expect(subject).to receive(:`).once
|
|
287
|
-
|
|
287
|
+
.and_return(json_error)
|
|
288
288
|
expect(subject).to_not receive(:run_cmd)
|
|
289
289
|
expect(subject).to_not receive(:info)
|
|
290
290
|
expect(subject).to receive(:ap).with({}).and_return({})
|
|
@@ -296,7 +296,7 @@ describe PickynodeBCHD do
|
|
|
296
296
|
describe 'clear_cache' do
|
|
297
297
|
it 'should clear the bitnodes cache' do
|
|
298
298
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
299
|
-
|
|
299
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
300
300
|
expect(subject).to receive(:run_cmd)
|
|
301
301
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
|
302
302
|
expect(subject).to receive(:run_cmd)
|
|
@@ -305,7 +305,7 @@ describe PickynodeBCHD do
|
|
|
305
305
|
subject.add('Unlimited')
|
|
306
306
|
subject.clear_cache
|
|
307
307
|
expect(subject).to receive(:blockchair_snapshot).once
|
|
308
|
-
|
|
308
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
|
309
309
|
expect(subject).to receive(:run_cmd)
|
|
310
310
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
|
311
311
|
subject.add('ABC')
|
|
@@ -313,7 +313,7 @@ describe PickynodeBCHD do
|
|
|
313
313
|
|
|
314
314
|
it 'should clear the getpeerinfo cache' do
|
|
315
315
|
expect(subject).to receive(:getpeerinfo).once
|
|
316
|
-
|
|
316
|
+
.and_return(PEER_INFO)
|
|
317
317
|
expect(subject).to receive(:run_cmd)
|
|
318
318
|
.with('bchctl node remove "131.114.88.218:33422"')
|
|
319
319
|
expect(subject).to receive(:run_cmd)
|
|
@@ -322,7 +322,7 @@ describe PickynodeBCHD do
|
|
|
322
322
|
subject.remove('SecondClient')
|
|
323
323
|
subject.clear_cache
|
|
324
324
|
expect(subject).to receive(:getpeerinfo).once
|
|
325
|
-
|
|
325
|
+
.and_return(PEER_INFO)
|
|
326
326
|
expect(subject).to receive(:run_cmd)
|
|
327
327
|
.with('bchctl node remove "131.114.88.218:33422"')
|
|
328
328
|
subject.remove('FirstClient')
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pickynode-bchd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josh Ellithorpe
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: awesome_print
|
|
@@ -16,84 +16,84 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.8.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 1.8.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: optimist
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 3.0.1
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 3.0.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 13.0.1
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 13.0.1
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 3.9.0
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 3.9.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rubocop
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: 0.85.1
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 0.85.1
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: simplecov
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
89
|
+
version: 0.18.5
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
96
|
+
version: 0.18.5
|
|
97
97
|
description: Some people are picky about the bitcoin cash nodes they connect to with
|
|
98
98
|
bchd.
|
|
99
99
|
email: quest@mac.com
|
|
@@ -123,7 +123,7 @@ homepage: http://github.com/zquestz/pickynode-bchd
|
|
|
123
123
|
licenses:
|
|
124
124
|
- MIT
|
|
125
125
|
metadata: {}
|
|
126
|
-
post_install_message:
|
|
126
|
+
post_install_message:
|
|
127
127
|
rdoc_options: []
|
|
128
128
|
require_paths:
|
|
129
129
|
- lib
|
|
@@ -131,16 +131,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
131
131
|
requirements:
|
|
132
132
|
- - ">="
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: '2.
|
|
134
|
+
version: '2.5'
|
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
137
|
- - ">="
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
139
|
version: '0'
|
|
140
140
|
requirements: []
|
|
141
|
-
rubyforge_project:
|
|
142
|
-
rubygems_version: 2.6.
|
|
143
|
-
signing_key:
|
|
141
|
+
rubyforge_project:
|
|
142
|
+
rubygems_version: 2.7.6.2
|
|
143
|
+
signing_key:
|
|
144
144
|
specification_version: 4
|
|
145
145
|
summary: Manage connections to your bchd node
|
|
146
146
|
test_files: []
|