Everlastly 0.1.0 → 0.1.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/tests.rb +77 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83066914b5a0ff1c2f942779a82935e5b95103a7
|
4
|
+
data.tar.gz: fd48bb1b333f9a633a700d2eb9bfdcc6b36acaaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca21aa86f433373cccda3160c987d881a7822259de8b78a029001fbb7811d71bff0ef379eca4bdb5df90cd73f745c32e305cc42fb18aaec053297d0ecca5a782
|
7
|
+
data.tar.gz: 652a28b8de28be448766e1302fd1eadb00f390e84200a88e52c32f100a32459925fd03d5bacaeef34b4bbcdc68422b663663c7c63f64e0ffd3e80cfbe927234e
|
data/tests.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'everlastly'
|
2
|
+
|
3
|
+
Everlastly.setup do | config |
|
4
|
+
config.public_key = 'pub_key'
|
5
|
+
config.private_key = 'priv_key'
|
6
|
+
end
|
7
|
+
|
8
|
+
anchor_tests = [
|
9
|
+
{ arguments: {hash: '1'*64, kwargs: {} }, success: true, error: nil},
|
10
|
+
{ arguments: {hash: '1'*64, kwargs: {metadata: { 隨機詞: '👌'}} }, success: true, error: nil},
|
11
|
+
{ arguments: {hash: '1'*64, kwargs: {metadata: { 隨機詞: '👌'}, save_dochash_in_receipt: true} }, success: true, error: nil},
|
12
|
+
{ arguments: {hash: '1'*64, kwargs: {metadata: { 隨機詞: '👌'}, save_dochash_in_receipt: true, no_salt: true} }, success: true, error: nil},
|
13
|
+
{ arguments: {hash: '1'*64, kwargs: {metadata: { 隨機詞: '👌'}, save_dochash_in_receipt: true, no_salt: true, no_nonce: true} }, success: true, error: nil},
|
14
|
+
{ arguments: {hash: '1'*63, kwargs: {} }, success: false, error: "Wrong length of `hash` parameter\n"},
|
15
|
+
]
|
16
|
+
|
17
|
+
def run_anchor_tests (tests)
|
18
|
+
raise_on_errors = true
|
19
|
+
print_positive = true
|
20
|
+
uuids = []
|
21
|
+
tests.each_with_index do | test, index |
|
22
|
+
begin
|
23
|
+
dochash = test[:arguments][:hash]
|
24
|
+
params = test[:arguments][:kwargs]
|
25
|
+
success = test[:success]
|
26
|
+
error = test[:error]
|
27
|
+
rescue Exception => msg
|
28
|
+
puts msg
|
29
|
+
raise ArgumentError, "Bad formed test #{test}"
|
30
|
+
end
|
31
|
+
res = Everlastly.anchor dochash, params
|
32
|
+
unless res[:success]==success
|
33
|
+
msg = "For test \n#{test} we got \n#{res}"
|
34
|
+
if raise_on_errors then raise(ArgumentError, msg) else puts(msg) end
|
35
|
+
else
|
36
|
+
if (not res[:success]) and (error!=res[:error_message])
|
37
|
+
raise ArgumentError, "For test \n#{test} we got error `#{res[:error_message]}`, but expected `#{error}`"
|
38
|
+
elsif print_positive
|
39
|
+
puts "👌OK\tAnchor test #{index} done correctly"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
uuids.push res[:receiptID] if res[:success]
|
43
|
+
end
|
44
|
+
uuids
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def run_get_receipts_tests (receipt_list)
|
49
|
+
raise_on_errors = true
|
50
|
+
print_positive = true
|
51
|
+
receipt_list = ['Not token', 'eb6c398d-341c-4d3b-81f0-225958991a5f'] + receipt_list
|
52
|
+
res = Everlastly.get_receipts receipt_list
|
53
|
+
preliminary_success = true
|
54
|
+
raise RuntimeError, 'Bad response from server' unless res[:success]
|
55
|
+
bad_receipts, good_receipts = res[:receipts][0...2], res[:receipts][2..-1]
|
56
|
+
bad_receipts.each_with_index do | br, index |
|
57
|
+
unless br["status"]=="Error"
|
58
|
+
msg = "Problem with #{index} example: #{br}"
|
59
|
+
preliminary_success = false
|
60
|
+
if raise_on_errors then raise(ArgumentError, msg) else puts(msg) end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
good_receipts.each_with_index do | gr, index |
|
64
|
+
unless gr["status"]=="Success"
|
65
|
+
msg = "Problem with #{index} example: #{gr}"
|
66
|
+
preliminary_success = false
|
67
|
+
if raise_on_errors then raise(ArgumentError, msg) else puts(msg) end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
puts "👌OK\tGet_receipts test 0 done correctly" if print_positive
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
uuids = run_anchor_tests anchor_tests
|
76
|
+
sleep(0.2) # Give server time to put tests to db
|
77
|
+
run_get_receipts_tests uuids
|
metadata
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Everlastly
|
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
|
- Emelyanenko Kirill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Everlastly.com API wrapper for Ruby. Notarize all your data using the
|
14
14
|
blockchain!
|
15
|
-
email:
|
15
|
+
email: kirill@everlastly.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- example.rb
|
21
21
|
- lib/everlastly.rb
|
22
|
+
- tests.rb
|
22
23
|
homepage: https://everlastly.com
|
23
24
|
licenses:
|
24
|
-
-
|
25
|
+
- BSD-3-Clause
|
25
26
|
metadata: {}
|
26
27
|
post_install_message:
|
27
28
|
rdoc_options: []
|