zold 0.31.5 → 0.31.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codecov.yml +20 -0
  3. data/.github/workflows/pdd.yml +11 -0
  4. data/.github/workflows/rake.yml +23 -0
  5. data/.github/workflows/xcop.yml +11 -0
  6. data/.rubocop.yml +9 -5
  7. data/.ruby-version +1 -1
  8. data/.rultor.yml +4 -5
  9. data/.simplecov +15 -19
  10. data/Dockerfile +1 -1
  11. data/Gemfile +13 -13
  12. data/Guardfile +1 -1
  13. data/README.md +0 -5
  14. data/Rakefile +1 -1
  15. data/bin/zold +1 -1
  16. data/features/step_definitions/steps.rb +5 -5
  17. data/features/support/env.rb +1 -1
  18. data/fixtures/merge/asserts.rb +1 -1
  19. data/fixtures/merge/into_no_wallet/assert.rb +1 -1
  20. data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -2
  21. data/fixtures/merge/missed_wallets/assert.rb +2 -2
  22. data/fixtures/merge/negative_overwriting/assert.rb +1 -1
  23. data/fixtures/merge/negatives_in_between/assert.rb +2 -2
  24. data/fixtures/merge/random_expenses/assert.rb +2 -2
  25. data/fixtures/merge/simple_case/assert.rb +1 -1
  26. data/fixtures/merge/unconfirmed_income/assert.rb +1 -1
  27. data/lib/zold/age.rb +1 -1
  28. data/lib/zold/amount.rb +3 -3
  29. data/lib/zold/cached_wallets.rb +1 -1
  30. data/lib/zold/commands/args.rb +1 -1
  31. data/lib/zold/commands/calculate.rb +2 -2
  32. data/lib/zold/commands/clean.rb +1 -1
  33. data/lib/zold/commands/create.rb +6 -2
  34. data/lib/zold/commands/diff.rb +3 -3
  35. data/lib/zold/commands/fetch.rb +3 -3
  36. data/lib/zold/commands/invoice.rb +1 -1
  37. data/lib/zold/commands/list.rb +1 -1
  38. data/lib/zold/commands/merge.rb +4 -4
  39. data/lib/zold/commands/next.rb +1 -1
  40. data/lib/zold/commands/node.rb +3 -3
  41. data/lib/zold/commands/pay.rb +2 -2
  42. data/lib/zold/commands/propagate.rb +2 -2
  43. data/lib/zold/commands/pull.rb +1 -1
  44. data/lib/zold/commands/push.rb +1 -1
  45. data/lib/zold/commands/remote.rb +1 -1
  46. data/lib/zold/commands/remove.rb +1 -1
  47. data/lib/zold/commands/routines/audit.rb +7 -8
  48. data/lib/zold/commands/routines/gc.rb +1 -1
  49. data/lib/zold/commands/routines/reconcile.rb +1 -1
  50. data/lib/zold/commands/routines/reconnect.rb +1 -1
  51. data/lib/zold/commands/routines/retire.rb +1 -1
  52. data/lib/zold/commands/routines.rb +1 -1
  53. data/lib/zold/commands/show.rb +5 -6
  54. data/lib/zold/commands/taxes.rb +2 -2
  55. data/lib/zold/commands/thread_badge.rb +1 -1
  56. data/lib/zold/copies.rb +4 -4
  57. data/lib/zold/dir_items.rb +2 -2
  58. data/lib/zold/endless.rb +3 -5
  59. data/lib/zold/gem.rb +1 -1
  60. data/lib/zold/hands.rb +4 -4
  61. data/lib/zold/head.rb +1 -1
  62. data/lib/zold/hexnum.rb +1 -1
  63. data/lib/zold/http.rb +5 -4
  64. data/lib/zold/hungry_wallets.rb +2 -2
  65. data/lib/zold/id.rb +3 -5
  66. data/lib/zold/json_page.rb +2 -2
  67. data/lib/zold/key.rb +5 -5
  68. data/lib/zold/log.rb +7 -7
  69. data/lib/zold/metronome.rb +2 -2
  70. data/lib/zold/node/async_entrance.rb +9 -9
  71. data/lib/zold/node/entrance.rb +5 -5
  72. data/lib/zold/node/farm.rb +4 -4
  73. data/lib/zold/node/farmers.rb +2 -4
  74. data/lib/zold/node/front.rb +23 -19
  75. data/lib/zold/node/journaled_pipeline.rb +6 -6
  76. data/lib/zold/node/nodup_entrance.rb +1 -1
  77. data/lib/zold/node/nospam_entrance.rb +2 -2
  78. data/lib/zold/node/pipeline.rb +6 -6
  79. data/lib/zold/node/safe_entrance.rb +2 -2
  80. data/lib/zold/node/soft_error.rb +1 -1
  81. data/lib/zold/node/spread_entrance.rb +3 -3
  82. data/lib/zold/node/sync_entrance.rb +1 -1
  83. data/lib/zold/node/trace.rb +1 -1
  84. data/lib/zold/patch.rb +14 -15
  85. data/lib/zold/prefixes.rb +1 -1
  86. data/lib/zold/remotes.rb +4 -6
  87. data/lib/zold/signature.rb +1 -1
  88. data/lib/zold/size.rb +1 -1
  89. data/lib/zold/sync_wallets.rb +1 -1
  90. data/lib/zold/tax.rb +6 -4
  91. data/lib/zold/thread_pool.rb +3 -3
  92. data/lib/zold/tree_wallets.rb +1 -1
  93. data/lib/zold/txn.rb +26 -19
  94. data/lib/zold/txns.rb +1 -1
  95. data/lib/zold/upgrades.rb +2 -2
  96. data/lib/zold/verbose_thread.rb +2 -2
  97. data/lib/zold/version.rb +2 -2
  98. data/lib/zold/version_file.rb +1 -1
  99. data/lib/zold/wallet.rb +3 -3
  100. data/lib/zold/wallets.rb +6 -1
  101. data/lib/zold.rb +1 -1
  102. data/renovate.json +6 -0
  103. data/test/commands/routines/test_audit.rb +2 -2
  104. data/test/commands/routines/test_gc.rb +2 -2
  105. data/test/commands/routines/test_reconcile.rb +2 -2
  106. data/test/commands/routines/test_reconnect.rb +2 -2
  107. data/test/commands/routines/test_retire.rb +2 -2
  108. data/test/commands/test_alias.rb +1 -1
  109. data/test/commands/test_calculate.rb +1 -1
  110. data/test/commands/test_clean.rb +4 -4
  111. data/test/commands/test_create.rb +1 -1
  112. data/test/commands/test_diff.rb +5 -5
  113. data/test/commands/test_fetch.rb +21 -21
  114. data/test/commands/test_invoice.rb +1 -1
  115. data/test/commands/test_list.rb +1 -1
  116. data/test/commands/test_merge.rb +11 -11
  117. data/test/commands/test_node.rb +1 -1
  118. data/test/commands/test_pay.rb +4 -4
  119. data/test/commands/test_propagate.rb +1 -1
  120. data/test/commands/test_pull.rb +1 -1
  121. data/test/commands/test_push.rb +1 -1
  122. data/test/commands/test_remote.rb +2 -2
  123. data/test/commands/test_remove.rb +1 -1
  124. data/test/commands/test_show.rb +1 -1
  125. data/test/commands/test_taxes.rb +2 -2
  126. data/test/fake_home.rb +4 -3
  127. data/test/node/fake_entrance.rb +1 -1
  128. data/test/node/fake_node.rb +2 -2
  129. data/test/node/test_async_entrance.rb +6 -4
  130. data/test/node/test_entrance.rb +4 -4
  131. data/test/node/test_farm.rb +2 -2
  132. data/test/node/test_farmers.rb +1 -1
  133. data/test/node/test_front.rb +4 -4
  134. data/test/node/test_nodup_entrance.rb +2 -2
  135. data/test/node/test_nospam_entrance.rb +1 -1
  136. data/test/node/test_safe_entrance.rb +3 -3
  137. data/test/node/test_spread_entrance.rb +2 -2
  138. data/test/node/test_sync_entrance.rb +1 -1
  139. data/test/node/test_trace.rb +1 -1
  140. data/test/test__helper.rb +5 -4
  141. data/test/test_age.rb +2 -2
  142. data/test/test_amount.rb +1 -1
  143. data/test/test_cached_wallets.rb +3 -3
  144. data/test/test_copies.rb +6 -6
  145. data/test/test_dir_items.rb +2 -4
  146. data/test/test_gem.rb +1 -1
  147. data/test/test_hands.rb +1 -1
  148. data/test/test_hexnum.rb +1 -1
  149. data/test/test_http.rb +5 -5
  150. data/test/test_hungry_wallets.rb +1 -1
  151. data/test/test_id.rb +1 -1
  152. data/test/test_json_page.rb +1 -1
  153. data/test/test_key.rb +5 -5
  154. data/test/test_log.rb +1 -1
  155. data/test/test_metronome.rb +2 -1
  156. data/test/test_patch.rb +9 -9
  157. data/test/test_prefixes.rb +1 -1
  158. data/test/test_remotes.rb +2 -2
  159. data/test/test_signature.rb +1 -1
  160. data/test/test_size.rb +1 -1
  161. data/test/test_sync_wallets.rb +1 -1
  162. data/test/test_tax.rb +4 -4
  163. data/test/test_thread_pool.rb +1 -1
  164. data/test/test_tree_wallets.rb +1 -1
  165. data/test/test_txn.rb +2 -2
  166. data/test/test_upgrades.rb +4 -4
  167. data/test/test_verbose_thread.rb +1 -1
  168. data/test/test_wallet.rb +14 -14
  169. data/test/test_wallets.rb +1 -1
  170. data/test/test_zold.rb +2 -2
  171. data/test/upgrades/test_delete_banned_wallets.rb +1 -1
  172. data/test/upgrades/test_protocol_up.rb +1 -1
  173. data/upgrades/2.rb +1 -1
  174. data/upgrades/delete_banned_wallets.rb +2 -2
  175. data/upgrades/move_wallets_into_tree.rb +1 -1
  176. data/upgrades/protocol_up.rb +3 -3
  177. data/upgrades/rename_foreign_wallets.rb +2 -2
  178. data/zold.gemspec +21 -24
  179. metadata +40 -117
  180. data/.github/CODE_OF_CONDUCT.md +0 -76
  181. data/.github/CONTRIBUTING.md +0 -11
  182. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  183. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -46,7 +46,7 @@ class TestTaxes < Zold::Test
