zold 0.31.9 → 0.32.0

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.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +2 -19
  3. data/.github/typos.toml +11 -0
  4. data/.github/workflows/actionlint.yml +5 -21
  5. data/.github/workflows/bashate.yml +25 -0
  6. data/.github/workflows/codecov.yml +11 -24
  7. data/.github/workflows/copyrights.yml +6 -21
  8. data/.github/workflows/hadolint.yml +14 -0
  9. data/.github/workflows/markdown-lint.yml +19 -0
  10. data/.github/workflows/pdd.yml +5 -20
  11. data/.github/workflows/rake.yml +8 -22
  12. data/.github/workflows/reuse.yml +19 -0
  13. data/.github/workflows/shellcheck.yml +19 -0
  14. data/.github/workflows/typos.yml +21 -0
  15. data/.github/workflows/xcop.yml +5 -20
  16. data/.github/workflows/yamllint.yml +5 -20
  17. data/.gitignore +9 -6
  18. data/.rubocop.yml +16 -20
  19. data/.ruby-version +1 -1
  20. data/.rultor.yml +6 -22
  21. data/Dockerfile +11 -27
  22. data/Gemfile +21 -33
  23. data/Gemfile.lock +185 -130
  24. data/Guardfile +0 -0
  25. data/INSTALL.md +80 -59
  26. data/LICENSE.txt +1 -1
  27. data/LICENSES/MIT.txt +21 -0
  28. data/README.md +183 -154
  29. data/REUSE.toml +40 -0
  30. data/Rakefile +4 -38
  31. data/bin/zold +7 -37
  32. data/cucumber.yml +2 -19
  33. data/deploy.sh +4 -22
  34. data/features/cli.feature +2 -0
  35. data/features/gem_package.feature +2 -0
  36. data/features/step_definitions/steps.rb +2 -19
  37. data/features/support/env.rb +2 -19
  38. data/fixtures/merge/asserts.rb +3 -19
  39. data/fixtures/merge/into_no_wallet/assert.rb +2 -19
  40. data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -19
  41. data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +1 -1
  42. data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -2
  43. data/fixtures/merge/missed_wallets/assert.rb +2 -19
  44. data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +1 -1
  45. data/fixtures/merge/negative_overwriting/assert.rb +2 -19
  46. data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -1
  47. data/fixtures/merge/negatives_in_between/assert.rb +2 -19
  48. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -1
  49. data/fixtures/merge/negatives_in_between/opts +1 -1
  50. data/fixtures/merge/random_expenses/assert.rb +2 -19
  51. data/fixtures/merge/random_expenses/opts +1 -1
  52. data/fixtures/merge/simple_case/assert.rb +2 -19
  53. data/fixtures/merge/simple_case/opts +1 -1
  54. data/fixtures/merge/unconfirmed_income/assert.rb +2 -19
  55. data/fixtures/scripts/_head.sh +16 -33
  56. data/fixtures/scripts/calculate-scores.sh +3 -20
  57. data/fixtures/scripts/distribute-wallet.sh +26 -43
  58. data/fixtures/scripts/print-helps.sh +5 -23
  59. data/fixtures/scripts/pull-on-start.sh +12 -29
  60. data/fixtures/scripts/push-and-pull.sh +10 -27
  61. data/fixtures/scripts/redeploy-on-upgrade.sh +18 -34
  62. data/fixtures/scripts/spread-wallets.sh +24 -40
  63. data/lib/zold/age.rb +3 -20
  64. data/lib/zold/amount.rb +3 -20
  65. data/lib/zold/cached_wallets.rb +3 -20
  66. data/lib/zold/commands/alias.rb +4 -21
  67. data/lib/zold/commands/args.rb +4 -21
  68. data/lib/zold/commands/calculate.rb +5 -22
  69. data/lib/zold/commands/clean.rb +6 -23
  70. data/lib/zold/commands/create.rb +5 -22
  71. data/lib/zold/commands/diff.rb +5 -22
  72. data/lib/zold/commands/fetch.rb +6 -23
  73. data/lib/zold/commands/invoice.rb +5 -22
  74. data/lib/zold/commands/list.rb +5 -22
  75. data/lib/zold/commands/merge.rb +7 -24
  76. data/lib/zold/commands/next.rb +5 -22
  77. data/lib/zold/commands/node.rb +4 -21
  78. data/lib/zold/commands/pay.rb +6 -23
  79. data/lib/zold/commands/propagate.rb +5 -22
  80. data/lib/zold/commands/pull.rb +5 -22
  81. data/lib/zold/commands/push.rb +5 -22
  82. data/lib/zold/commands/remote.rb +7 -24
  83. data/lib/zold/commands/remove.rb +5 -22
  84. data/lib/zold/commands/routines/audit.rb +4 -21
  85. data/lib/zold/commands/routines/gc.rb +6 -23
  86. data/lib/zold/commands/routines/reconcile.rb +5 -22
  87. data/lib/zold/commands/routines/reconnect.rb +4 -21
  88. data/lib/zold/commands/routines/retire.rb +4 -21
  89. data/lib/zold/commands/routines/spread.rb +5 -22
  90. data/lib/zold/commands/routines.rb +3 -20
  91. data/lib/zold/commands/show.rb +5 -22
  92. data/lib/zold/commands/taxes.rb +5 -22
  93. data/lib/zold/commands/thread_badge.rb +3 -20
  94. data/lib/zold/copies.rb +6 -25
  95. data/lib/zold/dir_items.rb +3 -20
  96. data/lib/zold/endless.rb +5 -22
  97. data/lib/zold/gem.rb +3 -20
  98. data/lib/zold/hands.rb +6 -23
  99. data/lib/zold/head.rb +4 -21
  100. data/lib/zold/hexnum.rb +3 -20
  101. data/lib/zold/http.rb +3 -20
  102. data/lib/zold/hungry_wallets.rb +6 -23
  103. data/lib/zold/id.rb +3 -20
  104. data/lib/zold/json_page.rb +5 -22
  105. data/lib/zold/key.rb +3 -20
  106. data/lib/zold/metronome.rb +5 -22
  107. data/lib/zold/node/async_entrance.rb +6 -23
  108. data/lib/zold/node/entrance.rb +7 -24
  109. data/lib/zold/node/farm.rb +5 -22
  110. data/lib/zold/node/farmers.rb +15 -32
  111. data/lib/zold/node/front.rb +6 -23
  112. data/lib/zold/node/journaled_pipeline.rb +8 -25
  113. data/lib/zold/node/nodup_entrance.rb +6 -23
  114. data/lib/zold/node/nospam_entrance.rb +6 -23
  115. data/lib/zold/node/pipeline.rb +6 -23
  116. data/lib/zold/node/safe_entrance.rb +4 -22
  117. data/lib/zold/node/soft_error.rb +3 -20
  118. data/lib/zold/node/spread_entrance.rb +5 -22
  119. data/lib/zold/node/sync_entrance.rb +5 -22
  120. data/lib/zold/node/trace.rb +3 -20
  121. data/lib/zold/patch.rb +6 -23
  122. data/lib/zold/prefixes.rb +3 -20
  123. data/lib/zold/remotes.rb +5 -22
  124. data/lib/zold/signature.rb +3 -20
  125. data/lib/zold/size.rb +3 -20
  126. data/lib/zold/sync_wallets.rb +5 -22
  127. data/lib/zold/tax.rb +4 -21
  128. data/lib/zold/thread_pool.rb +4 -21
  129. data/lib/zold/tree_wallets.rb +3 -20
  130. data/lib/zold/txn.rb +4 -21
  131. data/lib/zold/txns.rb +4 -21
  132. data/lib/zold/upgrades.rb +4 -21
  133. data/lib/zold/verbose_thread.rb +5 -22
  134. data/lib/zold/version.rb +4 -21
  135. data/lib/zold/version_file.rb +4 -21
  136. data/lib/zold/wallet.rb +6 -23
  137. data/lib/zold/wallets.rb +5 -23
  138. data/lib/zold.rb +3 -21
  139. data/resources/banned-wallets.log +6 -6
  140. data/test/commands/routines/test_audit.rb +3 -21
  141. data/test/commands/routines/test_gc.rb +3 -21
  142. data/test/commands/routines/test_reconcile.rb +3 -21
  143. data/test/commands/routines/test_reconnect.rb +3 -21
  144. data/test/commands/routines/test_retire.rb +3 -21
  145. data/test/commands/test_alias.rb +2 -20
  146. data/test/commands/test_calculate.rb +5 -23
  147. data/test/commands/test_clean.rb +5 -23
  148. data/test/commands/test_create.rb +6 -24
  149. data/test/commands/test_diff.rb +4 -22
  150. data/test/commands/test_fetch.rb +3 -21
  151. data/test/commands/test_invoice.rb +3 -21
  152. data/test/commands/test_list.rb +3 -21
  153. data/test/commands/test_merge.rb +12 -35
  154. data/test/commands/test_node.rb +3 -21
  155. data/test/commands/test_pay.rb +5 -23
  156. data/test/commands/test_propagate.rb +6 -24
  157. data/test/commands/test_pull.rb +4 -22
  158. data/test/commands/test_push.rb +3 -21
  159. data/test/commands/test_remote.rb +10 -28
  160. data/test/commands/test_remove.rb +7 -25
  161. data/test/commands/test_show.rb +3 -21
  162. data/test/commands/test_taxes.rb +5 -23
  163. data/test/fake_home.rb +5 -22
  164. data/test/node/fake_entrance.rb +3 -20
  165. data/test/node/fake_node.rb +5 -22
  166. data/test/node/test_async_entrance.rb +3 -21
  167. data/test/node/test_entrance.rb +7 -25
  168. data/test/node/test_farm.rb +15 -33
  169. data/test/node/test_farmers.rb +3 -21
  170. data/test/node/test_front.rb +22 -42
  171. data/test/node/test_nodup_entrance.rb +4 -22
  172. data/test/node/test_nospam_entrance.rb +6 -24
  173. data/test/node/test_safe_entrance.rb +3 -21
  174. data/test/node/test_spread_entrance.rb +4 -22
  175. data/test/node/test_sync_entrance.rb +4 -22
  176. data/test/node/test_trace.rb +4 -22
  177. data/test/test__helper.rb +32 -31
  178. data/test/test_age.rb +5 -23
  179. data/test/test_amount.rb +15 -34
  180. data/test/test_cached_wallets.rb +3 -21
  181. data/test/test_copies.rb +10 -28
  182. data/test/test_dir_items.rb +4 -22
  183. data/test/test_gem.rb +3 -21
  184. data/test/test_hands.rb +3 -21
  185. data/test/test_hexnum.rb +3 -21
  186. data/test/test_http.rb +9 -27
  187. data/test/test_hungry_wallets.rb +6 -24
  188. data/test/test_id.rb +10 -28
  189. data/test/test_json_page.rb +3 -21
  190. data/test/test_key.rb +5 -23
  191. data/test/test_metronome.rb +6 -24
  192. data/test/test_patch.rb +10 -28
  193. data/test/test_prefixes.rb +3 -21
  194. data/test/test_remotes.rb +17 -35
  195. data/test/test_signature.rb +3 -21
  196. data/test/test_size.rb +3 -21
  197. data/test/test_sync_wallets.rb +3 -21
  198. data/test/test_tax.rb +6 -24
  199. data/test/test_thread_pool.rb +6 -24
  200. data/test/test_tree_wallets.rb +4 -22
  201. data/test/test_txn.rb +3 -21
  202. data/test/test_upgrades.rb +3 -21
  203. data/test/test_verbose_thread.rb +6 -24
  204. data/test/test_version.rb +2 -20
  205. data/test/test_wallet.rb +15 -33
  206. data/test/test_wallets.rb +4 -22
  207. data/test/test_zold.rb +7 -25
  208. data/test/upgrades/test_delete_banned_wallets.rb +4 -22
  209. data/test/upgrades/test_protocol_up.rb +3 -21
  210. data/upgrades/2.rb +3 -20
  211. data/upgrades/delete_banned_wallets.rb +3 -20
  212. data/upgrades/move_wallets_into_tree.rb +3 -20
  213. data/upgrades/protocol_up.rb +3 -20
  214. data/upgrades/rename_foreign_wallets.rb +3 -20
  215. data/views/journal.haml +25 -0
  216. data/views/layout.haml +25 -0
  217. data/views/wallet.haml +25 -0
  218. data/zold.gemspec +5 -21
  219. metadata +33 -15
  220. data/.simplecov +0 -36
  221. data/lib/zold/log.rb +0 -139
  222. data/test/test_log.rb +0 -49
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require 'json'
25
7
  require 'time'
