zold 0.20.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/zold +1 -1
- data/lib/zold/commands/pay.rb +12 -4
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_clean.rb +9 -0
- data/test/commands/test_diff.rb +1 -1
- data/test/commands/test_merge.rb +2 -2
- data/test/commands/test_pay.rb +28 -5
- data/test/commands/test_propagate.rb +1 -1
- data/test/node/test_entrance.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec6ef3362deffe905c48db392a63691b2af28e0e1d7935705a7ccee03f72630
|
4
|
+
data.tar.gz: d8bc9621312050b27e2d25897585f6f8a9b5d2b0f9d4681c9a08e52ad04990d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50bf436dc8d8323b83c7fae037e9de22818921e67ede7d1a2fce49c29dcffe515e1f6695199bbd36ec64668aba138782cdb82725f07ae13c2db74f78f1210b2f
|
7
|
+
data.tar.gz: 603a47739743f9c77c3a4f6208802534d1ad7c59b9a15d5759324c78ddba22939ae7b4b1181181e26b0de2445ac747eef31aab14e45ffbc640d9791ec8b4e7f1
|
data/bin/zold
CHANGED
@@ -201,7 +201,7 @@ cmd = lambda do
|
|
201
201
|
Zold::Invoice.new(wallets: wallets, remotes: remotes, copies: copies, log: log).run(args)
|
202
202
|
when 'pay'
|
203
203
|
require_relative '../lib/zold/commands/pay'
|
204
|
-
Zold::Pay.new(wallets: wallets, remotes: remotes, log: log).run(args)
|
204
|
+
Zold::Pay.new(wallets: wallets, copies: copies, remotes: remotes, log: log).run(args)
|
205
205
|
when 'show'
|
206
206
|
require_relative '../lib/zold/commands/show'
|
207
207
|
Zold::Show.new(wallets: wallets, copies: copies, log: log).run(args)
|
data/lib/zold/commands/pay.rb
CHANGED
@@ -37,9 +37,10 @@ module Zold
|
|
37
37
|
class Pay
|
38
38
|
prepend ThreadBadge
|
39
39
|
|
40
|
-
def initialize(wallets:, remotes:, log: Log::NULL)
|
40
|
+
def initialize(wallets:, remotes:, copies:, log: Log::NULL)
|
41
41
|
@wallets = wallets
|
42
42
|
@remotes = remotes
|
43
|
+
@copies = copies
|
43
44
|
@log = log
|
44
45
|
end
|
45
46
|
|
@@ -59,6 +60,12 @@ Available options:"
|
|
59
60
|
o.bool '--force',
|
60
61
|
'Ignore all validations',
|
61
62
|
default: false
|
63
|
+
o.bool '--tolerate-edges',
|
64
|
+
'Don\'t fail if only "edge" (not "master" ones) nodes have the wallet',
|
65
|
+
default: false
|
66
|
+
o.integer '--tolerate-quorum',
|
67
|
+
'The minimum number of nodes required for a successful fetch (default: 4)',
|
68
|
+
default: 4
|
62
69
|
o.bool '--dont-pay-taxes',
|
63
70
|
'Don\'t pay taxes even if the wallet is in debt',
|
64
71
|
default: false
|
@@ -74,9 +81,10 @@ Available options:"
|
|
74
81
|
invoice = mine[1]
|
75
82
|
unless invoice.include?('@')
|
76
83
|
require_relative 'invoice'
|
77
|
-
invoice = Invoice.new(
|
78
|
-
|
79
|
-
|
84
|
+
invoice = Invoice.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
85
|
+
['invoice', invoice, "--tolerate-quorum=#{opts['tolerate-quorum']}"] +
|
86
|
+
(opts['tolerate-edges'] ? ['--tolerate-edges'] : [])
|
87
|
+
)
|
80
88
|
end
|
81
89
|
raise 'Amount is required (in ZLD) as the third argument' if mine[2].nil?
|
82
90
|
amount = Amount.new(zld: mine[2].to_f)
|
data/lib/zold/version.rb
CHANGED
data/test/commands/test_clean.rb
CHANGED
@@ -44,6 +44,15 @@ class TestClean < Zold::Test
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_clean_no_copies
|
48
|
+
FakeHome.new(log: test_log).run do |home|
|
49
|
+
wallet = home.create_wallet
|
50
|
+
copies = home.copies(wallet)
|
51
|
+
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: test_log).run(['clean'])
|
52
|
+
assert(copies.all.empty?)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
47
56
|
def test_cleans_empty_wallets
|
48
57
|
FakeHome.new(log: test_log).run do |home|
|
49
58
|
Zold::Clean.new(wallets: home.wallets, copies: File.join(home.dir, 'c'), log: test_log).run(['clean'])
|
data/test/commands/test_diff.rb
CHANGED
@@ -46,7 +46,7 @@ class TestDiff < Zold::Test
|
|
46
46
|
IO.write(first.path, IO.read(wallet.path))
|
47
47
|
second = home.create_wallet
|
48
48
|
IO.write(second.path, IO.read(wallet.path))
|
49
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
49
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
50
50
|
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
51
51
|
)
|
52
52
|
copies = home.copies(wallet)
|
data/test/commands/test_merge.rb
CHANGED
@@ -48,7 +48,7 @@ class TestMerge < Zold::Test
|
|
48
48
|
IO.write(first.path, IO.read(wallet.path))
|
49
49
|
second = home.create_wallet
|
50
50
|
IO.write(second.path, IO.read(wallet.path))
|
51
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
51
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
52
52
|
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
53
53
|
)
|
54
54
|
copies = home.copies(wallet)
|
@@ -69,7 +69,7 @@ class TestMerge < Zold::Test
|
|
69
69
|
IO.write(first.path, IO.read(wallet.path))
|
70
70
|
second = home.create_wallet
|
71
71
|
IO.write(second.path, IO.read(wallet.path))
|
72
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
72
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
73
73
|
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
74
74
|
)
|
75
75
|
copies = home.copies(wallet)
|
data/test/commands/test_pay.rb
CHANGED
@@ -21,10 +21,12 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'minitest/autorun'
|
24
|
+
require 'webmock/minitest'
|
24
25
|
require 'threads'
|
25
26
|
require_relative '../test__helper'
|
26
27
|
require_relative '../fake_home'
|
27
28
|
require_relative '../../lib/zold/wallets'
|
29
|
+
require_relative '../../lib/zold/json_page'
|
28
30
|
require_relative '../../lib/zold/amount'
|
29
31
|
require_relative '../../lib/zold/key'
|
30
32
|
require_relative '../../lib/zold/id'
|
@@ -40,7 +42,7 @@ class TestPay < Zold::Test
|
|
40
42
|
source = home.create_wallet
|
41
43
|
target = home.create_wallet
|
42
44
|
amount = Zold::Amount.new(zld: 14.95)
|
43
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
45
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
44
46
|
[
|
45
47
|
'pay', '--force', '--private-key=fixtures/id_rsa',
|
46
48
|
source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
|
@@ -50,12 +52,33 @@ class TestPay < Zold::Test
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
55
|
+
def test_pay_without_invoice
|
56
|
+
FakeHome.new(log: test_log).run do |home|
|
57
|
+
remotes = home.remotes
|
58
|
+
remotes.add('localhost', 4096)
|
59
|
+
json = home.create_wallet_json
|
60
|
+
id = Zold::JsonPage.new(json).to_hash['id']
|
61
|
+
stub_request(:get, "http://localhost:4096/wallet/#{id}/size").to_return(status: 200, body: '10000')
|
62
|
+
stub_request(:get, "http://localhost:4096/wallet/#{id}").to_return(status: 200, body: json)
|
63
|
+
home.wallets.acq(Zold::Id.new(id)) { |w| File.delete(w.path) }
|
64
|
+
source = home.create_wallet
|
65
|
+
amount = Zold::Amount.new(zld: 14.95)
|
66
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: test_log).run(
|
67
|
+
[
|
68
|
+
'pay', '--force', '--private-key=fixtures/id_rsa', '--tolerate-edges', '--tolerate-quorum=1',
|
69
|
+
source.id.to_s, id, amount.to_zld, 'For the car'
|
70
|
+
]
|
71
|
+
)
|
72
|
+
assert_equal(amount * -1, source.balance)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
53
76
|
def test_pay_in_many_threads
|
54
77
|
FakeHome.new(log: test_log).run do |home|
|
55
78
|
wallet = home.create_wallet
|
56
79
|
amount = Zold::Amount.new(zld: 2.0)
|
57
80
|
Threads.new(10).assert do
|
58
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
81
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
59
82
|
[
|
60
83
|
'pay', '--force', '--private-key=fixtures/id_rsa',
|
61
84
|
wallet.id.to_s, 'NOPREFIX@dddd0000dddd0000', amount.to_zld, '-'
|
@@ -71,7 +94,7 @@ class TestPay < Zold::Test
|
|
71
94
|
source = home.create_wallet(Zold::Id::ROOT)
|
72
95
|
target = home.create_wallet
|
73
96
|
amount = Zold::Amount.new(zld: 14.95)
|
74
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
97
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
75
98
|
[
|
76
99
|
'pay', '--private-key=fixtures/id_rsa',
|
77
100
|
source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
|
@@ -92,7 +115,7 @@ class TestPay < Zold::Test
|
|
92
115
|
'NOPREFIX', Zold::Id.new, '-'
|
93
116
|
)
|
94
117
|
)
|
95
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
118
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
96
119
|
[
|
97
120
|
'pay', '--private-key=fixtures/id_rsa',
|
98
121
|
source.id.to_s, target.id.to_s, amount.to_zld, 'here is the refund'
|
@@ -115,7 +138,7 @@ class TestPay < Zold::Test
|
|
115
138
|
(@info_messages ||= []) << message
|
116
139
|
end
|
117
140
|
end
|
118
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: accumulating_log).run(
|
141
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: accumulating_log).run(
|
119
142
|
[
|
120
143
|
'pay', '--force', '--private-key=fixtures/id_rsa',
|
121
144
|
source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
|
@@ -37,7 +37,7 @@ class TestPropagate < Zold::Test
|
|
37
37
|
wallet = home.create_wallet
|
38
38
|
friend = home.create_wallet
|
39
39
|
amount = Zold::Amount.new(zld: 14.95)
|
40
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
40
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
41
41
|
['pay', wallet.id.to_s, friend.id.to_s, amount.to_zld, '--force', '--private-key=fixtures/id_rsa']
|
42
42
|
)
|
43
43
|
Zold::Propagate.new(wallets: home.wallets, log: test_log).run(
|
data/test/node/test_entrance.rb
CHANGED
@@ -42,7 +42,7 @@ class TestEntrance < Zold::Test
|
|
42
42
|
body = FakeHome.new(log: test_log).run do |home|
|
43
43
|
source = home.create_wallet(sid)
|
44
44
|
target = home.create_wallet(tid)
|
45
|
-
Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
|
45
|
+
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
46
46
|
[
|
47
47
|
'pay', '--force', '--private-key=fixtures/id_rsa',
|
48
48
|
source.id.to_s, target.id.to_s, '19.99', 'testing'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -690,7 +690,7 @@ licenses:
|
|
690
690
|
- MIT
|
691
691
|
metadata: {}
|
692
692
|
post_install_message: |-
|
693
|
-
Thanks for installing Zold 0.20.
|
693
|
+
Thanks for installing Zold 0.20.1!
|
694
694
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
695
695
|
Read our blog posts: https://blog.zold.io
|
696
696
|
Try online wallet at: https://wts.zold.io
|