46
46
  wallet.add(
47
47
  Zold::Txn.new(
48
48
  i + 1,
49
- Time.now - 24 * 60 * 60 * 365 * 300,
49
+ Time.now - (24 * 60 * 60 * 365 * 300),
50
50
  fund,
51
51
  'NOPREFIX', Zold::Id.new, '-'
52
52
  )
data/test/fake_home.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -37,6 +37,7 @@ require_relative '../lib/zold/remotes'
37
37
  # License:: MIT
38
38
  class FakeHome
39
39
  attr_reader :dir
40
+
40
41
  def initialize(dir = __dir__, log: Zold::Log::NULL)
41
42
  @dir = dir
42
43
  @log = log
@@ -57,7 +58,7 @@ class FakeHome
57
58
  target = Zold::Wallet.new(File.join(dir, id.to_s + Zold::Wallet::EXT))
58
59
  wallets.acq(id, exclusive: true) do |w|
59
60
  w.init(id, Zold::Key.new(file: File.expand_path(File.join(__dir__, '../fixtures/id_rsa.pub'))))
60
- IO.write(target.path, IO.read(w.path))
61
+ File.write(target.path, File.read(w.path))
61
62
  txns.times do |i|
62
63
  w.add(
63
64
  Zold::Txn.new(
@@ -86,7 +87,7 @@ class FakeHome
86
87
  mtime: wallet.mtime.utc.iso8601,
87
88
  digest: wallet.digest,
88
89
  balance: wallet.balance.to_i,
89
- body: IO.read(wallet.path)
90
+ body: File.read(wallet.path)
90
91
  }.to_json
91
92
  end
92
93
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -78,7 +78,7 @@ class FakeNode
78
78
  begin
79
79
  yield port
80
80
  ensure
81
- Zold::Http.new(uri: uri + '?halt=test').get
81
+ Zold::Http.new(uri: "#{uri}?halt=test").get
82
82
  node.join
83
83
  sleep 0.1 # stupid sleep to make sure all threads are terminated
84
84
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -49,7 +49,7 @@ class TestAsyncEntrance < Zold::Test
49
49
  wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
50
50
  basic = CountingEntrance.new
51
51
  Zold::AsyncEntrance.new(basic, File.join(home.dir, 'a/b/c'), log: test_log).start do |e|
52
- e.push(wallet.id, IO.read(wallet.path))
52
+ e.push(wallet.id, File.read(wallet.path))
53
53
  assert_equal_wait(1) { basic.count }
54
54
  end
55
55
  end
@@ -64,7 +64,7 @@ class TestAsyncEntrance < Zold::Test
64
64
  amount = Zold::Amount.new(zld: 39.99)
65
65
  key = Zold::Key.new(file: 'fixtures/id_rsa')
66
66
  wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
67
- 5.times { e.push(wallet.id, IO.read(wallet.path)) }
67
+ 5.times { e.push(wallet.id, File.read(wallet.path)) }
68
68
  end
69
69
  assert_equal_wait(true) { basic.count >= 20 }
70
70
  end
@@ -75,7 +75,7 @@ class TestAsyncEntrance < Zold::Test
75
75
  FakeHome.new(log: test_log).run do |home|
76
76
  wallet = home.create_wallet
77
77
  id = wallet.id
78
- body = IO.read(wallet.path)
78
+ body = File.read(wallet.path)
79
79
  Zold::AsyncEntrance.new(BrokenEntrance.new, home.dir, log: test_log).start do |e|
80
80
  e.push(id, body)
81
81
  end
@@ -84,7 +84,9 @@ class TestAsyncEntrance < Zold::Test
84
84
 
85
85
  class CountingEntrance < FakeEntrance
86
86
  attr_reader :count
87
+
87
88
  def initialize
89
+ super
88
90
  @count = 0
89
91
  end
90
92
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -49,7 +49,7 @@ class TestEntrance < Zold::Test
49
49
  source.id.to_s, target.id.to_s, '19.99', 'testing'
50
50
  ]
51
51
  )
