sibit 0.20.4 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sibit/blockchain.rb +7 -2
- data/lib/sibit/version.rb +1 -1
- data/test/test_blockchain.rb +9 -0
- 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: b6560adb5310350a01c7d22c8fa4dd58abc73e9c60c737117d8929cc1a77bdc1
|
4
|
+
data.tar.gz: 31f7e57e269801972b5e3f8cb11f29d9ff847a214b29f488c0a809bc35d0341e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d170b48eca5cd5ecd76d6e60bbf9b2fb5575f1e203a92aab6d10547fcfbf9043f30e55d12f21e45ff6929ab46538a2c56edd103df8e48cc0e621fca1810fe2
|
7
|
+
data.tar.gz: 910666d824ba0e74414e39a51d18b3e5fbbeae6af37cd4c8d15cf27e2b591a1b3d0b992f98b324e3c43dc0fa07ae5a5d19e0bb403f5958242e2f47a2eaeb412a
|
data/lib/sibit/blockchain.rb
CHANGED
@@ -58,8 +58,13 @@ class Sibit
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# Get hash of the block after this one.
|
61
|
-
def next_of(
|
62
|
-
|
61
|
+
def next_of(hash)
|
62
|
+
json = Sibit::Json.new(http: @http, log: @log).get(
|
63
|
+
URI("https://blockchain.info/rawblock/#{hash}")
|
64
|
+
)
|
65
|
+
nxt = json['next_block']
|
66
|
+
@log.info("The next block of #{hash} is #{nxt}")
|
67
|
+
nxt
|
63
68
|
end
|
64
69
|
|
65
70
|
# The height of the block.
|
data/lib/sibit/version.rb
CHANGED
data/test/test_blockchain.rb
CHANGED
@@ -45,4 +45,13 @@ class TestBlockchain < Minitest::Test
|
|
45
45
|
assert_equal('h1', json[:txns][0][:hash])
|
46
46
|
assert(json[:txns][0][:outputs].is_a?(Array))
|
47
47
|
end
|
48
|
+
|
49
|
+
def test_next_of
|
50
|
+
hash = '0000000000000000000f676241aabc9b62b748d26192a44bc25720c34de27d19'
|
51
|
+
stub_request(:get, "https://blockchain.info/rawblock/#{hash}")
|
52
|
+
.to_return(body: '{"next_block": "nxt"}')
|
53
|
+
sibit = Sibit::Blockchain.new
|
54
|
+
nxt = sibit.next_of(hash)
|
55
|
+
assert_equal('nxt', nxt)
|
56
|
+
end
|
48
57
|
end
|