zold 0.31.8 → 0.31.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +20 -0
  3. data/.github/workflows/actionlint.yml +41 -0
  4. data/.github/workflows/codecov.yml +23 -4
  5. data/.github/workflows/copyrights.yml +30 -0
  6. data/.github/workflows/pdd.yml +26 -3
  7. data/.github/workflows/rake.yml +24 -2
  8. data/.github/workflows/xcop.yml +21 -2
  9. data/.github/workflows/yamllint.yml +34 -0
  10. data/.gitignore +2 -1
  11. data/.rubocop.yml +21 -0
  12. data/.ruby-version +1 -1
  13. data/.rultor.yml +35 -5
  14. data/.simplecov +1 -1
  15. data/Dockerfile +29 -3
  16. data/Gemfile +10 -10
  17. data/Gemfile.lock +340 -0
  18. data/LICENSE.txt +1 -1
  19. data/Rakefile +9 -12
  20. data/bin/zold +1 -1
  21. data/cucumber.yml +20 -0
  22. data/deploy.sh +20 -0
  23. data/features/step_definitions/steps.rb +1 -1
  24. data/features/support/env.rb +1 -1
  25. data/fixtures/merge/asserts.rb +1 -1
  26. data/fixtures/merge/into_no_wallet/assert.rb +1 -1
  27. data/fixtures/merge/legacy_negatives_stay/assert.rb +1 -1
  28. data/fixtures/merge/missed_wallets/assert.rb +1 -1
  29. data/fixtures/merge/negative_overwriting/assert.rb +1 -1
  30. data/fixtures/merge/negatives_in_between/assert.rb +1 -1
  31. data/fixtures/merge/random_expenses/assert.rb +1 -1
  32. data/fixtures/merge/simple_case/assert.rb +1 -1
  33. data/fixtures/merge/unconfirmed_income/assert.rb +1 -1
  34. data/fixtures/scripts/_head.sh +21 -1
  35. data/fixtures/scripts/calculate-scores.sh +19 -0
  36. data/fixtures/scripts/distribute-wallet.sh +19 -0
  37. data/fixtures/scripts/print-helps.sh +19 -0
  38. data/fixtures/scripts/pull-on-start.sh +19 -0
  39. data/fixtures/scripts/push-and-pull.sh +19 -0
  40. data/fixtures/scripts/redeploy-on-upgrade.sh +19 -0
  41. data/fixtures/scripts/spread-wallets.sh +19 -0
  42. data/lib/zold/age.rb +2 -2
  43. data/lib/zold/amount.rb +2 -2
  44. data/lib/zold/cached_wallets.rb +3 -3
  45. data/lib/zold/commands/alias.rb +20 -0
  46. data/lib/zold/commands/args.rb +2 -2
  47. data/lib/zold/commands/calculate.rb +2 -2
  48. data/lib/zold/commands/clean.rb +2 -2
  49. data/lib/zold/commands/create.rb +2 -2
  50. data/lib/zold/commands/diff.rb +2 -2
  51. data/lib/zold/commands/fetch.rb +2 -2
  52. data/lib/zold/commands/invoice.rb +2 -2
  53. data/lib/zold/commands/list.rb +2 -2
  54. data/lib/zold/commands/merge.rb +2 -2
  55. data/lib/zold/commands/next.rb +2 -2
  56. data/lib/zold/commands/node.rb +2 -2
  57. data/lib/zold/commands/pay.rb +2 -2
  58. data/lib/zold/commands/propagate.rb +2 -2
  59. data/lib/zold/commands/pull.rb +2 -2
  60. data/lib/zold/commands/push.rb +2 -2
  61. data/lib/zold/commands/remote.rb +2 -2
  62. data/lib/zold/commands/remove.rb +2 -2
  63. data/lib/zold/commands/routines/audit.rb +2 -2
  64. data/lib/zold/commands/routines/gc.rb +2 -2
  65. data/lib/zold/commands/routines/reconcile.rb +2 -2
  66. data/lib/zold/commands/routines/reconnect.rb +2 -2
  67. data/lib/zold/commands/routines/retire.rb +2 -2
  68. data/lib/zold/commands/routines/spread.rb +2 -2
  69. data/lib/zold/commands/routines.rb +2 -2
  70. data/lib/zold/commands/show.rb +2 -2
  71. data/lib/zold/commands/taxes.rb +2 -2
  72. data/lib/zold/commands/thread_badge.rb +3 -3
  73. data/lib/zold/copies.rb +2 -2
  74. data/lib/zold/dir_items.rb +2 -2
  75. data/lib/zold/endless.rb +2 -2
  76. data/lib/zold/gem.rb +2 -2
  77. data/lib/zold/hands.rb +2 -2
  78. data/lib/zold/head.rb +3 -3
  79. data/lib/zold/hexnum.rb +2 -2
  80. data/lib/zold/http.rb +3 -3
  81. data/lib/zold/hungry_wallets.rb +2 -2
  82. data/lib/zold/id.rb +2 -2
  83. data/lib/zold/json_page.rb +2 -2
  84. data/lib/zold/key.rb +2 -2
  85. data/lib/zold/log.rb +2 -2
  86. data/lib/zold/metronome.rb +2 -2
  87. data/lib/zold/node/async_entrance.rb +2 -2
  88. data/lib/zold/node/entrance.rb +2 -2
  89. data/lib/zold/node/farm.rb +2 -2
  90. data/lib/zold/node/farmers.rb +2 -2
  91. data/lib/zold/node/front.rb +3 -3
  92. data/lib/zold/node/journaled_pipeline.rb +2 -2
  93. data/lib/zold/node/nodup_entrance.rb +2 -2
  94. data/lib/zold/node/nospam_entrance.rb +2 -2
  95. data/lib/zold/node/pipeline.rb +2 -2
  96. data/lib/zold/node/safe_entrance.rb +2 -2
  97. data/lib/zold/node/soft_error.rb +2 -2
  98. data/lib/zold/node/spread_entrance.rb +2 -2
  99. data/lib/zold/node/sync_entrance.rb +2 -2
  100. data/lib/zold/node/trace.rb +2 -2
  101. data/lib/zold/patch.rb +2 -2
  102. data/lib/zold/prefixes.rb +2 -2
  103. data/lib/zold/remotes.rb +2 -2
  104. data/lib/zold/signature.rb +2 -2
  105. data/lib/zold/size.rb +2 -2
  106. data/lib/zold/sync_wallets.rb +2 -2
  107. data/lib/zold/tax.rb +2 -2
  108. data/lib/zold/thread_pool.rb +2 -2
  109. data/lib/zold/tree_wallets.rb +2 -2
  110. data/lib/zold/txn.rb +2 -2
  111. data/lib/zold/txns.rb +3 -3
  112. data/lib/zold/upgrades.rb +1 -1
  113. data/lib/zold/verbose_thread.rb +2 -2
  114. data/lib/zold/version.rb +3 -3
  115. data/lib/zold/version_file.rb +1 -1
  116. data/lib/zold/wallet.rb +2 -2
  117. data/lib/zold/wallets.rb +2 -2
  118. data/lib/zold.rb +2 -2
  119. data/test/commands/routines/test_audit.rb +4 -4
  120. data/test/commands/routines/test_gc.rb +8 -8
  121. data/test/commands/routines/test_reconcile.rb +4 -4
  122. data/test/commands/routines/test_reconnect.rb +3 -3
  123. data/test/commands/routines/test_retire.rb +3 -3
  124. data/test/commands/test_alias.rb +26 -6
  125. data/test/commands/test_calculate.rb +3 -3
  126. data/test/commands/test_clean.rb +10 -10
  127. data/test/commands/test_create.rb +3 -3
  128. data/test/commands/test_diff.rb +5 -5
  129. data/test/commands/test_fetch.rb +9 -9
  130. data/test/commands/test_invoice.rb +3 -3
  131. data/test/commands/test_list.rb +3 -3
  132. data/test/commands/test_merge.rb +12 -12
  133. data/test/commands/test_node.rb +6 -6
  134. data/test/commands/test_pay.rb +19 -19
  135. data/test/commands/test_propagate.rb +5 -5
  136. data/test/commands/test_pull.rb +6 -6
  137. data/test/commands/test_push.rb +9 -9
  138. data/test/commands/test_remote.rb +11 -11
  139. data/test/commands/test_remove.rb +10 -10
  140. data/test/commands/test_show.rb +3 -3
  141. data/test/commands/test_taxes.rb +4 -4
  142. data/test/fake_home.rb +2 -2
  143. data/test/node/fake_entrance.rb +2 -2
  144. data/test/node/fake_node.rb +57 -40
  145. data/test/node/test_async_entrance.rb +10 -10
  146. data/test/node/test_entrance.rb +8 -8
  147. data/test/node/test_farm.rb +11 -11
  148. data/test/node/test_farmers.rb +5 -5
  149. data/test/node/test_front.rb +29 -28
  150. data/test/node/test_nodup_entrance.rb +4 -4
  151. data/test/node/test_nospam_entrance.rb +3 -3
  152. data/test/node/test_safe_entrance.rb +4 -4
  153. data/test/node/test_spread_entrance.rb +8 -8
  154. data/test/node/test_sync_entrance.rb +4 -4
  155. data/test/node/test_trace.rb +2 -2
  156. data/test/test__helper.rb +4 -4
  157. data/test/test_age.rb +2 -2
  158. data/test/test_amount.rb +2 -2
  159. data/test/test_cached_wallets.rb +2 -2
  160. data/test/test_copies.rb +12 -12
  161. data/test/test_dir_items.rb +4 -4
  162. data/test/test_gem.rb +20 -0
  163. data/test/test_hands.rb +2 -2
  164. data/test/test_hexnum.rb +2 -2
  165. data/test/test_http.rb +8 -8
  166. data/test/test_hungry_wallets.rb +11 -11
  167. data/test/test_id.rb +2 -2
  168. data/test/test_json_page.rb +2 -2
  169. data/test/test_key.rb +2 -2
  170. data/test/test_log.rb +5 -5
  171. data/test/test_metronome.rb +6 -6
  172. data/test/test_patch.rb +14 -14
  173. data/test/test_prefixes.rb +3 -3
  174. data/test/test_remotes.rb +9 -9
  175. data/test/test_signature.rb +2 -2
  176. data/test/test_size.rb +2 -2
  177. data/test/test_sync_wallets.rb +3 -3
  178. data/test/test_tax.rb +9 -9
  179. data/test/test_thread_pool.rb +8 -8
  180. data/test/test_tree_wallets.rb +2 -2
  181. data/test/test_txn.rb +2 -2
  182. data/test/test_upgrades.rb +2 -2
  183. data/test/test_verbose_thread.rb +2 -2
  184. data/test/test_version.rb +20 -0
  185. data/test/test_wallet.rb +22 -22
  186. data/test/test_wallets.rb +5 -5
  187. data/test/test_zold.rb +5 -5
  188. data/test/upgrades/test_delete_banned_wallets.rb +4 -4
  189. data/test/upgrades/test_protocol_up.rb +4 -4
  190. data/upgrades/2.rb +1 -1
  191. data/upgrades/delete_banned_wallets.rb +1 -1
  192. data/upgrades/move_wallets_into_tree.rb +1 -1
  193. data/upgrades/protocol_up.rb +1 -1
  194. data/upgrades/rename_foreign_wallets.rb +1 -1
  195. data/zold.gemspec +23 -23
  196. metadata +7 -3
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -31,7 +31,7 @@ require_relative '../../lib/zold/commands/invoice'
31
31
 