52
- IO.read(source.path)
52
+ File.read(source.path)
53
53
  end
54
54
  FakeHome.new(log: test_log).run do |home|
55
55
  source = home.create_wallet(sid)
@@ -66,7 +66,7 @@ class TestEntrance < Zold::Test
66
66
  assert_equal(Zold::Amount.new(zld: 19.99), target.balance)
67
67
  assert(modified.include?(sid))
68
68
  assert(modified.include?(tid))
69
- assert_equal(1, IO.read(ledger).split("\n").count)
69
+ assert_equal(1, File.read(ledger).split("\n").count)
70
70
  end
71
71
  end
72
72
 
@@ -74,7 +74,7 @@ class TestEntrance < Zold::Test
74
74
  FakeHome.new(log: test_log).run do |home|
75
75
  wallet = home.create_wallet
76
76
  e = Zold::Entrance.new(home.wallets, Zold::Pipeline.new(home.remotes, home.copies.root, 'x'), log: test_log)
77
- e.push(wallet.id, IO.read(wallet.path))
77
+ e.push(wallet.id, File.read(wallet.path))
78
78
  assert(e.to_json[:history].include?(wallet.id.to_s))
79
79
  assert(!e.to_json[:speed].negative?)
80
80
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -131,7 +131,7 @@ class FarmTest < Zold::Test
131
131
  suffixes: %w[13f7f01 b2b32b 4ade7e],