26
8
  require 'securerandom'
@@ -62,14 +44,14 @@ class FrontTest < Zold::Test
62
44
  assert_equal(Zold::PROTOCOL, json['protocol'])
63
45
  assert_equal('foo', json['network'])
64
46
  assert_equal('zold-io/zold', json['repo'])
65
- assert(json['pid'].positive?, json)
66
- assert(json['cpus'].positive?, json)
67
- assert(!json['journal'].negative?, json)
68
- assert(json['memory'].positive?, json)
69
- assert(!json['load'].negative?, json)
70
- assert(json['wallets'].positive?, json)
71
- assert(json['remotes'].zero?, json)
72
- assert(json['nscore'].zero?, json)
47
+ assert_predicate(json['pid'], :positive?, json)
48
+ assert_predicate(json['cpus'], :positive?, json)
49
+ refute_predicate(json['journal'], :negative?, json)
50
+ assert_predicate(json['memory'], :positive?, json)
51
+ refute_predicate(json['load'], :negative?, json)
52
+ assert_predicate(json['wallets'], :positive?, json)
53
+ assert_predicate(json['remotes'], :zero?, json)
54
+ assert_predicate(json['nscore'], :zero?, json)
73
55
  end
74
56
  end
75
57
 
@@ -182,7 +164,7 @@ class FrontTest < Zold::Test
182
164
  assert_equal_wait(200) { Zold::Http.new(uri: "#{base}/wallet/#{wallet.id}").get.status }