32
32
  # INVOICE test.
33
33
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
34
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
34
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
35
35
  # License:: MIT
36
36
  class TestInvoice < Zold::Test
37
37
  def test_generates_invoice
@@ -40,7 +40,7 @@ class TestInvoice < Zold::Test
40
40
  wallets = Zold::Wallets.new(dir)
41
41
  wallets.acq(id) do |source|
42
42
  source.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
43
- invoice = Zold::Invoice.new(wallets: wallets, remotes: nil, copies: nil, log: test_log).run(
43
+ invoice = Zold::Invoice.new(wallets: wallets, remotes: nil, copies: nil, log: fake_log).run(
44
44
  ['invoice', id.to_s, '--length=16']
45
45
  )
46
46
  assert_equal(33, invoice.length)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -31,7 +31,7 @@ require_relative '../../lib/zold/commands/list'
31
31
 
32
32
  # LIST test.
33
33
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
34
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
34
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
35
35
  # License:: MIT
36
36
  class TestList < Zold::Test
37
37
  def test_lists_wallets_with_balances
@@ -40,7 +40,7 @@ class TestList < Zold::Test
40
40
  wallets = Zold::Wallets.new(dir)
41
41
  wallets.acq(id) do |wallet|
42
42
  wallet.init(Zold::Id.new, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
43
- Zold::List.new(wallets: wallets, copies: File.join(dir, 'copies'), log: test_log).run
43
+ Zold::List.new(wallets: wallets, copies: File.join(dir, 'copies'), log: fake_log).run
44
44
  end
45
45
  end
46
46
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -39,23 +39,23 @@ require_relative '../../lib/zold/commands/pay'
39
39
 
40
40
  # MERGE test.
41
41
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
42
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
42
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
43
43
  # License:: MIT
44
44
  class TestMerge < Zold::Test
45
45
  def test_merges_wallet
46
- FakeHome.new(log: test_log).run do |home|
46
+ FakeHome.new(log: fake_log).run do |home|
47
47
  wallet = home.create_wallet
48
48
  first = home.create_wallet
49
49
  File.write(first.path, File.read(wallet.path))
50
50
  second = home.create_wallet
51
51
  File.write(second.path, File.read(wallet.path))
52
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
52
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
53
53
  ['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
54
54
  )
55
55
  copies = home.copies(wallet)
56
56
  copies.add(File.read(first.path), 'host-1', 80, 5)
57
57
  copies.add(File.read(second.path), 'host-2', 80, 5)
58
- modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
58
+ modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: fake_log).run(
59
59
  ['merge', wallet.id.to_s]
60
60
  )
61
61
  assert(1, modified.count)
@@ -64,12 +64,12 @@ class TestMerge < Zold::Test
64
64
  end
65
65
 
66
66
  def test_merges_with_a_broken_copy
67
- FakeHome.new(log: test_log).run do |home|
67
+ FakeHome.new(log: fake_log).run do |home|
68
68
  wallet = home.create_wallet
69
69
  copies = home.copies(wallet)
70
70
  copies.add(File.read(wallet.path), 'good-host', 80, 5)
71
71
  copies.add('some garbage', 'bad-host', 80, 5)
72
- modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
72
+ modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: fake_log).run(
73
73
  ['merge', wallet.id.to_s]
74
74
  )