132
132
  strength: 6
133
133
  )
134
- IO.write(cache, score.to_s)
134
+ File.write(cache, score.to_s)
135
135
  farm = Zold::Farm.new('NOPREFIX4@ffffffffffffffff', cache, log: test_log, strength: score.strength)
136
136
  farm.start(score.host, score.port, threads: 1) do
137
137
  100.times do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -129,7 +129,7 @@ class FrontTest < Zold::Test
129
129
  Zold::JsonPage.new(response.body).to_hash['all'].count, response.body
130
130
  )
131
131
  assert_match(
132
- /(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})Z/,
132
+ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/,
133
133
  Zold::JsonPage.new(response.body).to_hash['mtime'].to_s,
134
134
  response.body
135
135
  )
@@ -286,7 +286,7 @@ class FrontTest < Zold::Test
286
286
  Threads.new(10).assert(100) do
287
287
  start = Time.now
288
288
  Zold::Http.new(uri: URI("http://localhost:#{port}/")).get
289
- times << Time.now - start
289
+ times << (Time.now - start)
290
290
  end
291
291
  end
292
292
  all = []
@@ -359,7 +359,7 @@ class FrontTest < Zold::Test
359
359
  end
360
360
 
361
361
  def test_push_fetch_in_multiple_threads
362
- key = Zold::Key.new(text: IO.read('fixtures/id_rsa'))
362
+ key = Zold::Key.new(text: File.read('fixtures/id_rsa'))
363
363
  FakeNode.new(log: test_log).run(opts) do |port|