183
165
  response = Zold::Http.new(uri: "#{base}/wallets").get
184
166
  assert_equal(200, response.status, response.body)
185
- assert(response.body.to_s.split("\n").include?(wallet.id.to_s), response.body)
167
+ assert_includes(response.body.to_s.split("\n"), wallet.id.to_s, response.body)
186
168
  end
187
169
  end
188
170
  end
@@ -203,7 +185,7 @@ class FrontTest < Zold::Test
203
185
  res.status
204
186
  end
205
187
  end
206
- assert(threads.uniq.count > 1)
188
+ assert_operator(threads.uniq.count, :>, 1)
207
189
  end
208
190
  end
209
191
  end
@@ -255,17 +237,17 @@ class FrontTest < Zold::Test
255
237
  end
256
238
  if score.value >= 16
257
239
  assert_equal(
258
- path, 'https://www.zold.io/images/logo-green.png',
240
+ 'https://www.zold.io/images/logo-green.png', path,
259
241
  "Expected #{path} for score #{score.value}"
260
242
  )
261
243
  elsif score.value >= 4
262
244
  assert_equal(
263
- path, 'https://www.zold.io/images/logo-orange.png',
245
+ 'https://www.zold.io/images/logo-orange.png', path,
264
246
  "Expected #{path} for score #{score.value}"
265
247
  )