75
75
  assert(modified.empty?)
@@ -77,13 +77,13 @@ class TestMerge < Zold::Test
77
77
  end
78
78
 
79
79
  def test_merges_a_copy_on_top
80
- FakeHome.new(log: test_log).run do |home|
80
+ FakeHome.new(log: fake_log).run do |home|
81
81
  wallet = home.create_wallet(Zold::Id::ROOT)
82
82
  copies = home.copies(wallet)
83
83
  copies.add(File.read(wallet.path), 'good-host', 80, 5)
84
84
  key = Zold::Key.new(file: 'fixtures/id_rsa')
85
85
  wallet.sub(Zold::Amount.new(zld: 9.99), "NOPREFIX@#{Zold::Id.new}", key)
86
- Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
86
+ Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: fake_log).run(
87
87
  ['merge', wallet.id.to_s]
88
88
  )
89
89
  assert(!wallet.balance.zero?)
@@ -91,14 +91,14 @@ class TestMerge < Zold::Test
91
91
  end
92
92
 
93
93
  def test_rejects_fake_positives_in_new_wallet
94
- FakeHome.new(log: test_log).run do |home|
94
+ FakeHome.new(log: fake_log).run do |home|
95
95
  main = home.create_wallet
96
96
  remote = home.create_wallet
97
97
  File.write(remote.path, File.read(main.path))
