zold 0.19.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/scripts/distribute-wallet.sh +4 -4
- data/fixtures/scripts/pull-on-start.sh +4 -4
- data/fixtures/scripts/push-and-pull.sh +5 -5
- data/fixtures/scripts/redeploy-on-upgrade.sh +1 -1
- data/fixtures/scripts/spread-wallets.sh +3 -3
- data/lib/zold/commands/fetch.rb +13 -1
- data/lib/zold/commands/invoice.rb +4 -1
- data/lib/zold/commands/node.rb +6 -3
- data/lib/zold/commands/push.rb +13 -1
- data/lib/zold/hungry_wallets.rb +9 -1
- data/lib/zold/node/spread_entrance.rb +1 -1
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_fetch.rb +57 -18
- data/test/commands/test_node.rb +2 -2
- data/test/commands/test_pull.rb +17 -1
- data/test/commands/test_push.rb +30 -2
- 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: 4a31487e8700a8c5b7c346e82df8f142931e471a37292df407067320a6a095e9
|
4
|
+
data.tar.gz: ffb06dbf75783b9be9c7b02271bdb5a1a1a70a74b61909cb52f82b24d7ac6ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ded3b0ff00af5ccf51e31d68e5e8593f3a1c0ee5851a3b051ee77b29e9abad1b672f9daca870bcc6805f0089db89c12c92b791d6cdbecc393db0ac9dc607bc
|
7
|
+
data.tar.gz: b7e0bcdf1b27eaefe1ddb141538f0b01a001cdfe3128056c1620c7f8201d6e72e21f0623a7d3c044a08bc1d8ec64e5a8ed067ef9d2267372ebd226d9fa86fd5b
|
@@ -4,7 +4,7 @@ function start_node {
|
|
4
4
|
port=$(reserve_port)
|
5
5
|
mkdir ${port}
|
6
6
|
cd ${port}
|
7
|
-
zold node --trace --invoice=DISTRWALLET@ffffffffffffffff --tolerate-edges \
|
7
|
+
zold node --trace --invoice=DISTRWALLET@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
|
8
8
|
--host=127.0.0.1 --port=${port} --bind-port=${port} \
|
9
9
|
--threads=0 --routine-immediately --never-reboot > log.txt 2>&1 &
|
10
10
|
pid=$!
|
@@ -36,7 +36,7 @@ zold --public-key=id_rsa.pub create 0000000000000000
|
|
36
36
|
zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4.95 'For the book'
|
37
37
|
zold remote clean
|
38
38
|
zold remote add 127.0.0.1 ${first}
|
39
|
-
zold push 0000000000000000 --tolerate-edges
|
39
|
+
zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
|
40
40
|
zold remote clean
|
41
41
|
zold remote add 127.0.0.1 ${second}
|
42
42
|
|
@@ -45,7 +45,7 @@ zold remote add 127.0.0.1 ${second}
|
|
45
45
|
# delay between them, in order to give the first node a chance to distribute
|
46
46
|
# the wallet.
|
47
47
|
i=0
|
48
|
-
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges; do
|
48
|
+
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
|
49
49
|
echo 'Failed to fetch, let us try again'
|
50
50
|
((i++)) || sleep 0
|
51
51
|
if ((i==5)); then
|
@@ -73,7 +73,7 @@ fi
|
|
73
73
|
# have the wallet very soon.
|
74
74
|
rm -f ${second}/**/*.z
|
75
75
|
i=0
|
76
|
-
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges; do
|
76
|
+
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
|
77
77
|
echo 'Failed to fetch, let us try again'
|
78
78
|
((i++)) || sleep 0
|
79
79
|
if ((i==5)); then
|
@@ -4,7 +4,7 @@ port=$(reserve_port)
|
|
4
4
|
mkdir server
|
5
5
|
cd server
|
6
6
|
zold remote clean
|
7
|
-
zold node --trace --invoice=PULLONSTART@ffffffffffffffff --no-metronome --tolerate-edges \
|
7
|
+
zold node --trace --invoice=PULLONSTART@ffffffffffffffff --no-metronome --tolerate-edges --tolerate-quorum=1 \
|
8
8
|
--host=127.0.0.1 --port=${port} --bind-port=${port} \
|
9
9
|
--threads=0 --standalone --pretty=full 2>&1 &
|
10
10
|
cd ..
|
@@ -15,16 +15,16 @@ zold remote clean
|
|
15
15
|
zold remote add 127.0.0.1 ${port}
|
16
16
|
|
17
17
|
zold --public-key=id_rsa.pub create abcdabcdabcdabcd
|
18
|
-
zold push abcdabcdabcdabcd --tolerate-edges
|
18
|
+
zold push abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
|
19
19
|
zold remove abcdabcdabcdabcd
|
20
|
-
zold invoice abcdabcdabcdabcd --tolerate-edges
|
20
|
+
zold invoice abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
|
21
21
|
|
22
22
|
second_port=$(reserve_port)
|
23
23
|
mkdir second
|
24
24
|
cd second
|
25
25
|
zold remote clean
|
26
26
|
zold remote add 127.0.0.1 ${port}
|
27
|
-
zold node --trace --invoice=abcdabcdabcdabcd --no-metronome --tolerate-edges \
|
27
|
+
zold node --trace --invoice=abcdabcdabcdabcd --no-metronome --tolerate-edges --tolerate-quorum=1 \
|
28
28
|
--host=127.0.0.1 --port=${second_port} --bind-port=${second_port} \
|
29
29
|
--threads=0 &
|
30
30
|
|
@@ -4,7 +4,7 @@ port=$(reserve_port)
|
|
4
4
|
|
5
5
|
mkdir server
|
6
6
|
cd server
|
7
|
-
zold node --trace --invoice=PUSHNPULL@ffffffffffffffff --tolerate-edges \
|
7
|
+
zold node --trace --invoice=PUSHNPULL@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
|
8
8
|
--host=127.0.0.1 --port=${port} --bind-port=${port} \
|
9
9
|
--threads=0 --standalone 2>&1 &
|
10
10
|
pid=$!
|
@@ -29,13 +29,13 @@ zold show 0000000000000000
|
|
29
29
|
zold taxes debt 0000000000000000
|
30
30
|
|
31
31
|
zold remote show
|
32
|
-
zold push --tolerate-edges
|
33
|
-
zold push 0000000000000000 --tolerate-edges
|
34
|
-
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges; do
|
32
|
+
zold push --tolerate-edges --tolerate-quorum=1
|
33
|
+
zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
|
34
|
+
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
|
35
35
|
echo 'Failed to fetch, let us try again'
|
36
36
|
sleep 1
|
37
37
|
done
|
38
|
-
zold fetch --tolerate-edges
|
38
|
+
zold fetch --tolerate-edges --tolerate-quorum=1
|
39
39
|
zold diff 0000000000000000
|
40
40
|
zold merge
|
41
41
|
zold merge 0000000000000000
|
@@ -5,7 +5,7 @@ function start_node {
|
|
5
5
|
cd $1
|
6
6
|
zold remote clean
|
7
7
|
zold node $3 --nohup --nohup-command='touch restarted' --nohup-log=log --nohup-max-cycles=0 --nohup-log-truncate=10240 \
|
8
|
-
--expose-version=$2 --save-pid=pid --routine-immediately --tolerate-edges \
|
8
|
+
--expose-version=$2 --save-pid=pid --routine-immediately --tolerate-edges --tolerate-quorum=1 \
|
9
9
|
--verbose --trace --invoice=REDEPLOY@ffffffffffffffff \
|
10
10
|
--host=127.0.0.1 --port=$1 --bind-port=$1 --threads=1 --strength=20 > /dev/null 2>&1
|
11
11
|
wait_for_port $1
|
@@ -5,7 +5,7 @@ function start_node {
|
|
5
5
|
mkdir ${port}
|
6
6
|
cd ${port}
|
7
7
|
zold remote clean
|
8
|
-
zold node --trace --invoice=SPREADWALLETS@ffffffffffffffff --tolerate-edges \
|
8
|
+
zold node --trace --invoice=SPREADWALLETS@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
|
9
9
|
--host=127.0.0.1 --port=${port} --bind-port=${port} \
|
10
10
|
--threads=0 > log.txt 2>&1 &
|
11
11
|
pid=$!
|
@@ -26,12 +26,12 @@ zold --public-key=id_rsa.pub create 0000000000000000
|
|
26
26
|
zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4.95 'To help you, dude!'
|
27
27
|
zold remote clean
|
28
28
|
zold remote add 127.0.0.1 ${first}
|
29
|
-
zold push 0000000000000000 --tolerate-edges
|
29
|
+
zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
|
30
30
|
zold remote clean
|
31
31
|
zold remote add 127.0.0.1 ${second}
|
32
32
|
|
33
33
|
i=0
|
34
|
-
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges; do
|
34
|
+
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
|
35
35
|
echo 'Failed to fetch, let us try again'
|
36
36
|
((i++)) || sleep 0
|
37
37
|
if ((i==5)); then
|
data/lib/zold/commands/fetch.rb
CHANGED
@@ -49,6 +49,12 @@ module Zold
|
|
49
49
|
class Fetch
|
50
50
|
prepend ThreadBadge
|
51
51
|
|
52
|
+
# Raises when there are only edge nodes and not a single master one.
|
53
|
+
class EdgesOnly < StandardError; end
|
54
|
+
|
55
|
+
# Raises when there are not enough successful nodes.
|
56
|
+
class NoQuorum < StandardError; end
|
57
|
+
|
52
58
|
def initialize(wallets:, remotes:, copies:, log: Log::NULL)
|
53
59
|
@wallets = wallets
|
54
60
|
@remotes = remotes
|
@@ -69,6 +75,9 @@ Available options:"
|
|
69
75
|
o.bool '--tolerate-edges',
|
70
76
|
'Don\'t fail if only "edge" (not "master" ones) nodes accepted the wallet',
|
71
77
|
default: false
|
78
|
+
o.integer '--tolerate-quorum',
|
79
|
+
'The minimum number of nodes required for a successful fetch (default: 4)',
|
80
|
+
default: 4
|
72
81
|
o.bool '--quiet-if-absent',
|
73
82
|
'Don\'t fail if the wallet is absent in all remote nodes',
|
74
83
|
default: false
|
@@ -105,7 +114,10 @@ Available options:"
|
|
105
114
|
unless opts['quiet-if-absent']
|
106
115
|
raise "No nodes out of #{nodes.value} have the wallet #{id}" if done.value.zero?
|
107
116
|
if masters.value.zero? && !opts['tolerate-edges']
|
108
|
-
raise "There are only edge nodes, run 'zold remote reset' or use --tolerate-edges"
|
117
|
+
raise EdgesOnly, "There are only edge nodes, run 'zold remote reset' or use --tolerate-edges"
|
118
|
+
end
|
119
|
+
if nodes.value < opts['tolerate-quorum']
|
120
|
+
raise NoQuorum, "There were not enough nodes, run 'zold remote reset' or use --tolerate-quorum=1"
|
109
121
|
end
|
110
122
|
end
|
111
123
|
@log.info("#{done.value} copies of #{id} fetched in #{Age.new(start)} with the total score of \
|
@@ -54,6 +54,9 @@ Available options:"
|
|
54
54
|
o.bool '--tolerate-edges',
|
55
55
|
'Don\'t fail if only "edge" (not "master" ones) nodes have the wallet',
|
56
56
|
default: false
|
57
|
+
o.integer '--tolerate-quorum',
|
58
|
+
'The minimum number of nodes required for a successful fetch (default: 4)',
|
59
|
+
default: 4
|
57
60
|
o.string '--network',
|
58
61
|
'The name of the network we work in',
|
59
62
|
default: 'test'
|
@@ -70,7 +73,7 @@ Available options:"
|
|
70
73
|
unless @wallets.acq(id, &:exists?)
|
71
74
|
require_relative 'pull'
|
72
75
|
Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
73
|
-
['pull', id.to_s, "--network=#{opts['network']}"] +
|
76
|
+
['pull', id.to_s, "--network=#{opts['network']}", "--tolerate-quorum=#{opts['tolerate-quorum']}"] +
|
74
77
|
(opts['tolerate-edges'] ? ['--tolerate-edges'] : [])
|
75
78
|
)
|
76
79
|
end
|
data/lib/zold/commands/node.rb
CHANGED
@@ -100,6 +100,9 @@ module Zold
|
|
100
100
|
o.bool '--tolerate-edges',
|
101
101
|
'Don\'t fail if only "edge" (not "master" ones) nodes accepted/have the wallet',
|
102
102
|
default: false
|
103
|
+
o.integer '--tolerate-quorum',
|
104
|
+
'The minimum number of nodes required for a successful fetch (default: 4)',
|
105
|
+
default: 4
|
103
106
|
o.boolean '--nohup',
|
104
107
|
'Run it in background, rebooting when a higher version is available in the network',
|
105
108
|
default: false
|
@@ -136,8 +139,8 @@ module Zold
|
|
136
139
|
'Skip Out Of Memory check and never exit, no matter how much RAM is consumed',
|
137
140
|
default: false
|
138
141
|
o.integer '--oom-limit',
|
139
|
-
'Maximum amount of memory we can consume, quit if we take more than that, in Mb (default:
|
140
|
-
default:
|
142
|
+
'Maximum amount of memory we can consume, quit if we take more than that, in Mb (default: 256)',
|
143
|
+
default: 256
|
141
144
|
o.integer '--queue-limit',
|
142
145
|
'The maximum number of wallets to be accepted via PUSH and stored in the queue (default: 256)',
|
143
146
|
default: 256
|
@@ -287,7 +290,7 @@ module Zold
|
|
287
290
|
unless invoice.include?('@')
|
288
291
|
require_relative 'invoice'
|
289
292
|
invoice = Invoice.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
290
|
-
['invoice', invoice, "--network=#{opts['network']}"] +
|
293
|
+
['invoice', invoice, "--network=#{opts['network']}", "--tolerate-quorum=#{opts['tolerate-quorum']}"] +
|
291
294
|
(opts['tolerate-edges'] ? ['--tolerate-edges'] : [])
|
292
295
|
)
|
293
296
|
end
|
data/lib/zold/commands/push.rb
CHANGED
@@ -45,6 +45,12 @@ module Zold
|
|
45
45
|
class Push
|
46
46
|
prepend ThreadBadge
|
47
47
|
|
48
|
+
# Raises when there are only edge nodes and not a single master one.
|
49
|
+
class EdgesOnly < StandardError; end
|
50
|
+
|
51
|
+
# Raises when there are not enough successful nodes.
|
52
|
+
class NoQuorum < StandardError; end
|
53
|
+
|
48
54
|
def initialize(wallets:, remotes:, log: Log::NULL)
|
49
55
|
@wallets = wallets
|
50
56
|
@remotes = remotes
|
@@ -61,6 +67,9 @@ Available options:"
|
|
61
67
|
o.bool '--tolerate-edges',
|
62
68
|
'Don\'t fail if only "edge" (not "master" ones) nodes accepted the wallet',
|
63
69
|
default: false
|
70
|
+
o.integer '--tolerate-quorum',
|
71
|
+
'The minimum number of nodes required for a successful fetch (default: 4)',
|
72
|
+
default: 4
|
64
73
|
o.bool '--quiet-if-missed',
|
65
74
|
'Don\'t fail if the wallet wasn\'t delivered to any remotes',
|
66
75
|
default: false
|
@@ -97,7 +106,10 @@ Available options:"
|
|
97
106
|
unless opts['quiet-if-missed']
|
98
107
|
raise "No nodes out of #{nodes} accepted the wallet #{id}" if done.value.zero?
|
99
108
|
if masters.value.zero? && !opts['tolerate-edges']
|
100
|
-
raise "There are only edge nodes, run 'zold remote reset' or use --tolerate-edges"
|
109
|
+
raise EdgesOnly, "There are only edge nodes, run 'zold remote reset' or use --tolerate-edges"
|
110
|
+
end
|
111
|
+
if nodes.value < opts['tolerate-quorum']
|
112
|
+
raise NoQuorum, "There were not enough nodes, run 'zold remote reset' or use --tolerate-quorum=1"
|
101
113
|
end
|
102
114
|
end
|
103
115
|
@log.info("Push finished to #{done.value} nodes (#{masters.value} master nodes) \
|
data/lib/zold/hungry_wallets.rb
CHANGED
@@ -48,6 +48,8 @@ module Zold
|
|
48
48
|
Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
49
49
|
['pull', id.to_s, "--network=#{@network}"]
|
50
50
|
)
|
51
|
+
rescue Pull::EdgesOnly => e
|
52
|
+
@log.error("Can't hungry-pull #{id}: #{e.message}")
|
51
53
|
end
|
52
54
|
end
|
53
55
|
super(wallets)
|
@@ -55,7 +57,13 @@ module Zold
|
|
55
57
|
|
56
58
|
def acq(id, exclusive: false)
|
57
59
|
@wallets.acq(id, exclusive: exclusive) do |wallet|
|
58
|
-
|
60
|
+
unless wallet.exists?
|
61
|
+
if @queue.size > 256
|
62
|
+
@log.error("Hungry queue is full with #{@queue.size} wallets, can't add #{id}")
|
63
|
+
else
|
64
|
+
@queue << id
|
65
|
+
end
|
66
|
+
end
|
59
67
|
yield wallet
|
60
68
|
end
|
61
69
|
end
|
@@ -76,7 +76,7 @@ module Zold
|
|
76
76
|
else
|
77
77
|
Thread.current.thread_variable_set(:wallet, id.to_s)
|
78
78
|
Push.new(wallets: @wallets, remotes: @remotes, log: @log).run(
|
79
|
-
['push', "--ignore-node=#{@address}", id.to_s] +
|
79
|
+
['push', "--ignore-node=#{@address}", id.to_s, '--tolerate-quorum=1'] +
|
80
80
|
(@ignore_score_weakeness ? ['--ignore-score-weakness'] : []) +
|
81
81
|
(@tolerate_edges ? ['--tolerate-edges'] : [])
|
82
82
|
)
|
data/lib/zold/version.rb
CHANGED
data/test/commands/test_fetch.rb
CHANGED
@@ -59,15 +59,9 @@ class TestFetch < Zold::Test
|
|
59
59
|
remotes.add('localhost', 4096)
|
60
60
|
remotes.add('localhost', 81)
|
61
61
|
copies = home.copies(wallet)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
['fetch', '--ignore-score-weakness', wallet.id.to_s]
|
66
|
-
)
|
67
|
-
rescue StandardError => _
|
68
|
-
sleep 1
|
69
|
-
retry if (retries += 1) < 3
|
70
|
-
end
|
62
|
+
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: test_log).run(
|
63
|
+
['fetch', '--tolerate-edges', '--tolerate-quorum=1', '--ignore-score-weakness', wallet.id.to_s]
|
64
|
+
)
|
71
65
|
assert_equal(1, copies.all.count)
|
72
66
|
assert_equal('1', copies.all[0][:name])
|
73
67
|
assert_equal(0, copies.all[0][:score])
|
@@ -103,15 +97,12 @@ class TestFetch < Zold::Test
|
|
103
97
|
remotes.add('localhost', 4096)
|
104
98
|
copies_a = home.copies(wallet_a)
|
105
99
|
copies_b = home.copies(wallet_b)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
sleep 1
|
113
|
-
retry if (retries += 1) < 3
|
114
|
-
end
|
100
|
+
Zold::Fetch.new(wallets: home.wallets, copies: copies_a.root, remotes: remotes, log: log).run(
|
101
|
+
[
|
102
|
+
'fetch', '--tolerate-edges', '--tolerate-quorum=1', '--ignore-score-weakness',
|
103
|
+
'--threads 2', wallet_a.id.to_s, wallet_b.id.to_s
|
104
|
+
]
|
105
|
+
)
|
115
106
|
assert_equal(1, copies_a.all.count)
|
116
107
|
assert_equal('1', copies_a.all[0][:name])
|
117
108
|
assert_equal(0, copies_a.all[0][:score])
|
@@ -120,4 +111,52 @@ class TestFetch < Zold::Test
|
|
120
111
|
assert_equal(0, copies_b.all[0][:score])
|
121
112
|
end
|
122
113
|
end
|
114
|
+
|
115
|
+
def test_fails_when_only_edge_nodes
|
116
|
+
FakeHome.new(log: test_log).run do |home|
|
117
|
+
wallet = home.create_wallet
|
118
|
+
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}/size")
|
119
|
+
.to_return(status: 200, body: wallet.size.to_s)
|
120
|
+
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
121
|
+
status: 200,
|
122
|
+
body: {
|
123
|
+
'score': Zold::Score::ZERO.to_h,
|
124
|
+
'body': IO.read(wallet.path),
|
125
|
+
'mtime': Time.now.utc.iso8601
|
126
|
+
}.to_json
|
127
|
+
)
|
128
|
+
remotes = home.remotes
|
129
|
+
remotes.add('localhost', 4096)
|
130
|
+
copies = home.copies(wallet)
|
131
|
+
assert_raises Zold::Fetch::EdgesOnly do
|
132
|
+
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: test_log).run(
|
133
|
+
['fetch', '--ignore-score-weakness', wallet.id.to_s]
|
134
|
+
)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_fails_when_only_one_node
|
140
|
+
FakeHome.new(log: test_log).run do |home|
|
141
|
+
wallet = home.create_wallet
|
142
|
+
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}/size")
|
143
|
+
.to_return(status: 200, body: wallet.size.to_s)
|
144
|
+
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
145
|
+
status: 200,
|
146
|
+
body: {
|
147
|
+
'score': Zold::Score::ZERO.to_h,
|
148
|
+
'body': IO.read(wallet.path),
|
149
|
+
'mtime': Time.now.utc.iso8601
|
150
|
+
}.to_json
|
151
|
+
)
|
152
|
+
remotes = home.remotes
|
153
|
+
remotes.add('localhost', 4096)
|
154
|
+
copies = home.copies(wallet)
|
155
|
+
assert_raises Zold::Fetch::NoQuorum do
|
156
|
+
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: test_log).run(
|
157
|
+
['fetch', '--tolerate-edges', '--ignore-score-weakness', wallet.id.to_s]
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
123
162
|
end
|
data/test/commands/test_node.rb
CHANGED
@@ -47,7 +47,7 @@ class TestNode < Zold::Test
|
|
47
47
|
remotes = home.remotes
|
48
48
|
remotes.add('localhost', port)
|
49
49
|
Zold::Push.new(wallets: wallets, remotes: remotes, log: test_log).run(
|
50
|
-
['push', '--ignore-score-weakness', '--tolerate-edges']
|
50
|
+
['push', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1']
|
51
51
|
)
|
52
52
|
copies = home.copies(wallet)
|
53
53
|
begin
|
@@ -55,7 +55,7 @@ class TestNode < Zold::Test
|
|
55
55
|
Zold::Fetch.new(
|
56
56
|
wallets: wallets, copies: copies.root,
|
57
57
|
remotes: remotes, log: test_log
|
58
|
-
).run(['fetch', '--ignore-score-weakness', '--tolerate-edges'])
|
58
|
+
).run(['fetch', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1'])
|
59
59
|
rescue StandardError => _
|
60
60
|
sleep 1
|
61
61
|
retry if (retries += 1) < 3
|
data/test/commands/test_pull.rb
CHANGED
@@ -42,11 +42,27 @@ class TestPull < Zold::Test
|
|
42
42
|
stub_request(:get, "http://localhost:4096/wallet/#{id}/size").to_return(status: 200, body: '10000')
|
43
43
|
stub_request(:get, "http://localhost:4096/wallet/#{id}").to_return(status: 200, body: json)
|
44
44
|
Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: test_log).run(
|
45
|
-
['--ignore-this-stupid-option', 'pull', id.to_s, '--tolerate-edges']
|
45
|
+
['--ignore-this-stupid-option', 'pull', id.to_s, '--tolerate-edges', '--tolerate-quorum=1']
|
46
46
|
)
|
47
47
|
home.wallets.acq(Zold::Id.new(id)) do |wallet|
|
48
48
|
assert(wallet.exists?)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def test_fails_when_only_edge_nodes
|
54
|
+
FakeHome.new(log: test_log).run do |home|
|
55
|
+
remotes = home.remotes
|
56
|
+
remotes.add('localhost', 4096)
|
57
|
+
json = home.create_wallet_json
|
58
|
+
id = Zold::JsonPage.new(json).to_hash['id']
|
59
|
+
stub_request(:get, "http://localhost:4096/wallet/#{id}/size").to_return(status: 200, body: '10000')
|
60
|
+
stub_request(:get, "http://localhost:4096/wallet/#{id}").to_return(status: 200, body: json)
|
61
|
+
assert_raises Zold::Fetch::EdgesOnly do
|
62
|
+
Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: test_log).run(
|
63
|
+
['--ignore-this-stupid-option', 'pull', id.to_s]
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
52
68
|
end
|
data/test/commands/test_push.rb
CHANGED
@@ -43,7 +43,7 @@ class TestPush < Zold::Test
|
|
43
43
|
remotes.add('localhost', 80)
|
44
44
|
stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
|
45
45
|
Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
|
46
|
-
['--ignore-this-stupid-option', 'push', wallet.id.to_s, '--tolerate-edges']
|
46
|
+
['--ignore-this-stupid-option', 'push', wallet.id.to_s, '--tolerate-edges', '--tolerate-quorum=1']
|
47
47
|
)
|
48
48
|
end
|
49
49
|
end
|
@@ -58,8 +58,36 @@ class TestPush < Zold::Test
|
|
58
58
|
stub_request(:put, "http://localhost:80/wallet/#{wallet_a.id}").to_return(status: 304)
|
59
59
|
stub_request(:put, "http://localhost:80/wallet/#{wallet_b.id}").to_return(status: 304)
|
60
60
|
Zold::Push.new(wallets: home.wallets, remotes: remotes, log: log).run(
|
61
|
-
['--tolerate-edges', '--threads=2', 'push', wallet_a.id.to_s, wallet_b.id.to_s]
|
61
|
+
['--tolerate-edges', '--tolerate-quorum=1', '--threads=2', 'push', wallet_a.id.to_s, wallet_b.id.to_s]
|
62
62
|
)
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
def test_fails_when_only_edge_nodes
|
67
|
+
FakeHome.new(log: test_log).run do |home|
|
68
|
+
wallet = home.create_wallet
|
69
|
+
remotes = home.remotes
|
70
|
+
remotes.add('localhost', 80)
|
71
|
+
stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
|
72
|
+
assert_raises Zold::Push::EdgesOnly do
|
73
|
+
Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
|
74
|
+
['push', wallet.id.to_s]
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_fails_when_only_one_node
|
81
|
+
FakeHome.new(log: test_log).run do |home|
|
82
|
+
wallet = home.create_wallet
|
83
|
+
remotes = home.remotes
|
84
|
+
remotes.add('localhost', 80)
|
85
|
+
stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
|
86
|
+
assert_raises Zold::Push::NoQuorum do
|
87
|
+
Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
|
88
|
+
['push', wallet.id.to_s, '--tolerate-edges']
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
65
93
|
end
|
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.19.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -690,7 +690,7 @@ licenses:
|
|
690
690
|
- MIT
|
691
691
|
metadata: {}
|
692
692
|
post_install_message: |-
|
693
|
-
Thanks for installing Zold 0.19.
|
693
|
+
Thanks for installing Zold 0.19.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
|