266
248
  else
267
249
  assert_equal(
268
- path, 'https://www.zold.io/images/logo-red.png',
250
+ 'https://www.zold.io/images/logo-red.png', path,
269
251
  "Expected #{path} for score #{score.value}"
270
252
  )
271
253
  end
@@ -291,12 +273,12 @@ class FrontTest < Zold::Test
291
273
  end
292
274
  all = []
293
275
  all << times.pop(true) until times.empty?
294
- fake_log.info("Average response time is #{all.inject(&:+) / all.count}")
276
+ fake_log.info("Average response time is #{all.sum / all.count}")
295
277
  end
296
278
 
297
279
  # The score exposed via the HTTP header must be reduced to the value of 16.
298
280
  # We need this in order to optimize the amount of data we transfer in each
299
- # HTTP request. This value is enough to identify a valueable node, and filter
281
+ # HTTP request. This value is enough to identify a valuable node, and filter
300
282
  # out those that are too weak.
301
283
  def test_score_is_reduced
302
284
  FakeNode.new(log: fake_log).run(opts('--threads=1', '--strength=1', '--farmer=plain')) do |port|
@@ -306,7 +288,7 @@ class FrontTest < Zold::Test
306
288
  scores << Zold::Score.parse(res.headers[Zold::Http::SCORE_HEADER]).value
307
289
  sleep(0.1)
308
290
  end
309
- assert(scores.uniq.sort.reverse[0] <= Zold::Front::MIN_SCORE)
291
+ assert_operator(scores.uniq.sort.reverse[0], :<=, Zold::Front::MIN_SCORE)
310
292
  end
311
293
  end
312
294
 
@@ -319,7 +301,7 @@ class FrontTest < Zold::Test
319
301
  assert_equal(app.settings.protocol.to_s, response.headers[Zold::Http::PROTOCOL_HEADER])