98
98
  remote.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 11.0), 'NOPREFIX', Zold::Id.new, 'fake'))
99
99
  copies = home.copies(main)
100
100
  copies.add(File.read(remote.path), 'fake-host', 80, 0)
101
- Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
101
+ Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: fake_log).run(
102
102
  ['merge', main.id.to_s, '--no-baseline']
103
103
  )
104
104
  assert_equal(Zold::Amount::ZERO, main.balance)
@@ -117,7 +117,7 @@ class TestMerge < Zold::Test
117
117
  wallets = Zold::Wallets.new(dir)
118
118
  copies = File.join(dir, 'copies')
119
119
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes'))
120
- Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: test_log).run(
120
+ Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: fake_log).run(
121
121
  %w[merge 0123456789abcdef] + File.read(File.join(dir, 'opts')).split("\n")
122
122
  )
123
123
  Dir.chdir(dir) do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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,17 +36,17 @@ require_relative '../node/fake_node'
36
36
 
37
37
  # NODE test.
38
38
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
39
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
39
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
40
40
  # License:: MIT
41
41
  class TestNode < Zold::Test
42
42
  def test_push_and_fetch
43
- FakeHome.new(log: test_log).run do |home|
44
- FakeNode.new(log: test_log).run do |port|
43
+ FakeHome.new(log: fake_log).run do |home|
44
+ FakeNode.new(log: fake_log).run do |port|
45
45
  wallets = home.wallets
46
46
  wallet = home.create_wallet
47
47
  remotes = home.remotes
48
48
  remotes.add('localhost', port)
