sibit 0.21.0 → 0.21.1
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 +4 -4
- data/lib/sibit/blockchain.rb +6 -2
- data/lib/sibit/version.rb +1 -1
- data/test/test_blockchain.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f5aa35b76dae1b83f707bb8fb83778b440c3a360be0d488528a75fa54ec8a4c
|
|
4
|
+
data.tar.gz: 0addf6b95dcdacaa73bef4587ba3e3b434314a9064d8905a3fac76c47a60eb0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15685ed9d9b96ec1e50005e9fdc5f84ccfb57e70a31fa319a8065b6312e31b326b981c8c100e5a015bfcd90c37411ccd3f36c7bf736ec004a4a450eadcbaf005
|
|
7
|
+
data.tar.gz: ce65b2ff52d59493c73aa43bae875608483767d2033b34070ab8ec25832a6ec68aa3a9fb391a697871bbe9ce61ee57fde78577df9dd4a55d53d0d04f4eeecc9a
|
data/lib/sibit/blockchain.rb
CHANGED
|
@@ -62,8 +62,12 @@ class Sibit
|
|
|
62
62
|
json = Sibit::Json.new(http: @http, log: @log).get(
|
|
63
63
|
URI("https://blockchain.info/rawblock/#{hash}")
|
|
64
64
|
)
|
|
65
|
-
nxt = json['next_block']
|
|
66
|
-
|
|
65
|
+
nxt = json['next_block'][0]
|
|
66
|
+
if nxt.nil?
|
|
67
|
+
@log.info("There is no block after #{hash}")
|
|
68
|
+
else
|
|
69
|
+
@log.info("The next block of #{hash} is #{nxt}")
|
|
70
|
+
end
|
|
67
71
|
nxt
|
|
68
72
|
end
|
|
69
73
|
|
data/lib/sibit/version.rb
CHANGED
data/test/test_blockchain.rb
CHANGED
|
@@ -34,7 +34,7 @@ class TestBlockchain < Minitest::Test
|
|
|
34
34
|
def test_fetch_block
|
|
35
35
|
hash = '0000000000000000000f676241aabc9b62b748d26192a44bc25720c34de27d19'
|
|
36
36
|
stub_request(:get, "https://blockchain.info/rawblock/#{hash}")
|
|
37
|
-
.to_return(body: '{"next_block": "n", "prev_block": "p", "hash": "h",
|
|
37
|
+
.to_return(body: '{"next_block": ["n"], "prev_block": "p", "hash": "h",
|
|
38
38
|
"tx": [{"hash": "h1", "out": [{"hash": "oh", "value": 123}]}]}')
|
|
39
39
|
sibit = Sibit::Blockchain.new
|
|
40
40
|
json = sibit.block(hash)
|
|
@@ -49,7 +49,7 @@ class TestBlockchain < Minitest::Test
|
|
|
49
49
|
def test_next_of
|
|
50
50
|
hash = '0000000000000000000f676241aabc9b62b748d26192a44bc25720c34de27d19'
|
|
51
51
|
stub_request(:get, "https://blockchain.info/rawblock/#{hash}")
|
|
52
|
-
.to_return(body: '{"next_block": "nxt"}')
|
|
52
|
+
.to_return(body: '{"next_block": ["nxt"]}')
|
|
53
53
|
sibit = Sibit::Blockchain.new
|
|
54
54
|
nxt = sibit.next_of(hash)
|
|
55
55
|
assert_equal('nxt', nxt)
|