364
364
  FakeHome.new(log: test_log).run do |home|
365
365
  wallet = home.create_wallet(Zold::Id::ROOT)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -36,7 +36,7 @@ class TestNoDupEntrance < Zold::Test
36
36
  FakeHome.new(log: test_log).run do |home|
37
37
  wallet = home.create_wallet
38
38
  Zold::NoDupEntrance.new(RealEntrance.new, home.wallets, log: test_log).start do |e|
39
- assert(e.push(wallet.id, IO.read(wallet.path)).empty?)
39
+ assert(e.push(wallet.id, File.read(wallet.path)).empty?)
40
40
  end
41
41
  end
42
42
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -42,7 +42,7 @@ class TestSafeEntrance < Zold::Test
42
42
  key = Zold::Key.new(file: 'fixtures/id_rsa')
43
43
  wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
44
44
  assert_raises Zold::SoftError do
45
- Zold::SafeEntrance.new(FakeEntrance.new).push(wallet.id, IO.read(wallet.path))
45
+ Zold::SafeEntrance.new(FakeEntrance.new).push(wallet.id, File.read(wallet.path))
46
46
  end
47
47
  end
48
48
  end
@@ -52,7 +52,7 @@ class TestSafeEntrance < Zold::Test
52
52
  wallet = Zold::Wallet.new(File.join(home.dir, 'wallet.z'))
53
53
  wallet.init(Zold::Id.new, Zold::Key.new(file: 'fixtures/id_rsa.pub'), network: 'someothernetwork')
54
54
  assert_raises StandardError do
55
- Zold::SafeEntrance.new(FakeEntrance.new).push(wallet.id, IO.read(wallet.path))
55
+ Zold::SafeEntrance.new(FakeEntrance.new).push(wallet.id, File.read(wallet.path))
56
56
  end
57
57
  end
58
58
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -58,7 +58,7 @@ class TestSpreadEntrance < Zold::Test
58
58
  remotes = home.remotes
59
59
  remotes.add('localhost', port)
60
60
  Zold::SpreadEntrance.new(FakeEntrance.new, home.wallets, remotes, 'x', log: test_log).start do |e|
61
- 8.times { e.push(wallet.id, IO.read(wallet.path)) }
61
+ 8.times { e.push(wallet.id, File.read(wallet.path)) }
62
62
  assert(e.to_json[:modified] < 2, "It's too big: #{e.to_json[:modified]}")
63
63
  end
64
64
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test__helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -29,7 +29,7 @@ require 'timeout'
29
29
 
30
30
  require 'minitest/fail_fast' if ENV['TEST_QUIET_LOG']
31
31
 
32
- STDOUT.sync = true
32
+ $stdout.sync = true
33
33
 
34
34
  ENV['RACK_ENV'] = 'test'
35
35
 
@@ -57,8 +57,8 @@ module Zold
57
57
  end
58
58
  end
59
59
 
60
- def assert_wait(max: 30)
61
- assert_equal_wait(true, max: max) { yield }
60
+ def assert_wait(max: 30, &block)
61
+ assert_equal_wait(true, max: max, &block)
62
62
  end
63
63
 
64
64
  def assert_equal_wait(expected, max: 30)
@@ -87,6 +87,7 @@ module Zold
87
87
 
88
88
  class TestLogger
89
89
  attr_accessor :msgs
90
+
90
91
  def initialize(log = Zold::Log::NULL)
91
92
  @log = log
92
93
  @msgs = []
data/test/test_age.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -30,7 +30,7 @@ require_relative '../lib/zold/age'
30
30
  # License:: MIT
31
31
  class TestAge < Zold::Test
32
32
  def test_prints_age