49
- Zold::Push.new(wallets: wallets, remotes: remotes, log: test_log).run(
49
+ Zold::Push.new(wallets: wallets, remotes: remotes, log: fake_log).run(
50
50
  ['push', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1']
51
51
  )
52
52
  copies = home.copies(wallet)
@@ -54,7 +54,7 @@ class TestNode < Zold::Test
54
54
  retries ||= 0
55
55
  Zold::Fetch.new(
56
56
  wallets: wallets, copies: copies.root,
57
- remotes: remotes, log: test_log
57
+ remotes: remotes, log: fake_log
58
58
  ).run(['fetch', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1'])
59
59
  rescue StandardError => _e
60
60
  sleep 1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -35,22 +35,22 @@ require_relative '../../lib/zold/commands/pay'
35
35
 
36
36
  # PAY test.
37
37
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
38
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
38
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
39
39
  # License:: MIT
40
40
  class TestPay < Zold::Test
41
41
  def test_sends_from_wallet_to_wallet
42
- FakeHome.new(log: test_log).run do |home|
42
+ FakeHome.new(log: fake_log).run do |home|
43
43
  source = home.create_wallet
44
44
  target = home.create_wallet
45
45
  amount = Zold::Amount.new(zld: 14.95)
46
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
46
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
47
47
  [
48
48
  'pay', '--force', '--private-key=fixtures/id_rsa',
49
49
  source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
50
50
  ]
51
51
  )
52
52
  assert_equal(amount * -1, source.balance)
53
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
53
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
54
54
  [
55
55
  'pay', '--private-key=fixtures/id_rsa',
56
56
  target.id.to_s, source.id.to_s, amount.to_zld, 'Refund'
@@ -62,7 +62,7 @@ class TestPay < Zold::Test
62
62
  end
63
63
 
64
64
  def test_pay_without_invoice
65
- FakeHome.new(log: test_log).run do |home|
65
+ FakeHome.new(log: fake_log).run do |home|
66
66
  remotes = home.remotes
67
67
  remotes.add('localhost', 4096)
68
68
  json = home.create_wallet_json
@@ -73,7 +73,7 @@ class TestPay < Zold::Test
73
73
  home.wallets.acq(Zold::Id.new(id)) { |w| File.delete(w.path) }
74
74
  source = home.create_wallet
75
75
  amount = Zold::Amount.new(zld: 14.95)
76
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: test_log).run(
76
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: fake_log).run(
77
77
  [
78
78
  'pay', '--force', '--private-key=fixtures/id_rsa', '--tolerate-edges', '--tolerate-quorum=1',
79
79
  source.id.to_s, id, amount.to_zld, 'For the car'
@@ -84,14 +84,14 @@ class TestPay < Zold::Test
84
84
  end
85
85
 
86
86
  def test_pay_with_keygap
87
- FakeHome.new(log: test_log).run do |home|
87
+ FakeHome.new(log: fake_log).run do |home|
88
88
  wallet = home.create_wallet
89
89
  amount = Zold::Amount.new(zld: 2.0)
90
90
  Tempfile.open do |f|
91
91
  pem = File.read('fixtures/id_rsa')
92
92
  keygap = pem[100..120]
93
93
  File.write(f, pem.gsub(keygap, '*' * keygap.length))
94
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
94
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
95
95
  [
96
96
  'pay', '--force', "--private-key=#{Shellwords.escape(f.path)}",
97
97
  "--keygap=#{Shellwords.escape(keygap)}",
@@ -104,12 +104,12 @@ class TestPay < Zold::Test
104
104
  end
105
105
 
106
106
  def test_pay_in_many_threads
107
- FakeHome.new(log: test_log).run do |home|
107
+ FakeHome.new(log: fake_log).run do |home|
108
108
  wallet = home.create_wallet
109
109
  amount = Zold::Amount.new(zld: 2.0)
110
110
  wallets = home.wallets
111
111
  Threads.new(10).assert do
112
- Zold::Pay.new(wallets: wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
112
+ Zold::Pay.new(wallets: wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
113
113
  [
114
114
  'pay', '--force', '--private-key=fixtures/id_rsa',
115
115
  wallet.id.to_s, 'NOPREFIX@dddd0000dddd0000', amount.to_zld, '-'
@@ -121,11 +121,11 @@ class TestPay < Zold::Test
121
121
  end
122
122
 
123
123
  def test_sends_from_root_wallet
124
- FakeHome.new(log: test_log).run do |home|
124
+ FakeHome.new(log: fake_log).run do |home|
125
125
  source = home.create_wallet(Zold::Id::ROOT)
126
126
  target = home.create_wallet
127
127
  amount = Zold::Amount.new(zld: 14.95)
128
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
128
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
129
129
  [
130
130
  'pay', '--private-key=fixtures/id_rsa',
131
131
  source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
@@ -136,7 +136,7 @@ class TestPay < Zold::Test
136
136
  end
137
137
 
138
138
  def test_sends_from_normal_wallet
139
- FakeHome.new(log: test_log).run do |home|
139
+ FakeHome.new(log: fake_log).run do |home|
140
140
  source = home.create_wallet
141
141
  target = home.create_wallet
142
142
  amount = Zold::Amount.new(zld: 14.95)
@@ -146,7 +146,7 @@ class TestPay < Zold::Test
146
146
  'NOPREFIX', Zold::Id.new, '-'
147
147
  )
148
148
  )
149
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
149
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
150
150
  [
151
151
  'pay', '--private-key=fixtures/id_rsa',
152
152
  source.id.to_s, target.id.to_s, amount.to_zld, 'here is the refund'
@@ -157,11 +157,11 @@ class TestPay < Zold::Test
157
157
  end
158
158
 
159
159
  def test_notifies_about_tax_status
160
- FakeHome.new(log: test_log).run do |home|
160
+ FakeHome.new(log: fake_log).run do |home|
161
161
  source = home.create_wallet
162
162
  target = home.create_wallet
163
163
  amount = Zold::Amount.new(zld: 14.95)
164
- accumulating_log = test_log.dup
164
+ accumulating_log = fake_log.dup
165
165
  class << accumulating_log
166
166
  attr_accessor :info_messages
167
167
 
@@ -182,7 +182,7 @@ class TestPay < Zold::Test
182
182
  end
183
183
 
184
184
  def test_pays_and_taxes
185
- FakeHome.new(log: test_log).run do |home|
185
+ FakeHome.new(log: fake_log).run do |home|
186
186
  wallet = home.create_wallet
187
187
  fund = Zold::Amount.new(zld: 19.99)
188
188
  10.times do |i|
@@ -207,7 +207,7 @@ class TestPay < Zold::Test
207
207
  )
208
208
  before = wallet.balance
209
209
  target = home.create_wallet
210
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: test_log).run(
210
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: remotes, log: fake_log).run(
211
211
  [
212
212
  'pay', '--force', '--private-key=fixtures/id_rsa',
213
213
  '--ignore-score-weakness',
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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,18 +29,18 @@ require_relative '../../lib/zold/commands/pay'
29
29
 
30
30
  # PROPAGATE test.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
32
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
32
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
33
33
  # License:: MIT
34
34
  class TestPropagate < Zold::Test
35
35
  def test_propagates_wallet
36
- FakeHome.new(log: test_log).run do |home|
36
+ FakeHome.new(log: fake_log).run do |home|
37
37
  wallet = home.create_wallet
38
38
  friend = home.create_wallet
39
39
  amount = Zold::Amount.new(zld: 14.95)
40
- Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
40
+ Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
41
41
  ['pay', wallet.id.to_s, friend.id.to_s, amount.to_zld, '--force', '--private-key=fixtures/id_rsa']
42
42
  )
43
- Zold::Propagate.new(wallets: home.wallets, log: test_log).run(
43
+ Zold::Propagate.new(wallets: home.wallets, log: fake_log).run(
44
44
  ['merge', wallet.id.to_s]
45
45
  )
46
46
  assert(amount, friend.balance)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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,11 +30,11 @@ require_relative '../../lib/zold/commands/pull'
30
30
 
31
31
  # PUSH test.
32
32
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
33
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
33
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
34
34
  # License:: MIT
35
35
  class TestPull < Zold::Test
36
36
  def test_pull_wallet
37
- FakeHome.new(log: test_log).run do |home|
37
+ FakeHome.new(log: fake_log).run do |home|
38
38
  remotes = home.remotes
39
39
  remotes.add('localhost', 4096)
40
40
  json = home.create_wallet_json
@@ -42,7 +42,7 @@ class TestPull < Zold::Test
42
42
  id = hash['id']
43
43
  stub_request(:get, "http://localhost:4096/wallet/#{id}").to_return(status: 200, body: json)
44
44
  stub_request(:get, "http://localhost:4096/wallet/#{id}.bin").to_return(status: 200, body: hash['body'])
45
- Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: test_log).run(
45
+ Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: fake_log).run(
46
46
  ['--ignore-this-stupid-option', 'pull', id.to_s, '--tolerate-edges', '--tolerate-quorum=1']
47
47
  )
48
48
  home.wallets.acq(Zold::Id.new(id)) do |wallet|
@@ -52,7 +52,7 @@ class TestPull < Zold::Test
52
52
  end
53
53
 
54
54
  def test_fails_when_only_edge_nodes
55
- FakeHome.new(log: test_log).run do |home|
55
+ FakeHome.new(log: fake_log).run do |home|
56
56
  remotes = home.remotes
57
57
  remotes.add('localhost', 4096)
58
58
  json = home.create_wallet_json
@@ -61,7 +61,7 @@ class TestPull < Zold::Test
61
61
  stub_request(:get, "http://localhost:4096/wallet/#{id}").to_return(status: 200, body: json)
62
62
  stub_request(:get, "http://localhost:4096/wallet/#{id}.bin").to_return(status: 200, body: hash['body'])
63
63
  assert_raises Zold::Fetch::EdgesOnly do
64
- Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: test_log).run(
64
+ Zold::Pull.new(wallets: home.wallets, remotes: remotes, copies: home.copies.root.to_s, log: fake_log).run(
65
65
  ['--ignore-this-stupid-option', 'pull', id.to_s]
66
66
  )
67
67
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -33,23 +33,23 @@ require_relative '../../lib/zold/commands/push'
33
33
 
34
34
  # PUSH test.
35
35
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
36
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
36
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
37
37
  # License:: MIT
38
38
  class TestPush < Zold::Test
39
39
  def test_pushes_wallet
40
- FakeHome.new(log: test_log).run do |home|
40
+ FakeHome.new(log: fake_log).run do |home|
41
41
  wallet = home.create_wallet
42
42
  remotes = home.remotes
43
43
  remotes.add('localhost', 80)
44
44
  stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
45
- Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
45
+ Zold::Push.new(wallets: home.wallets, remotes: remotes, log: fake_log).run(
46
46
  ['--ignore-this-stupid-option', 'push', wallet.id.to_s, '--tolerate-edges', '--tolerate-quorum=1']
47
47
  )
48
48
  end
49
49
  end
50
50
 
51
51
  def test_pushes_multiple_wallets
52
- log = TestLogger.new(test_log)
52
+ log = TestLogger.new(fake_log)
53
53
  FakeHome.new(log: log).run do |home|
54
54
  wallet_a = home.create_wallet
55
55
  wallet_b = home.create_wallet
@@ -64,13 +64,13 @@ class TestPush < Zold::Test
64
64
  end
65
65
 
66
66
  def test_fails_when_only_edge_nodes
67
- FakeHome.new(log: test_log).run do |home|
67
+ FakeHome.new(log: fake_log).run do |home|
68
68
  wallet = home.create_wallet
69
69
  remotes = home.remotes
70
70
  remotes.add('localhost', 80)
71
71
  stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
72
72
  assert_raises Zold::Push::EdgesOnly do
73
- Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
73
+ Zold::Push.new(wallets: home.wallets, remotes: remotes, log: fake_log).run(
74
74
  ['push', wallet.id.to_s]
75
75
  )
76
76
  end
@@ -78,13 +78,13 @@ class TestPush < Zold::Test
78
78
  end
79
79
 
80
80
  def test_fails_when_only_one_node
81
- FakeHome.new(log: test_log).run do |home|
81
+ FakeHome.new(log: fake_log).run do |home|
82
82
  wallet = home.create_wallet
83
83
  remotes = home.remotes
84
84
  remotes.add('localhost', 80)
85
85
  stub_request(:put, "http://localhost:80/wallet/#{wallet.id}").to_return(status: 304)
86
86
  assert_raises Zold::Push::NoQuorum do
87
- Zold::Push.new(wallets: home.wallets, remotes: remotes, log: test_log).run(
87
+ Zold::Push.new(wallets: home.wallets, remotes: remotes, log: fake_log).run(
88
88
  ['push', wallet.id.to_s, '--tolerate-edges']
89
89
  )
90
90
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -34,7 +34,7 @@ require_relative '../../lib/zold/commands/remote'
34
34
 
35
35
  # REMOTE test.
36
36
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
37
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
37
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
38
38
  # License:: MIT
39
39
  class TestRemote < Zold::Test
40
40
  def test_updates_remote
@@ -67,7 +67,7 @@ class TestRemote < Zold::Test
67
67
  headers: {},
68
68
  body: '{"version": "0.0.0"}'
69
69
  )
70
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
70
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
71
71
  cmd.run(%w[remote clean])
72
72
  assert(remotes.all.empty?)
73
73
  cmd.run(['remote', 'add', zero.host, zero.port.to_s, '--skip-ping'])
@@ -126,7 +126,7 @@ class TestRemote < Zold::Test
126
126
  score: zero.to_h
127
127
  }.to_json
128
128
  )
129
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
129
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
130
130
  winners = cmd.run(%w[remote elect --ignore-score-value])
131
131
  assert_equal(1, winners.count)
132
132
  end
@@ -135,7 +135,7 @@ class TestRemote < Zold::Test
135
135
  def test_resets_remotes
136
136
  Dir.mktmpdir do |dir|
137
137
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt'))
138
- Zold::Remote.new(remotes: remotes, log: test_log).run(%w[remote reset])
138
+ Zold::Remote.new(remotes: remotes, log: fake_log).run(%w[remote reset])
139
139
  end
140
140
  end
141
141
 
@@ -164,7 +164,7 @@ class TestRemote < Zold::Test
164
164
  body: '{"version": "0.0.0"}'
165
165
  )
166
166
  stub_request(:get, 'http://localhost:8883/remotes').to_return(status: 404)
167
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
167
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
168
168
  cmd.run(%w[remote clean])
169
169
  assert(remotes.all.empty?)
170
170
  cmd.run(['remote', 'add', score.host, score.port.to_s, '--skip-ping'])
@@ -179,7 +179,7 @@ class TestRemote < Zold::Test
179
179
  def test_select_selects_the_strongest_nodes
180
180
  Dir.mktmpdir do |dir|
181
181
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt'))
182
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
182
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
183
183
  (1..11).each do |i|
184
184
  cmd.run(%W[remote add localhost #{i} --skip-ping])
185
185
  remotes.rescore('localhost', i, i)
@@ -197,7 +197,7 @@ class TestRemote < Zold::Test
197
197
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt'))
198
198
  remotes.masters
199
199
  zero = Zold::Score::ZERO
200
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
200
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
201
201
  (5000..5010).each do |port|
202
202
  stub_request(:get, "http://#{zero.host}:#{zero.port}/remotes").to_return(
203
203
  status: 200,
@@ -226,7 +226,7 @@ class TestRemote < Zold::Test
226
226
  def test_sets_masters
227
227
  Dir.mktmpdir do |dir|
228
228
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt'))
229
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
229
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
230
230
  cmd.run(%w[remote masters])
231
231
  assert(!remotes.all.empty?)
232
232
  end
@@ -235,7 +235,7 @@ class TestRemote < Zold::Test
235
235
  def test_select_doesnt_touch_masters
236
236
  Dir.mktmpdir do |dir|
237
237
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt'))
238
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
238
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
239
239
  cmd.run(%w[remote masters])
240
240
  cmd.run(%w[remote select --max-nodes=0])
241
241
  assert(!remotes.all.empty?)
@@ -255,7 +255,7 @@ class TestRemote < Zold::Test
255
255
  all: []
256
256
  }.to_json
257
257
  )
258
- cmd = Zold::Remote.new(remotes: remotes, log: test_log)
258
+ cmd = Zold::Remote.new(remotes: remotes, log: fake_log)
259
259
  cmd.run(['remote', 'add', zero.host, zero.port.to_s, '--skip-ping'])
260
260
  cmd.run(['remote', 'update', '--ignore-score-weakness', '--depth=10'])
261
261
  assert_equal(1, remotes.all.count)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -27,37 +27,37 @@ require_relative '../../lib/zold/commands/remove'
27
27
 
28
28
  # REMOVE test.
29
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
31
31
  # License:: MIT
32
32
  class TestRemove < Zold::Test
33
33
  def test_removes_one_wallet
34
- FakeHome.new(log: test_log).run do |home|
34
+ FakeHome.new(log: fake_log).run do |home|
35
35
  wallet = home.create_wallet
36
36
  assert_equal(1, home.wallets.all.count)
37
- Zold::Remove.new(wallets: home.wallets, log: test_log).run(['remove', wallet.id.to_s])
37
+ Zold::Remove.new(wallets: home.wallets, log: fake_log).run(['remove', wallet.id.to_s])
38
38
  assert(home.wallets.all.empty?)
39
39
  end
40
40
  end
41
41
 
42
42
  def test_removes_wallets
43
- FakeHome.new(log: test_log).run do |home|
43
+ FakeHome.new(log: fake_log).run do |home|
44
44
  home.create_wallet
45
45
  home.create_wallet
46
- Zold::Remove.new(wallets: home.wallets, log: test_log).run(['remove'])
46
+ Zold::Remove.new(wallets: home.wallets, log: fake_log).run(['remove'])
47
47
  assert(home.wallets.all.empty?)
48
48
  end
49
49
  end
50
50
 
51
51
  def test_removes_no_wallets
52
- FakeHome.new(log: test_log).run do |home|
53
- Zold::Remove.new(wallets: home.wallets, log: test_log).run(['remove'])
52
+ FakeHome.new(log: fake_log).run do |home|
53
+ Zold::Remove.new(wallets: home.wallets, log: fake_log).run(['remove'])
54
54
  assert(home.wallets.all.empty?)
55
55
  end
56
56
  end
57
57
 
58
58
  def test_removes_absent_wallets
59
- FakeHome.new(log: test_log).run do |home|
60
- Zold::Remove.new(wallets: home.wallets, log: test_log).run(
59
+ FakeHome.new(log: fake_log).run do |home|
60
+ Zold::Remove.new(wallets: home.wallets, log: fake_log).run(
61
61
  ['remove', '7654321076543210', '--force']
62
62
  )
63
63
  assert(home.wallets.all.empty?)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy
3
+ # Copyright (c) 2018-2024 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
@@ -31,7 +31,7 @@ require_relative '../../lib/zold/commands/show'
31
31
 
32
32
  # SHOW test.
33
33
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
34
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
34
+ # Copyright:: Copyright (c) 2018-2024 Zerocracy
35
35
  # License:: MIT
36
36
  class TestShow < Zold::Test
37
37
  def test_checks_wallet_balance
@@ -40,7 +40,7 @@ class TestShow < Zold::Test
40
40
  wallets = Zold::Wallets.new(dir)
41
41
  wallets.acq(id) do |wallet|
42
42
  wallet.init(Zold::Id.new, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
43
- balance = Zold::Show.new(wallets: wallets, copies: File.join(dir, 'c'), log: test_log).run(['show', id.to_s])
43
+ balance = Zold::Show.new(wallets: wallets, copies: File.join(dir, 'c'), log: fake_log).run(['show', id.to_s])
44
44
  assert_equal(Zold::Amount::ZERO, balance)
45
45
  end
46
46
  end