320
302
  assert_equal('*', response.headers['Access-Control-Allow-Origin'])
321
303
  assert(response.headers['X-Zold-Milliseconds'])
322
- assert(!response.headers[Zold::Http::SCORE_HEADER].nil?)
304
+ refute_nil(response.headers[Zold::Http::SCORE_HEADER])
323
305
  end
324
306
  end
325
307
 
@@ -356,7 +338,7 @@ class FrontTest < Zold::Test
356
338
  Zold::Http.new(uri: uri).get
357
339
  end
358
340
  end
359
- assert(exception.message.include?('should be a 4 to 16 char long'), exception.message)
341
+ assert_includes(exception.message, 'should be a 4 to 16 char long', exception.message)
360
342
  end
361
343
 
362
344
  def test_push_fetch_in_multiple_threads
@@ -384,10 +366,8 @@ class FrontTest < Zold::Test
384
366
  FakeNode.new(log: fake_log).run(opts) do |port|
385
367
  uri = URI("http://localhost:#{port}/")
386
368
  response = Zold::Http.new(uri: uri).get
387
- assert(
388
- Zold::JsonPage.new(response.body).to_hash.key?('checksum'),
389
- response.body
390
- )
369
+ hash = Zold::JsonPage.new(response.body).to_hash
370
+ assert_includes(hash.keys, 'checksum')
391
371
  end
392
372
  end
393
373
 
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../fake_home'
25
7
  require_relative '../test__helper'
26
8
  require_relative '../../lib/zold/id'
@@ -29,14 +11,14 @@ require_relative 'fake_entrance'
29
11
 
30
12
  # NoDupEntrance test.
31
13
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
32
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
14
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
33
15
  # License:: MIT
34
16
  class TestNoDupEntrance < Zold::Test
35
17
  def test_ignores_dup
36
18
  FakeHome.new(log: fake_log).run do |home|
37
19
  wallet = home.create_wallet
38
20
  Zold::NoDupEntrance.new(RealEntrance.new, home.wallets, log: fake_log).start do |e|
39
- assert(e.push(wallet.id, File.read(wallet.path)).empty?)
21
+ assert_empty(e.push(wallet.id, File.read(wallet.path)))
40
22
  end
41
23
  end
42
24
  end
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../test__helper'
25
7
  require_relative '../../lib/zold/id'
26
8
  require_relative '../../lib/zold/node/nospam_entrance'
@@ -28,16 +10,16 @@ require_relative 'fake_entrance'
28
10
 
29
11
  # NoSpamEntrance test.
30
12
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
13
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
32
14
  # License:: MIT
33
15
  class TestNoSpamEntrance < Zold::Test
34
16
  def test_ignores_spam
35
17
  Zold::NoSpamEntrance.new(RealEntrance.new, log: fake_log).start do |e|
36
18
  id = Zold::Id.new
37
19
  content = 'hello'
38
- assert(!e.push(id, content).empty?)
39
- assert(e.push(id, content).empty?)
40
- assert(e.push(id, content).empty?)
20
+ refute_empty(e.push(id, content))
21
+ assert_empty(e.push(id, content))
22
+ assert_empty(e.push(id, content))
41
23
  end
42
24
  end
43
25
 
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../fake_home'
25
7
  require_relative '../test__helper'
26
8
  require_relative '../../lib/zold/wallet'
@@ -32,7 +14,7 @@ require_relative 'fake_entrance'
32
14
 
33
15
  # SafeEntrance test.
34
16
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
35
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
17
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
36
18
  # License:: MIT
37
19
  class TestSafeEntrance < Zold::Test
38
20
  def test_rejects_wallet_with_negative_balance
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../fake_home'
25
7
  require_relative 'fake_node'
26
8
  require_relative '../test__helper'
@@ -32,7 +14,7 @@ require_relative 'fake_entrance'
32
14
 
33
15
  # SpreadEntrance test.
34
16
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
35
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
17
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
36
18
  # License:: MIT
37
19
  class TestSpreadEntrance < Zold::Test
38
20
  def test_renders_json
@@ -59,7 +41,7 @@ class TestSpreadEntrance < Zold::Test
59
41
  remotes.add('localhost', port)
60
42
  Zold::SpreadEntrance.new(FakeEntrance.new, home.wallets, remotes, 'x', log: fake_log).start do |e|