33
- assert_equal('10m', Zold::Age.new(Time.now - 10 * 60).to_s)
33
+ assert_equal('10m', Zold::Age.new(Time.now - (10 * 60)).to_s)
34
34
  assert_equal('5.5s', Zold::Age.new(Time.now - 5.5).to_s)
35
35
  assert_equal('?', Zold::Age.new(nil).to_s)
36
36
  assert(!Zold::Age.new(Time.now.utc.iso8601).to_s.nil?)
data/test/test_amount.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -58,14 +58,14 @@ class TestCachedWallets < Zold::Test
58
58
  key = Zold::Key.new(file: 'fixtures/id_rsa')
59
59
  body = wallets.acq(id, exclusive: true) do |wallet|
60
60
  wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
61
- IO.read(wallet.path)
61
+ File.read(wallet.path)
62
62
  end
63
63
  wallets.acq(id, exclusive: true) do |wallet|
64
64
  wallet.sub(Zold::Amount.new(zld: 1.0), "NOPREFIX@#{Zold::Id.new}", key)
65
65
  end
66
66
  assert_equal(1, wallets.acq(id, &:txns).count)
67
67
  wallets.acq(id, exclusive: true) do |wallet|
68
- IO.write(wallet.path, body)
68
+ File.write(wallet.path, body)
69
69
  end
70
70
  assert_equal(0, wallets.acq(id, &:txns).count)
71
71
  end
data/test/test_copies.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -84,8 +84,8 @@ class TestCopies < Zold::Test
84
84
  def test_cleans_copies
85
85
  Dir.mktmpdir do |dir|
86
86
  copies = Zold::Copies.new(dir, log: test_log)
87
- copies.add(content('h1'), 'zold.io', 4096, 10, time: Time.now - 25 * 60 * 60)
88
- copies.add(content('h1'), 'zold.io', 4097, 20, time: Time.now - 26 * 60 * 60)
87
+ copies.add(content('h1'), 'zold.io', 4096, 10, time: Time.now - (25 * 60 * 60))
88
+ copies.add(content('h1'), 'zold.io', 4097, 20, time: Time.now - (26 * 60 * 60))
89
89
  assert(File.exist?(File.join(dir, "1#{Zold::Copies::EXT}")))
90
90
  copies.clean
91
91
  assert(copies.all.empty?, "#{copies.all.count} is not empty")
@@ -105,7 +105,7 @@ class TestCopies < Zold::Test
105
105
  def test_ignores_garbage
106
106
  Dir.mktmpdir do |dir|
107
107
  copies = Zold::Copies.new(dir, log: test_log)
108
- copies.add(content('h1'), 'zold.io', 50, 80, time: Time.now - 25 * 60 * 60)
108
+ copies.add(content('h1'), 'zold.io', 50, 80, time: Time.now - (25 * 60 * 60))
109
109
  FileUtils.mkdir(File.join(dir, '55'))
110
110
  assert_equal(1, copies.all.count)
111
111
  end
@@ -125,7 +125,7 @@ class TestCopies < Zold::Test
125
125
  def test_ignores_too_old_scores
126
126
  Dir.mktmpdir do |dir|
127
127
  copies = Zold::Copies.new(dir, log: test_log)
128
- copies.add(content('h1'), 'zold.io', 50, 80, time: Time.now - 1000 * 60 * 60)
128
+ copies.add(content('h1'), 'zold.io', 50, 80, time: Time.now - (1000 * 60 * 60))
129
129
  assert_equal(0, copies.all[0][:score])
130
130
  end
131
131
  end
@@ -139,7 +139,7 @@ class TestCopies < Zold::Test
139
139
  amount = Zold::Amount.new(zld: 1.99)
140
140
  key = Zold::Key.new(file: 'fixtures/id_rsa')
141
141
  wallet.sub(amount, 'NOPREFIX@0000111122223333', key, text, time: Time.parse('2018-01-01T01:01:01Z'))
142
- IO.read(wallet.path)
142
+ File.read(wallet.path)
143
143
  end
144
144
  end
145
145
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -43,9 +43,7 @@ class TestDirItems < Zold::Test
43
43
  end
44
44
  Threads.new(100).assert do
45
45
  start = Time.now
46
- File.open(file, 'w+') do |f|
47
- f.write('test')
48
- end
46
+ File.write(file, 'test')
49
47
  test_log.info("Saved in #{Zold::Age.new(start)}")
