silkroad 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/silkroad/batch.rb +2 -2
- data/lib/silkroad/client.rb +4 -2
- data/lib/silkroad/version.rb +1 -1
- data/silkroad.gemspec +2 -2
- data/test/client_test.rb +28 -10
- metadata +18 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1a6b37fb9a99b76044b3d0929be27188bf0e9ed46890ad8bd2eb5c6197b9504
|
4
|
+
data.tar.gz: fff1515809b4a8e7c3006cabdb937b4c8a28dd886e463c6097db225d522f82c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67e1ea9a7165af2f822b7ea40fe4c83ac1781f0b19ac7e9469f3b9ae8ec4775d39c3dd93549c02fbeddb638fb16405a89ce47dbacfd8878000dde02f67c828f0
|
7
|
+
data.tar.gz: e4fa7699c5aa35bbc46a100afafec6f63629b6abb94f97d174b10807369090cbdc66bdc5c7508fae29fe8b23fe5c35ffea08043ea237d111d35923d2b3630a75
|
data/lib/silkroad/batch.rb
CHANGED
data/lib/silkroad/client.rb
CHANGED
@@ -36,11 +36,13 @@ module Silkroad
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def send(formdata)
|
39
|
-
|
39
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
40
|
+
http.use_ssl = true if @uri.scheme == 'https'
|
41
|
+
|
42
|
+
resp = http.start do
|
40
43
|
req = Net::HTTP::Post.new '/'
|
41
44
|
req.basic_auth @uri.user, @uri.password
|
42
45
|
req.add_field 'Content-Type', 'application/json'
|
43
|
-
req.use_ssl = true if @uri.scheme == 'https'
|
44
46
|
req.body = formdata.to_json
|
45
47
|
http.request req
|
46
48
|
end
|
data/lib/silkroad/version.rb
CHANGED
data/silkroad.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "minitest"
|
24
24
|
spec.add_development_dependency "webmock"
|
25
25
|
spec.add_development_dependency "yard"
|
26
|
-
end
|
26
|
+
end
|
data/test/client_test.rb
CHANGED
@@ -2,16 +2,24 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require './lib/silkroad.rb'
|
4
4
|
require 'minitest/autorun'
|
5
|
-
require 'webmock'
|
5
|
+
require 'webmock/minitest'
|
6
6
|
include WebMock::API
|
7
|
+
WebMock.disable_net_connect!
|
7
8
|
|
8
|
-
def
|
9
|
-
'http://
|
9
|
+
def http_uri
|
10
|
+
'http://localhost:8332/'
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
13
|
+
def https_uri
|
14
|
+
'https://localhost:8332/'
|
15
|
+
end
|
16
|
+
|
17
|
+
def stub_with_body(body, response, use_ssl=false)
|
18
|
+
stub_request(:post, (use_ssl ? https_uri : http_uri)).
|
19
|
+
with(body: body, headers: {
|
20
|
+
'Content-Type' =>'application/json',
|
21
|
+
'Authorization' =>'Basic dXNlcjpwYXNz'
|
22
|
+
}).
|
15
23
|
to_return(response)
|
16
24
|
end
|
17
25
|
|
@@ -23,8 +31,7 @@ describe Silkroad::Client do
|
|
23
31
|
|
24
32
|
it 'sets url defaults correctly' do
|
25
33
|
Proc.new { Silkroad::Client.new 'http://localhost' }.must_raise Silkroad::Client::Error
|
26
|
-
|
27
|
-
|
34
|
+
|
28
35
|
silkroad = Silkroad::Client.new 'http://user:pass@localhost'
|
29
36
|
silkroad.uri.to_s.must_equal 'http://user:pass@localhost:8332'
|
30
37
|
|
@@ -41,6 +48,17 @@ describe Silkroad::Client do
|
|
41
48
|
@silkroad.rpc('getbalance', 'tyler@example.com').must_equal 31337
|
42
49
|
end
|
43
50
|
|
51
|
+
it 'works with ssl' do
|
52
|
+
stub_with_body(
|
53
|
+
{jsonrpc: "2.0", method: "getbalance", params: ["tyler@example.com"]},
|
54
|
+
{status: 200, body: {result: 31337}.to_json},
|
55
|
+
true
|
56
|
+
)
|
57
|
+
|
58
|
+
silkroad = Silkroad::Client.new 'https://user:pass@localhost:8332'
|
59
|
+
silkroad.rpc('getbalance', 'tyler@example.com').must_equal 31337
|
60
|
+
end
|
61
|
+
|
44
62
|
it 'fails with error' do
|
45
63
|
stub_with_body(
|
46
64
|
{jsonrpc: "2.0", method: "failbalance", params: ["tyler@example.com"]},
|
@@ -49,7 +67,7 @@ describe Silkroad::Client do
|
|
49
67
|
end
|
50
68
|
|
51
69
|
it 'makes a batch call' do
|
52
|
-
stub_request(:post,
|
70
|
+
stub_request(:post, http_uri).
|
53
71
|
with(
|
54
72
|
body: [
|
55
73
|
{method: 'getbalance', params: ['tyler@example.com'], jsonrpc: '2.0'},
|
@@ -72,4 +90,4 @@ describe Silkroad::Client do
|
|
72
90
|
response.first['result'].must_equal 31337
|
73
91
|
response.last['error']['message'].must_equal 'Method not found'
|
74
92
|
end
|
75
|
-
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silkroad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Drake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
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: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
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
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '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
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
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
82
|
version: '0'
|
83
83
|
description: A fast, thread-safe, simple, lightweight, batchable, sober interface
|
@@ -88,7 +88,7 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .gitignore
|
91
|
+
- ".gitignore"
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE.txt
|
94
94
|
- README.md
|
@@ -109,21 +109,19 @@ require_paths:
|
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.0.3
|
121
|
+
rubygems_version: 3.0.3
|
123
122
|
signing_key:
|
124
123
|
specification_version: 4
|
125
124
|
summary: A fast, thread-safe, simple, lightweight, batchable, sober interface to the
|
126
125
|
bitcoind JSON-RPC api. Uses HTTPClient for high performance (http://bibwild.wordpress.com/2012/04/30/ruby-http-performance-shootout-redux).
|
127
126
|
test_files:
|
128
127
|
- test/client_test.rb
|
129
|
-
has_rdoc:
|