61
43
  8.times { e.push(wallet.id, File.read(wallet.path)) }
62
- assert(e.to_json[:modified] < 2, "It's too big: #{e.to_json[:modified]}")
44
+ assert_operator(e.to_json[:modified], :<, 2, "It's too big: #{e.to_json[:modified]}")
63
45
  end
64
46
  end
65
47
  end
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../fake_home'
25
7
  require_relative '../test__helper'
26
8
  require_relative '../../lib/zold/node/sync_entrance'
@@ -28,13 +10,13 @@ require_relative 'fake_entrance'
28
10
 
29
11
  # SyncEntrance test.
30
12
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
13
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
32
14
  # License:: MIT
33
15
  class TestSyncEntrance < Zold::Test
34
16
  def test_renders_json
35
17
  FakeHome.new(log: fake_log).run do |home|
36
18
  Zold::SyncEntrance.new(FakeEntrance.new, File.join(home.dir, 'x'), log: fake_log).start do |e|
37
- assert(!e.to_json.nil?)
19
+ refute_nil(e.to_json)
38
20
  end
39
21
  end
40
22
  end
@@ -1,26 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative '../test__helper'
25
7
  require_relative '../../lib/zold/node/trace'
26
8
 
@@ -30,7 +12,7 @@ class TraceTest < Zold::Test
30
12
  trace.error('This should not be visible')
31
13
  trace.error('How are you, друг?')
32
14
  trace.error('Works?')
33
- assert(!trace.to_s.include?('visible'))
34
- assert(trace.to_s.include?('друг'))
15
+ refute_includes(trace.to_s, 'visible')
16
+ assert_includes(trace.to_s, 'друг')
35
17
  end
36
18
  end
data/test/test__helper.rb CHANGED
@@ -1,46 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  gem 'openssl'
24
7
  require 'openssl'
25
- require 'minitest/autorun'
26
8
  require 'minitest/hooks/test'
27
9
  require 'concurrent'
28
10
  require 'timeout'
29
11
 
30
- require 'minitest/fail_fast' if ENV['TEST_QUIET_LOG']
31
-
32
12
  $stdout.sync = true
33
13
 
34
14
  ENV['RACK_ENV'] = 'test'
35
-
36
15
  require 'simplecov'
37
- SimpleCov.start
38
-
39
- require_relative '../lib/zold/hands'
40
- Zold::Hands.start
16
+ require 'simplecov-cobertura'
17
+ unless SimpleCov.running || ENV['PICKS']
18
+ SimpleCov.command_name('test')
19
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
20
+ [
21
+ SimpleCov::Formatter::HTMLFormatter,
22
+ SimpleCov::Formatter::CoberturaFormatter
23
+ ]
24
+ )
25
+ SimpleCov.minimum_coverage 85
26
+ SimpleCov.minimum_coverage_by_file 50
27
+ SimpleCov.start do
28
+ add_filter 'test/'
29
+ add_filter 'vendor/'
30
+ add_filter 'target/'
31
+ track_files 'lib/**/*.rb'
32
+ track_files '*.rb'
33
+ end
34
+ end
41
35
 
36
+ require 'minitest/autorun'
37
+ require 'minitest/mock'
42
38
  require 'minitest/reporters'
39
+ require 'webmock/minitest'
43
40
  Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
41
+ Minitest.load :minitest_reporter
42
+
43
+ require_relative '../lib/zold/hands'
44
+ Zold::Hands.start
44
45
 
45
46
  module Zold
46
47
  class Test < Minitest::Test
@@ -49,7 +50,7 @@ module Zold
49
50
  # We need this in order to make sure any test is faster than a minute. This
50
51
  # should help spotting tests that hang out sometimes. The number of seconds
51
52
  # to wait can be increased, but try to make it as little as possible,
52
- # in order to catch problems ealier.
53
+ # in order to catch problems earlier.
53
54
  def around
54
55
  Timeout.timeout(180) do
55
56
  Thread.current.name = 'test'
@@ -81,14 +82,14 @@ module Zold
81
82
  end
82
83
 
83
84
  def fake_log
84
- require_relative '../lib/zold/log'
85
- @fake_log ||= ENV['TEST_QUIET_LOG'] ? Zold::Log::NULL : Zold::Log::VERBOSE
85
+ require 'loog'
86
+ @fake_log ||= ENV['TEST_QUIET_LOG'] == 'true' ? Loog::NULL : Loog::VERBOSE
86
87
  end
