zold 0.22.8 → 0.22.9
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/.ruby-version +1 -1
- data/lib/zold/age.rb +7 -1
- data/lib/zold/commands/pay.rb +4 -1
- data/lib/zold/commands/push.rb +1 -1
- data/lib/zold/txn.rb +5 -5
- data/lib/zold/version.rb +1 -1
- data/test/test_age.rb +17 -0
- data/test/test_txn.rb +14 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d10a8522bef20fb7b2c55c247ecc7e5880ff8b54f3de789757a66f93ae5473
|
4
|
+
data.tar.gz: 36961cafd7fb37eb88790efca940a8181b9ec57c42808bbb8b6a3d6766b70c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44792c5bec30388fd5cbaf793ab5a7ac6254aaf6e52ff2ee0574fb2d158144fc832e63bcd1c91bc349b3403e0931dc6b8db717570e4fd6ebd61be324e2574750
|
7
|
+
data.tar.gz: c87eabcbd062862ef4538a50c1e4eb3da11e82bcbacb703e935e76ef3647934156f6e3d53f08171b1a753b2f953eb19ee243293d15b0cd44bdd9930714e37209
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.0
|
data/lib/zold/age.rb
CHANGED
@@ -54,7 +54,13 @@ module Zold
|
|
54
54
|
return "#{(sec * 1000).round}ms" if sec < 1
|
55
55
|
return "#{sec.round(2)}s" if sec < 60
|
56
56
|
return "#{(sec / 60).round}m" if sec < 60 * 60
|
57
|
-
|
57
|
+
hours = (sec / 3600).round
|
58
|
+
return "#{hours}h" if hours < 24
|
59
|
+
days = (hours / 24).round
|
60
|
+
return "#{days}d" if days < 14
|
61
|
+
return "#{(days / 7).round}w" if days < 40
|
62
|
+
return "#{(days / 30).round}mo" if days < 365
|
63
|
+
"#{(days / 365).round}y"
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
data/lib/zold/commands/pay.rb
CHANGED
@@ -57,6 +57,9 @@ Available options:"
|
|
57
57
|
'The location of RSA private key (default: ~/.ssh/id_rsa)',
|
58
58
|
require: true,
|
59
59
|
default: File.expand_path('~/.ssh/id_rsa')
|
60
|
+
o.string '--network',
|
61
|
+
'The name of the network we work in',
|
62
|
+
default: 'test'
|
60
63
|
o.bool '--force',
|
61
64
|
'Ignore all validations',
|
62
65
|
default: false
|
@@ -85,7 +88,7 @@ Available options:"
|
|
85
88
|
unless invoice.include?('@')
|
86
89
|
require_relative 'invoice'
|
87
90
|
invoice = Invoice.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
88
|
-
['invoice', invoice, "--tolerate-quorum=#{opts['tolerate-quorum']}"] +
|
91
|
+
['invoice', invoice, "--tolerate-quorum=#{opts['tolerate-quorum']}", "--network=#{opts['network']}"] +
|
89
92
|
(opts['tolerate-edges'] ? ['--tolerate-edges'] : [])
|
90
93
|
)
|
91
94
|
end
|
data/lib/zold/commands/push.rb
CHANGED
@@ -153,7 +153,7 @@ out of #{nodes.value} in #{Age.new(start)}, total score for #{id} is #{total.val
|
|
153
153
|
r.http(uri).put(f)
|
154
154
|
end
|
155
155
|
if response.status == 304
|
156
|
-
@log.info("#{r}: same version of #{@wallets.acq(id, &:mnemo)} there, didn't push
|
156
|
+
@log.info("#{r}: same version of #{@wallets.acq(id, &:mnemo)} there, didn't push \
|
157
157
|
in #{Age.new(start, limit: 0.5)}")
|
158
158
|
return 0
|
159
159
|
end
|
data/lib/zold/txn.rb
CHANGED
@@ -81,14 +81,14 @@ module Zold
|
|
81
81
|
raise 'The bnf has to be of type Id' unless bnf.is_a?(Id)
|
82
82
|
@bnf = bnf
|
83
83
|
raise 'Prefix can\'t be NIL' if prefix.nil?
|
84
|
-
raise "Prefix is too short:
|
85
|
-
raise "Prefix is too long:
|
86
|
-
raise "Prefix is wrong:
|
84
|
+
raise "Prefix is too short: #{prefix.inspect}" if prefix.length < 8
|
85
|
+
raise "Prefix is too long: #{prefix.inspect}" if prefix.length > 32
|
86
|
+
raise "Prefix is wrong: #{prefix.inspect} (#{RE_PREFIX})" unless REGEX_PREFIX.match?(prefix)
|
87
87
|
@prefix = prefix
|
88
88
|
raise 'Details can\'t be NIL' if details.nil?
|
89
89
|
raise 'Details can\'t be empty' if details.empty?
|
90
|
-
raise "Details are too long:
|
91
|
-
raise "Wrong details
|
90
|
+
raise "Details are too long: #{details.inspect}" if details.length > 512
|
91
|
+
raise "Wrong details #{details.inspect} (#{RE_DETAILS})" unless REGEX_DETAILS.match?(details)
|
92
92
|
@details = details
|
93
93
|
end
|
94
94
|
|
data/lib/zold/version.rb
CHANGED
data/test/test_age.rb
CHANGED
@@ -35,4 +35,21 @@ class TestAge < Zold::Test
|
|
35
35
|
assert_equal('?', Zold::Age.new(nil).to_s)
|
36
36
|
assert(!Zold::Age.new(Time.now.utc.iso8601).to_s.nil?)
|
37
37
|
end
|
38
|
+
|
39
|
+
def test_prints_all_ages
|
40
|
+
[
|
41
|
+
0,
|
42
|
+
1,
|
43
|
+
63,
|
44
|
+
63 * 60,
|
45
|
+
27 * 60 * 60,
|
46
|
+
13 * 24 * 60 * 60,
|
47
|
+
30 * 24 * 60 * 60,
|
48
|
+
5 * 30 * 24 * 60 * 60,
|
49
|
+
15 * 30 * 24 * 60 * 60,
|
50
|
+
8 * 12 * 30 * 24 * 60 * 60
|
51
|
+
].each do |s|
|
52
|
+
assert(!Zold::Age.new(Time.now - s).to_s.nil?)
|
53
|
+
end
|
54
|
+
end
|
38
55
|
end
|
data/test/test_txn.rb
CHANGED
@@ -63,15 +63,20 @@ class TestTxn < Zold::Test
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_accepts_text_as_details
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
[
|
67
|
+
'How are you, dude?! I\'m @yegor256: *_hello_',
|
68
|
+
'For a pizza to my friend: John! Good? Works.',
|
69
|
+
'ZLD exchange to 0.00104 BTC at 3NimQKG2kuseH3cz3hdbdEHbqai9kj, rate is 0.00026, fee is 0.08'
|
70
|
+
].each do |details|
|
71
|
+
txn = Zold::Txn.parse(
|
72
|
+
Zold::Txn.new(
|
73
|
+
123, Time.now, Zold::Amount.new(zld: -99.95),
|
74
|
+
'NOPREFIX', Zold::Id.new,
|
75
|
+
details
|
76
|
+
).to_s
|
77
|
+
)
|
78
|
+
assert_equal(details, txn.details)
|
79
|
+
end
|
75
80
|
end
|
76
81
|
|
77
82
|
def test_prints_and_parses_time
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -751,7 +751,7 @@ licenses:
|
|
751
751
|
- MIT
|
752
752
|
metadata: {}
|
753
753
|
post_install_message: |-
|
754
|
-
Thanks for installing Zold 0.22.
|
754
|
+
Thanks for installing Zold 0.22.9!
|
755
755
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
756
756
|
Read our blog posts: https://blog.zold.io
|
757
757
|
Try ZLD online wallet at: https://wts.zold.io
|