helloblock 0.0.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/helloblock.gemspec +32 -0
- data/lib/helloblock.rb +20 -0
- data/lib/helloblock/api_interface/api_parameters.rb +10 -0
- data/lib/helloblock/api_interface/endpoints.rb +23 -0
- data/lib/helloblock/configuration.rb +22 -0
- data/lib/helloblock/http/connection.rb +28 -0
- data/lib/helloblock/http/request.rb +26 -0
- data/lib/helloblock/resources/address.rb +15 -0
- data/lib/helloblock/resources/block.rb +7 -0
- data/lib/helloblock/resources/faucet.rb +17 -0
- data/lib/helloblock/resources/query.rb +74 -0
- data/lib/helloblock/resources/transaction.rb +15 -0
- data/lib/helloblock/resources/wallet.rb +7 -0
- data/lib/helloblock/spec_helper.rb +11 -0
- data/lib/helloblock/utils.rb +17 -0
- data/lib/helloblock/version.rb +3 -0
- data/spec/fixture/vcr_cassettes/batch_address_unspents.yml +49 -0
- data/spec/fixture/vcr_cassettes/batch_addresses.yml +47 -0
- data/spec/fixture/vcr_cassettes/batch_transactions.yml +47 -0
- data/spec/fixture/vcr_cassettes/batch_transactions_addresses.yml +49 -0
- data/spec/fixture/vcr_cassettes/batch_unspents.yml +49 -0
- data/spec/fixture/vcr_cassettes/faucet.yml +45 -0
- data/spec/fixture/vcr_cassettes/latest_blocks.yml +47 -0
- data/spec/fixture/vcr_cassettes/latest_transactions.yml +47 -0
- data/spec/fixture/vcr_cassettes/propagate.yml +49 -0
- data/spec/fixture/vcr_cassettes/single_address.yml +47 -0
- data/spec/fixture/vcr_cassettes/single_address_unspents.yml +49 -0
- data/spec/fixture/vcr_cassettes/single_block.yml +47 -0
- data/spec/fixture/vcr_cassettes/single_transaction.yml +47 -0
- data/spec/fixture/vcr_cassettes/wallet.yml +47 -0
- data/spec/fixture/vcr_cassettes/withdrawal.yml +45 -0
- data/spec/integration/api_calls_work_spec.rb +176 -0
- data/spec/lib/address_spec.rb +77 -0
- data/spec/lib/connection_spec.rb +28 -0
- data/spec/lib/faucet_spec.rb +30 -0
- data/spec/lib/helloblock_spec.rb +51 -0
- data/spec/lib/request_spec.rb +41 -0
- data/spec/lib/transaction_spec.rb +106 -0
- data/spec/spec_helper.rb +13 -0
- metadata +251 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://testnet.helloblock.io/v1/addresses/1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Mon, 17 Mar 2014 16:46:09 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=d522542990ab83b2ea35755ea3da3ac561395074768841; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
Access-Control-Allow-Origin:
|
37
|
+
- '*'
|
38
|
+
X-Powered-By:
|
39
|
+
- Express
|
40
|
+
Cf-Ray:
|
41
|
+
- 10caaa3942ca0651-SJC
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"status":"success","data":{"address":{"balance":0,"confirmedBalance":0,"txsCount":0,"confirmedTxsCount":0,"address":"msvKSqto5wsSztpf3qzJweFR7tP76etSew","hash160":"880cbba2942bc34739fbd2d8d792a6ce607ef3b9"}}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Mon, 17 Mar 2014 16:46:10 GMT
|
47
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://testnet.helloblock.io/v1/addresses/1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej/unspents
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 18 Mar 2014 04:03:01 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Content-Length:
|
30
|
+
- '43'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=d0fa9e86a1a028627812ccf58ed472b381395115381362; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
Access-Control-Allow-Origin:
|
37
|
+
- '*'
|
38
|
+
Etag:
|
39
|
+
- '"-1484056770"'
|
40
|
+
X-Powered-By:
|
41
|
+
- Express
|
42
|
+
Cf-Ray:
|
43
|
+
- 10ce89bd8326070d-SJC
|
44
|
+
body:
|
45
|
+
encoding: UTF-8
|
46
|
+
string: '{"status":"success","data":{"unspents":[]}}'
|
47
|
+
http_version:
|
48
|
+
recorded_at: Tue, 18 Mar 2014 04:03:01 GMT
|
49
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://testnet.helloblock.io/v1/blocks/00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 18 Mar 2014 04:36:25 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=d3c5440a9a6d80bbe7bbbb2ac6dea82bd1395117384832; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
Access-Control-Allow-Origin:
|
37
|
+
- '*'
|
38
|
+
X-Powered-By:
|
39
|
+
- Express
|
40
|
+
Cf-Ray:
|
41
|
+
- 10cebaa73fb6070d-SJC
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"status":"success","data":{"block":{"blockHeight":1,"blockHash":"00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206","blockTime":1296688928,"previousBlockHash":"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943","bits":486604799,"version":1,"merkleRootHash":"f0315ffc38709d70ad5647e22048358dd3745f3ce3874223c80a7c92fab0c8ba","nonce":1924588547,"txsCount":1,"confirmations":205360}}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Tue, 18 Mar 2014 04:36:25 GMT
|
47
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://testnet.helloblock.io/v1/transactions/f37e6181661473c14a123cca6f0ad0ab3303d011246f1d4bb4ccf3fccef2d700
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Mon, 17 Mar 2014 16:46:10 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=de6b20e52c1fceecc2d304444df0f64ac1395074770069; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
Access-Control-Allow-Origin:
|
37
|
+
- '*'
|
38
|
+
X-Powered-By:
|
39
|
+
- Express
|
40
|
+
Cf-Ray:
|
41
|
+
- 10caaa40e259070d-SJC
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"status":"success","data":{"transaction":{"txHash":"f37e6181661473c14a123cca6f0ad0ab3303d011246f1d4bb4ccf3fccef2d700","version":1,"locktime":0,"size":225,"blockHash":"000000007a8ff45cc07729c07fd32e96da26c95c7f45853f694eb22731b699cc","blockHeight":205179,"blockTime":1394973554,"estimatedTxTime":1394971617,"confirmations":129,"inputsCount":1,"outputsCount":2,"inputs":[{"prevTxHash":"160855db287705a133c2a15176cb5acf3febe502c272016381dc4fa0d43effa6","prevTxoutIndex":1,"prevTxoutType":"pubkeyhash","value":7980000,"address":"n2WeNdvFk7GX9p38Ni7yebD56TfjvgDavC","hash160":"e64bae89305148c4098b1117594f802bcfcafdab","scriptSig":"47304402204bcc88caaefba54dfd2c7494af1898fa85af2cd0ece2070db618a9d3711772ce02201fd92149c149ebd9451a50013ef3e197e7e701283d5c25808ef0a3f933ab33e50121025c1ad4bc312481611e783751b8fc4de830a4436c129c4b82d704e728f3a5c1a3"}],"outputs":[{"index":0,"value":90000,"scriptPubKey":"76a914c081d02953f84ab9cb7aff43a845afb689d0c7ed88ac","address":"my4qYTdMmc7Dnd5H85HZSjtsD8NDmvyewJ","hash160":"c081d02953f84ab9cb7aff43a845afb689d0c7ed","txoutType":"pubkeyhash","spent":false,"nextTxHash":null,"nextTxinIndex":null},{"index":1,"value":7880000,"scriptPubKey":"76a914e64bae89305148c4098b1117594f802bcfcafdab88ac","address":"n2WeNdvFk7GX9p38Ni7yebD56TfjvgDavC","hash160":"e64bae89305148c4098b1117594f802bcfcafdab","txoutType":"pubkeyhash","spent":true,"nextTxHash":"4bcec91b6f39a11ad51f148f3ca6b156b4ac2373c4ba72af46b4a71beb71539b","nextTxinIndex":1}],"totalInputsValue":7980000,"totalOutputsValue":7970000,"fees":10000}}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Mon, 17 Mar 2014 16:46:11 GMT
|
47
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://testnet.helloblock.io/v1/wallet?addresses%5B0%5D=1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej&unspents=false
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 18 Mar 2014 05:40:47 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=d612db804667271c5ba424f3c0cf4d03a1395121247101; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
Access-Control-Allow-Origin:
|
37
|
+
- '*'
|
38
|
+
X-Powered-By:
|
39
|
+
- Express
|
40
|
+
Cf-Ray:
|
41
|
+
- 10cf18f26a60070d-SJC
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: '{"status":"success","data":{"summary":{"balance":0,"confirmedBalance":0,"txsCount":0,"confirmedTxsCount":0},"addresses":[{"balance":0,"confirmedBalance":0,"txsCount":0,"confirmedTxsCount":0,"address":"msvKSqto5wsSztpf3qzJweFR7tP76etSew","hash160":"880cbba2942bc34739fbd2d8d792a6ce607ef3b9"}]}}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Tue, 18 Mar 2014 05:40:47 GMT
|
47
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://testnet.helloblock.io/v1/faucet/withdrawal
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"body":{"toAddress":"1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej","amount":100000}}'
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- HelloBlock Gem 0.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json; charset=UTF-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 400
|
21
|
+
message: Bad Request
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cloudflare-nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 18 Mar 2014 06:14:30 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Content-Length:
|
30
|
+
- '60'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- __cfduid=da0f34724d643f0addb99836b9f0213441395123270154; expires=Mon, 23-Dec-2019
|
35
|
+
23:50:00 GMT; path=/; domain=.helloblock.io; HttpOnly
|
36
|
+
X-Powered-By:
|
37
|
+
- Express
|
38
|
+
Cf-Ray:
|
39
|
+
- 10cf4a567c58070d-SJC
|
40
|
+
body:
|
41
|
+
encoding: UTF-8
|
42
|
+
string: '{"status":"fail","message":"amount or toAddress is missing"}'
|
43
|
+
http_version:
|
44
|
+
recorded_at: Tue, 18 Mar 2014 06:14:30 GMT
|
45
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HelloBlock::Address, '.find' do
|
4
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
5
|
+
|
6
|
+
it 'retrieves a single address from the API' do
|
7
|
+
VCR.use_cassette(:single_address) do
|
8
|
+
response = HelloBlock::Address.find(address)
|
9
|
+
|
10
|
+
expect(response['status']).to eq 'success'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe HelloBlock::Address, '.where' do
|
16
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
17
|
+
|
18
|
+
it 'retrieves batch addresses from the API' do
|
19
|
+
VCR.use_cassette(:batch_addresses) do
|
20
|
+
response = HelloBlock::Address.where(address: [address, address])
|
21
|
+
|
22
|
+
expect(response['status']).to eq 'success'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe HelloBlock::Address, '.unspents' do
|
28
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
29
|
+
|
30
|
+
it 'retrieves from the API unspents for a single address' do
|
31
|
+
VCR.use_cassette(:single_address_unspents) do
|
32
|
+
response = HelloBlock::Address.find(address).unspents
|
33
|
+
|
34
|
+
expect(response['status']).to eq 'success'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'retrieves from the API unspents for a batch of addresses' do
|
39
|
+
VCR.use_cassette(:batch_address_unspents) do
|
40
|
+
response = HelloBlock::Address.where(
|
41
|
+
address: [address, address]
|
42
|
+
).unspents
|
43
|
+
|
44
|
+
expect(response['status']).to eq 'success'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'retrieves from the API unspents for a batch of addresses regardless of placement' do
|
49
|
+
VCR.use_cassette(:batch_unspents) do
|
50
|
+
response = HelloBlock::Address.unspents.where(
|
51
|
+
address: [address, address]
|
52
|
+
)
|
53
|
+
|
54
|
+
expect(response['status']).to eq 'success'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe HelloBlock::Transaction, '.find' do
|
60
|
+
let(:tx) { 'f37e6181661473c14a123cca6f0ad0ab3303d011246f1d4bb4ccf3fccef2d700' }
|
61
|
+
|
62
|
+
it 'retrieves a single transaction from the API' do
|
63
|
+
VCR.use_cassette(:single_transaction) do
|
64
|
+
response = HelloBlock::Transaction.find(tx)
|
65
|
+
|
66
|
+
expect(response['status']).to eq 'success'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe HelloBlock::Transaction, '.where' do
|
72
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
73
|
+
let(:tx) { 'f37e6181661473c14a123cca6f0ad0ab3303d011246f1d4bb4ccf3fccef2d700' }
|
74
|
+
|
75
|
+
it 'retrieves a batch of transactions from the API' do
|
76
|
+
VCR.use_cassette(:batch_transactions) do
|
77
|
+
response = HelloBlock::Transaction.where(transaction: [tx, tx])
|
78
|
+
|
79
|
+
expect(response['status']).to eq 'success'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'retrieves from the API a batch of transactions given several addresses' do
|
84
|
+
VCR.use_cassette(:batch_transactions_addresses) do
|
85
|
+
response = HelloBlock::Transaction.where(address: [address, address])
|
86
|
+
|
87
|
+
expect(response['status']).to eq 'success'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe HelloBlock::Transaction, '.last' do
|
93
|
+
it 'retrieves the latest transactions from the API' do
|
94
|
+
VCR.use_cassette(:latest_transactions) do
|
95
|
+
response = HelloBlock::Transaction.last(5)
|
96
|
+
|
97
|
+
expect(response['status']).to eq 'success'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe HelloBlock::Block, '.find' do
|
103
|
+
let(:block) { '00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206' }
|
104
|
+
|
105
|
+
it 'retrieves a block from the API' do
|
106
|
+
VCR.use_cassette(:single_block) do
|
107
|
+
response = HelloBlock::Block.find(block)
|
108
|
+
|
109
|
+
expect(response['status']).to eq 'success'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe HelloBlock::Block, '.last' do
|
115
|
+
it 'retrieves the latest blocks from the API' do
|
116
|
+
VCR.use_cassette(:latest_blocks) do
|
117
|
+
response = HelloBlock::Block.last(1)
|
118
|
+
|
119
|
+
expect(response['status']).to eq 'success'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe HelloBlock::Wallet, '.where' do
|
125
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
126
|
+
|
127
|
+
it 'retrieves wallet information from the API' do
|
128
|
+
VCR.use_cassette(:wallet) do
|
129
|
+
response = HelloBlock::Wallet.where(address: [address], unspents: false)
|
130
|
+
|
131
|
+
expect(response['status']).to eq 'success'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe HelloBlock::Faucet, '.where' do
|
137
|
+
it 'retrieves unspents from the API faucet' do
|
138
|
+
VCR.use_cassette(:faucet) do
|
139
|
+
response = HelloBlock::Faucet.where(type: 3)
|
140
|
+
|
141
|
+
expect(response['status']).to eq 'success'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe HelloBlock::Transaction, '.create' do
|
147
|
+
let(:tx) { '0100000001ec71e2ceac8476bea21fbc4a97062c000f07def6c8ef8d917' +
|
148
|
+
'1fb1a5e113418e0010000008c493046022100e6f39b4393794ef03b0f9d' +
|
149
|
+
'c71395e0835a211015b42ab4329cb6a6c1c8b3c6ea022100f1ccae451f3' +
|
150
|
+
'5e5c5ad25a8f7e7b5e778bafc4dc69dd560fab1cbadbb88767916014104' +
|
151
|
+
'e1934263e84e202ebffca95246b63c18c07cd369c4f02de76dbd1db89e6' +
|
152
|
+
'255dacb3ab1895af0422e24e1d1099e80f01b899cfcdf9b947575352dbc' +
|
153
|
+
'1af57466b5ffffffff0210270000000000001976a914652c453e3f8768d' +
|
154
|
+
'6d6e1f2985cb8939db91a4e0588ace065f81f000000001976a914cf0dfe' +
|
155
|
+
'6e0fa6ea5dda32c58ff699071b672e1faf88ac00000000' }
|
156
|
+
it 'posts a new transaction to be propagated to the API' do
|
157
|
+
VCR.use_cassette(:propagate) do
|
158
|
+
response = HelloBlock::Transaction.create(tx)
|
159
|
+
|
160
|
+
expect(response['status']).to eq 'success'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
describe HelloBlock::Faucet, '.withdraw' do
|
167
|
+
let(:address) { '1DQN9nopGvSCDnM3LH1w7j36FtnQDZKnej' }
|
168
|
+
|
169
|
+
it 'posts a withdrawal to the API' do
|
170
|
+
VCR.use_cassette(:withdrawal) do
|
171
|
+
response = HelloBlock::Faucet.withdraw(to: address, amount: 100_000)
|
172
|
+
|
173
|
+
expect(response['status']).to eq 'success'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|