50
48
  sleep 1
51
49
  end
data/test/test_gem.rb CHANGED
@@ -6,7 +6,7 @@ require 'minitest/autorun'
6
6
 
7
7
  class TestGem < Zold::Test
8
8
  def test_last_version
9
- version = (1..3).map { rand(9).to_s } .join('.')
9
+ version = (1..3).map { rand(9).to_s }.join('.')
10
10
  stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return(
11
11
  status: 200,
12
12
  body: "{\"version\": \"#{version}\"}"
data/test/test_hands.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_hexnum.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_http.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -137,13 +137,13 @@ class TestHttp < Zold::Test
137
137
  end
138
138
  latch.wait
139
139
  res = Tempfile.open do |f|
140
- IO.write(f, 'How are you?')
140
+ File.write(f, 'How are you?')
141
141
  Zold::Http.new(uri: "http://127.0.0.1:#{port}/").put(f)
142
142
  end
143
143
  assert_equal(200, res.status, res)
144
144
  assert(body.include?('Content-Length: 12'), body)
145
145
  assert(body.include?('Content-Type: text/plain'))
146
- headers = body.split("\n").select { |t| t =~ /^[a-zA-Z-]+:.+$/ }
146
+ headers = body.split("\n").grep(/^[a-zA-Z-]+:.+$/)
147
147
  assert_equal(headers.count, headers.uniq.count)
148
148
  thread.kill
149
149
  thread.join
@@ -188,7 +188,7 @@ class TestHttp < Zold::Test
188
188
  latch.wait
189
189
  content = "how are you\nmy friend"
190
190
  res = Tempfile.open do |f|
191
- IO.write(f, content)
191
+ File.write(f, content)
192
192
  Zold::Http.new(uri: "http://localhost:#{port}/").put(f)
193
193
  end
194
194
  assert_equal(200, res.status, res)
@@ -215,7 +215,7 @@ class TestHttp < Zold::Test
215
215
  latch.wait
216
216
  body = Tempfile.open do |f|
217
217
  Zold::Http.new(uri: "http://localhost:#{port}/").get_file(f)
218
- IO.read(f)
218
+ File.read(f)
219
219
  end
220
220
  assert(body.include?(content), body)
221
221
  thread.kill
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_id.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_key.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -63,9 +63,9 @@ class TestKey < Zold::Test
63
63
  Dir.mktmpdir do |dir|
64
64
  key = OpenSSL::PKey::RSA.new(2048)
65
65
  file = File.join(dir, 'temp')
66
- IO.write(file, key.public_key.to_s)
66
+ File.write(file, key.public_key.to_s)
67
67
  pub = Zold::Key.new(file: file)
68
- IO.write(file, key.to_s)
68
+ File.write(file, key.to_s)
69
69
  pvt = Zold::Key.new(file: file)
70
70
  text = 'How are you doing, dude?'
71
71
  signature = pvt.sign(text)
@@ -74,7 +74,7 @@ class TestKey < Zold::Test
74
74
  end
75
75
 
76
76
  def test_read_public_keys
77
- Dir.new('fixtures/keys').select { |f| f =~ /\.pub$/ }.each do |f|
77
+ Dir.new('fixtures/keys').grep(/\.pub$/).each do |f|
78
78
  path = "fixtures/keys/#{f}"
79
79
  pub = Zold::Key.new(file: path)
80
80
  assert(pub.to_pub.length > 100)
@@ -82,7 +82,7 @@ class TestKey < Zold::Test
82
82
  end
83
83
 
84
84
  def test_signs_with_real_keys
85
- Dir.new('fixtures/keys').select { |f| f =~ /[0-9]+$/ }.each do |f|
85
+ Dir.new('fixtures/keys').grep(/[0-9]+$/).each do |f|
86
86
  pvt = Zold::Key.new(file: "fixtures/keys/#{f}")
87
87
  pub = Zold::Key.new(file: "fixtures/keys/#{f}.pub")
88
88
  text = 'How are you doing, my friend?'
data/test/test_log.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -75,6 +75,7 @@ class TestMetronome < Zold::Test
75
75
 
76
76
  class BrokenRoutine
77
77
  attr_reader :count
78
+
78
79
  def initialize
79
80
  @count = 0
80
81
  end