87
88
 
88
89
  class TestLogger
89
90
  attr_accessor :msgs
90
91
 
91
- def initialize(log = Zold::Log::NULL)
92
+ def initialize(log = Loog::NULL)
92
93
  @log = log
93
94
  @msgs = []
94
95
  end
data/test/test_age.rb CHANGED
@@ -1,39 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative 'test__helper'
25
7
  require_relative '../lib/zold/age'
26
8
 
27
9
  # Age test.
28
10
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
11
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
30
12
  # License:: MIT
31
13
  class TestAge < Zold::Test
32
14
  def test_prints_age
33
15
  assert_equal('10m', Zold::Age.new(Time.now - (10 * 60)).to_s)
34
16
  assert_equal('5.5s', Zold::Age.new(Time.now - 5.5).to_s)
35
17
  assert_equal('?', Zold::Age.new(nil).to_s)
36
- assert(!Zold::Age.new(Time.now.utc.iso8601).to_s.nil?)
18
+ refute_nil(Zold::Age.new(Time.now.utc.iso8601).to_s)
37
19
  end
38
20
 
39
21
  def test_prints_all_ages
@@ -49,7 +31,7 @@ class TestAge < Zold::Test
49
31
  15 * 30 * 24 * 60 * 60,
50
32
  8 * 12 * 30 * 24 * 60 * 60
51
33
  ].each do |s|
52
- assert(!Zold::Age.new(Time.now - s).to_s.nil?)
34
+ refute_nil(Zold::Age.new(Time.now - s).to_s)
53
35
  end
54
36
  end
55
37
  end
data/test/test_amount.rb CHANGED
@@ -1,38 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'minitest/autorun'
24
6
  require_relative 'test__helper'
25
7
  require_relative '../lib/zold/amount'
26
8
 
27
9
  # Amount test.
28
10
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
11
+ # Copyright:: Copyright (c) 2018-2025 Zerocracy
30
12
  # License:: MIT
31
13
  class TestAmount < Zold::Test
32
14
  def test_parses_zld
33
15
  amount = Zold::Amount.new(zld: 14.95)
34
- assert(
35
- amount.to_s.include?('14.95ZLD'),
16
+ assert_includes(
17
+ amount.to_s, '14.95ZLD',
36
18
  "#{amount} is not equal to '14.95ZLD'"
37
19
  )
38
20
  end
@@ -47,35 +29,34 @@ class TestAmount < Zold::Test
47
29
 
48
30
  def test_compares_with_zero
49
31
  amount = Zold::Amount.new(zld: 0.00001)
50
- assert(!amount.zero?)
51
- assert(amount.positive?)
52
- assert(!amount.negative?)
53
- assert(amount != Zold::Amount::ZERO)
32
+ refute_predicate(amount, :zero?)
33
+ assert_predicate(amount, :positive?)
34
+ refute_predicate(amount, :negative?)
35
+ refute_equal(amount, Zold::Amount::ZERO)
54
36
  end
55
37
 
56
38
  def test_parses_zents
57
39
  amount = Zold::Amount.new(zents: 900_000_000)
58
- assert(
59
- amount.to_s.include?('0.21ZLD'),
40
+ assert_includes(
41
+ amount.to_s, '0.21ZLD',
60
42
  "#{amount} is not equal to '0.21ZLD'"
61
43
  )
62
44
  end
63
45
 
64
46
  def test_compares_amounts
65
47
  amount = Zold::Amount.new(zents: 700_000_000)
66
- assert(
67
- amount > Zold::Amount::ZERO,
68
- "#{amount} is not greater than zero"
48
+ assert_operator(
49
+ amount, :>, Zold::Amount::ZERO, "#{amount} is not greater than zero"
69
50
  )
70
51
  end
71
52
 
72
53
  def test_multiplies
73
54
  amount = Zold::Amount.new(zld: 1.2)
74
- assert(Zold::Amount.new(zld: 2.4), amount * 2)
55
+ assert_equal(Zold::Amount.new(zld: 2.4), amount * 2)
75
56
  end
76
57
 
77
58
  def test_divides
78
59
  amount = Zold::Amount.new(zld: 8.2)
79
- assert(Zold::Amount.new(zld: 4.1), amount / 2)
60
+ assert_equal(Zold::Amount.new(zld: 4.1), amount / 2)
80
61
  end
81
62
  end