zold 0.31.10 → 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.
- checksums.yaml +4 -4
- data/.0pdd.yml +2 -19
- data/.github/typos.toml +11 -0
- data/.github/workflows/actionlint.yml +5 -21
- data/.github/workflows/bashate.yml +25 -0
- data/.github/workflows/codecov.yml +11 -24
- data/.github/workflows/copyrights.yml +6 -21
- data/.github/workflows/hadolint.yml +14 -0
- data/.github/workflows/markdown-lint.yml +19 -0
- data/.github/workflows/pdd.yml +5 -20
- data/.github/workflows/rake.yml +8 -22
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/shellcheck.yml +19 -0
- data/.github/workflows/typos.yml +21 -0
- data/.github/workflows/xcop.yml +5 -20
- data/.github/workflows/yamllint.yml +5 -20
- data/.gitignore +9 -6
- data/.rubocop.yml +16 -20
- data/.ruby-version +1 -1
- data/.rultor.yml +6 -22
- data/Dockerfile +11 -27
- data/Gemfile +21 -33
- data/Gemfile.lock +181 -126
- data/Guardfile +0 -0
- data/INSTALL.md +80 -59
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +183 -154
- data/REUSE.toml +40 -0
- data/Rakefile +4 -38
- data/bin/zold +7 -37
- data/cucumber.yml +2 -19
- data/deploy.sh +4 -22
- data/features/cli.feature +2 -0
- data/features/gem_package.feature +2 -0
- data/features/step_definitions/steps.rb +2 -19
- data/features/support/env.rb +2 -19
- data/fixtures/merge/asserts.rb +3 -19
- data/fixtures/merge/into_no_wallet/assert.rb +2 -19
- data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -19
- data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +1 -1
- data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -2
- data/fixtures/merge/missed_wallets/assert.rb +2 -19
- data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +1 -1
- data/fixtures/merge/negative_overwriting/assert.rb +2 -19
- data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -1
- data/fixtures/merge/negatives_in_between/assert.rb +2 -19
- data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -1
- data/fixtures/merge/negatives_in_between/opts +1 -1
- data/fixtures/merge/random_expenses/assert.rb +2 -19
- data/fixtures/merge/random_expenses/opts +1 -1
- data/fixtures/merge/simple_case/assert.rb +2 -19
- data/fixtures/merge/simple_case/opts +1 -1
- data/fixtures/merge/unconfirmed_income/assert.rb +2 -19
- data/fixtures/scripts/_head.sh +16 -33
- data/fixtures/scripts/calculate-scores.sh +3 -20
- data/fixtures/scripts/distribute-wallet.sh +26 -43
- data/fixtures/scripts/print-helps.sh +5 -23
- data/fixtures/scripts/pull-on-start.sh +12 -29
- data/fixtures/scripts/push-and-pull.sh +10 -27
- data/fixtures/scripts/redeploy-on-upgrade.sh +18 -34
- data/fixtures/scripts/spread-wallets.sh +24 -40
- data/lib/zold/age.rb +3 -20
- data/lib/zold/amount.rb +3 -20
- data/lib/zold/cached_wallets.rb +3 -20
- data/lib/zold/commands/alias.rb +4 -21
- data/lib/zold/commands/args.rb +4 -21
- data/lib/zold/commands/calculate.rb +5 -22
- data/lib/zold/commands/clean.rb +6 -23
- data/lib/zold/commands/create.rb +5 -22
- data/lib/zold/commands/diff.rb +5 -22
- data/lib/zold/commands/fetch.rb +6 -23
- data/lib/zold/commands/invoice.rb +5 -22
- data/lib/zold/commands/list.rb +5 -22
- data/lib/zold/commands/merge.rb +7 -24
- data/lib/zold/commands/next.rb +5 -22
- data/lib/zold/commands/node.rb +4 -21
- data/lib/zold/commands/pay.rb +6 -23
- data/lib/zold/commands/propagate.rb +5 -22
- data/lib/zold/commands/pull.rb +5 -22
- data/lib/zold/commands/push.rb +5 -22
- data/lib/zold/commands/remote.rb +7 -24
- data/lib/zold/commands/remove.rb +5 -22
- data/lib/zold/commands/routines/audit.rb +4 -21
- data/lib/zold/commands/routines/gc.rb +6 -23
- data/lib/zold/commands/routines/reconcile.rb +5 -22
- data/lib/zold/commands/routines/reconnect.rb +4 -21
- data/lib/zold/commands/routines/retire.rb +4 -21
- data/lib/zold/commands/routines/spread.rb +5 -22
- data/lib/zold/commands/routines.rb +3 -20
- data/lib/zold/commands/show.rb +5 -22
- data/lib/zold/commands/taxes.rb +5 -22
- data/lib/zold/commands/thread_badge.rb +3 -20
- data/lib/zold/copies.rb +6 -25
- data/lib/zold/dir_items.rb +3 -20
- data/lib/zold/endless.rb +5 -22
- data/lib/zold/gem.rb +3 -20
- data/lib/zold/hands.rb +6 -23
- data/lib/zold/head.rb +4 -21
- data/lib/zold/hexnum.rb +3 -20
- data/lib/zold/http.rb +3 -20
- data/lib/zold/hungry_wallets.rb +6 -23
- data/lib/zold/id.rb +3 -20
- data/lib/zold/json_page.rb +5 -22
- data/lib/zold/key.rb +3 -20
- data/lib/zold/metronome.rb +5 -22
- data/lib/zold/node/async_entrance.rb +6 -23
- data/lib/zold/node/entrance.rb +7 -24
- data/lib/zold/node/farm.rb +5 -22
- data/lib/zold/node/farmers.rb +15 -32
- data/lib/zold/node/front.rb +6 -23
- data/lib/zold/node/journaled_pipeline.rb +8 -25
- data/lib/zold/node/nodup_entrance.rb +6 -23
- data/lib/zold/node/nospam_entrance.rb +6 -23
- data/lib/zold/node/pipeline.rb +6 -23
- data/lib/zold/node/safe_entrance.rb +4 -22
- data/lib/zold/node/soft_error.rb +3 -20
- data/lib/zold/node/spread_entrance.rb +5 -22
- data/lib/zold/node/sync_entrance.rb +5 -22
- data/lib/zold/node/trace.rb +3 -20
- data/lib/zold/patch.rb +6 -23
- data/lib/zold/prefixes.rb +3 -20
- data/lib/zold/remotes.rb +5 -22
- data/lib/zold/signature.rb +3 -20
- data/lib/zold/size.rb +3 -20
- data/lib/zold/sync_wallets.rb +5 -22
- data/lib/zold/tax.rb +4 -21
- data/lib/zold/thread_pool.rb +4 -21
- data/lib/zold/tree_wallets.rb +3 -20
- data/lib/zold/txn.rb +4 -21
- data/lib/zold/txns.rb +4 -21
- data/lib/zold/upgrades.rb +4 -21
- data/lib/zold/verbose_thread.rb +5 -22
- data/lib/zold/version.rb +4 -21
- data/lib/zold/version_file.rb +4 -21
- data/lib/zold/wallet.rb +6 -23
- data/lib/zold/wallets.rb +5 -23
- data/lib/zold.rb +3 -21
- data/resources/banned-wallets.log +6 -6
- data/test/commands/routines/test_audit.rb +3 -21
- data/test/commands/routines/test_gc.rb +3 -21
- data/test/commands/routines/test_reconcile.rb +3 -21
- data/test/commands/routines/test_reconnect.rb +3 -21
- data/test/commands/routines/test_retire.rb +3 -21
- data/test/commands/test_alias.rb +2 -20
- data/test/commands/test_calculate.rb +5 -23
- data/test/commands/test_clean.rb +5 -23
- data/test/commands/test_create.rb +6 -24
- data/test/commands/test_diff.rb +4 -22
- data/test/commands/test_fetch.rb +3 -21
- data/test/commands/test_invoice.rb +3 -21
- data/test/commands/test_list.rb +3 -21
- data/test/commands/test_merge.rb +12 -35
- data/test/commands/test_node.rb +3 -21
- data/test/commands/test_pay.rb +5 -23
- data/test/commands/test_propagate.rb +6 -24
- data/test/commands/test_pull.rb +4 -22
- data/test/commands/test_push.rb +3 -21
- data/test/commands/test_remote.rb +10 -28
- data/test/commands/test_remove.rb +7 -25
- data/test/commands/test_show.rb +3 -21
- data/test/commands/test_taxes.rb +5 -23
- data/test/fake_home.rb +5 -22
- data/test/node/fake_entrance.rb +3 -20
- data/test/node/fake_node.rb +5 -22
- data/test/node/test_async_entrance.rb +3 -21
- data/test/node/test_entrance.rb +7 -25
- data/test/node/test_farm.rb +15 -33
- data/test/node/test_farmers.rb +3 -21
- data/test/node/test_front.rb +22 -42
- data/test/node/test_nodup_entrance.rb +4 -22
- data/test/node/test_nospam_entrance.rb +6 -24
- data/test/node/test_safe_entrance.rb +3 -21
- data/test/node/test_spread_entrance.rb +4 -22
- data/test/node/test_sync_entrance.rb +4 -22
- data/test/node/test_trace.rb +4 -22
- data/test/test__helper.rb +32 -31
- data/test/test_age.rb +5 -23
- data/test/test_amount.rb +15 -34
- data/test/test_cached_wallets.rb +3 -21
- data/test/test_copies.rb +10 -28
- data/test/test_dir_items.rb +4 -22
- data/test/test_gem.rb +3 -21
- data/test/test_hands.rb +3 -21
- data/test/test_hexnum.rb +3 -21
- data/test/test_http.rb +9 -27
- data/test/test_hungry_wallets.rb +6 -24
- data/test/test_id.rb +10 -28
- data/test/test_json_page.rb +3 -21
- data/test/test_key.rb +5 -23
- data/test/test_metronome.rb +6 -24
- data/test/test_patch.rb +10 -28
- data/test/test_prefixes.rb +3 -21
- data/test/test_remotes.rb +17 -35
- data/test/test_signature.rb +3 -21
- data/test/test_size.rb +3 -21
- data/test/test_sync_wallets.rb +3 -21
- data/test/test_tax.rb +6 -24
- data/test/test_thread_pool.rb +6 -24
- data/test/test_tree_wallets.rb +4 -22
- data/test/test_txn.rb +3 -21
- data/test/test_upgrades.rb +3 -21
- data/test/test_verbose_thread.rb +6 -24
- data/test/test_version.rb +2 -20
- data/test/test_wallet.rb +15 -33
- data/test/test_wallets.rb +4 -22
- data/test/test_zold.rb +7 -25
- data/test/upgrades/test_delete_banned_wallets.rb +4 -22
- data/test/upgrades/test_protocol_up.rb +3 -21
- data/upgrades/2.rb +3 -20
- data/upgrades/delete_banned_wallets.rb +3 -20
- data/upgrades/move_wallets_into_tree.rb +3 -20
- data/upgrades/protocol_up.rb +3 -20
- data/upgrades/rename_foreign_wallets.rb +3 -20
- data/views/journal.haml +25 -0
- data/views/layout.haml +25 -0
- data/views/wallet.haml +25 -0
- data/zold.gemspec +5 -21
- metadata +33 -15
- data/.simplecov +0 -36
- data/lib/zold/log.rb +0 -139
- data/test/test_log.rb +0 -49
data/test/test_cached_wallets.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require_relative 'test__helper'
|
|
26
8
|
require_relative 'fake_home'
|
|
@@ -32,7 +14,7 @@ require_relative '../lib/zold/amount'
|
|
|
32
14
|
|
|
33
15
|
# CachedWallets test.
|
|
34
16
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
35
|
-
# Copyright:: Copyright (c) 2018-
|
|
17
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
36
18
|
# License:: MIT
|
|
37
19
|
class TestCachedWallets < Zold::Test
|
|
38
20
|
def test_adds_wallet
|
data/test/test_copies.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require 'time'
|
|
26
8
|
require_relative 'fake_home'
|
|
@@ -33,7 +15,7 @@ require_relative '../lib/zold/wallet'
|
|
|
33
15
|
|
|
34
16
|
# Copies test.
|
|
35
17
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
36
|
-
# Copyright:: Copyright (c) 2018-
|
|
18
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
37
19
|
# License:: MIT
|
|
38
20
|
class TestCopies < Zold::Test
|
|
39
21
|
def test_adds_and_removes_copies
|
|
@@ -54,7 +36,7 @@ class TestCopies < Zold::Test
|
|
|
54
36
|
def test_lists_empty_dir
|
|
55
37
|
Dir.mktmpdir do |dir|
|
|
56
38
|
copies = Zold::Copies.new(File.join(dir, 'xxx'), log: fake_log)
|
|
57
|
-
|
|
39
|
+
assert_empty(copies.all, "#{copies.all.count} is not zero")
|
|
58
40
|
end
|
|
59
41
|
end
|
|
60
42
|
|
|
@@ -65,8 +47,8 @@ class TestCopies < Zold::Test
|
|
|
65
47
|
copies.add(content('z1'), host, 80, 5)
|
|
66
48
|
copies.add(content('z1'), host, 80, 6)
|
|
67
49
|
copies.add(content('z1'), host, 80, 7)
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
assert_predicate(copies.all, :one?, "#{copies.all.count} is not equal to 1")
|
|
51
|
+
assert_equal(7, copies.all[0][:score], "#{copies.all[0][:score]} is not 7")
|
|
70
52
|
end
|
|
71
53
|
end
|
|
72
54
|
|
|
@@ -86,10 +68,10 @@ class TestCopies < Zold::Test
|
|
|
86
68
|
copies = Zold::Copies.new(dir, log: fake_log)
|
|
87
69
|
copies.add(content('h1'), 'zold.io', 4096, 10, time: Time.now - (25 * 60 * 60))
|
|
88
70
|
copies.add(content('h1'), 'zold.io', 4097, 20, time: Time.now - (26 * 60 * 60))
|
|
89
|
-
|
|
71
|
+
assert_path_exists(File.join(dir, "1#{Zold::Copies::EXT}"))
|
|
90
72
|
copies.clean
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
assert_empty(copies.all, "#{copies.all.count} is not empty")
|
|
74
|
+
refute_path_exists(File.join(dir, "1#{Zold::Copies::EXT}"))
|
|
93
75
|
end
|
|
94
76
|
end
|
|
95
77
|
|
|
@@ -98,7 +80,7 @@ class TestCopies < Zold::Test
|
|
|
98
80
|
copies = Zold::Copies.new(dir, log: fake_log)
|
|
99
81
|
copies.add('broken wallet content', 'zold.io', 4096, 10, time: Time.now)
|
|
100
82
|
copies.clean
|
|
101
|
-
|
|
83
|
+
assert_empty(copies.all, "#{copies.all.count} is not empty")
|
|
102
84
|
end
|
|
103
85
|
end
|
|
104
86
|
|
data/test/test_dir_items.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require 'threads'
|
|
26
8
|
require_relative 'test__helper'
|
|
@@ -30,7 +12,7 @@ require_relative '../lib/zold/dir_items'
|
|
|
30
12
|
|
|
31
13
|
# DirItems test.
|
|
32
14
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2018-
|
|
15
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
34
16
|
# License:: MIT
|
|
35
17
|
class TestDirItems < Zold::Test
|
|
36
18
|
def test_intensive_write_in_threads
|
|
@@ -70,7 +52,7 @@ class TestDirItems < Zold::Test
|
|
|
70
52
|
found = Zold::DirItems.new(dir).fetch
|
|
71
53
|
assert_equal(files.count, found.count)
|
|
72
54
|
files.each do |f|
|
|
73
|
-
|
|
55
|
+
assert_includes(found, f, f)
|
|
74
56
|
end
|
|
75
57
|
end
|
|
76
58
|
end
|
data/test/test_gem.rb
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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
|
require_relative '../lib/zold/gem'
|
|
24
7
|
require 'webmock/minitest'
|
|
25
|
-
require 'minitest/autorun'
|
|
26
8
|
|
|
27
9
|
class TestGem < Zold::Test
|
|
28
10
|
def test_last_version
|
|
@@ -36,6 +18,6 @@ class TestGem < Zold::Test
|
|
|
36
18
|
|
|
37
19
|
def test_last_version_live
|
|
38
20
|
WebMock.allow_net_connect!
|
|
39
|
-
|
|
21
|
+
refute_nil(Zold::Gem.new.last_version)
|
|
40
22
|
end
|
|
41
23
|
end
|
data/test/test_hands.rb
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'concurrent'
|
|
25
7
|
require_relative 'test__helper'
|
|
26
8
|
require_relative '../lib/zold/hands'
|
|
27
9
|
|
|
28
10
|
# Hands test.
|
|
29
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2018-
|
|
12
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
31
13
|
# License:: MIT
|
|
32
14
|
class TestHands < Zold::Test
|
|
33
15
|
def test_runs_in_many_threads
|
data/test/test_hexnum.rb
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 '../lib/zold/hexnum'
|
|
25
7
|
|
|
26
8
|
# Hexnum test.
|
|
27
9
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
28
|
-
# Copyright:: Copyright (c) 2018-
|
|
10
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
29
11
|
# License:: MIT
|
|
30
12
|
class TestHexnum < Zold::Test
|
|
31
13
|
def test_prints_and_parses
|
data/test/test_http.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require 'uri'
|
|
26
8
|
require 'webmock/minitest'
|
|
@@ -32,7 +14,7 @@ require_relative '../lib/zold/verbose_thread'
|
|
|
32
14
|
|
|
33
15
|
# Http test.
|
|
34
16
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
35
|
-
# Copyright:: Copyright (c) 2018-
|
|
17
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
36
18
|
# License:: MIT
|
|
37
19
|
class TestHttp < Zold::Test
|
|
38
20
|
def test_pings_broken_uri
|
|
@@ -46,8 +28,8 @@ class TestHttp < Zold::Test
|
|
|
46
28
|
stub_request(:get, 'http://exception/').to_return { raise 'Intentionally' }
|
|
47
29
|
res = Zold::Http.new(uri: 'http://exception/').get
|
|
48
30
|
assert_equal(599, res.status)
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
assert_includes(res.body, 'Intentionally')
|
|
32
|
+
refute(res.headers['nothing'])
|
|
51
33
|
end
|
|
52
34
|
|
|
53
35
|
def test_pings_live_uri
|
|
@@ -141,8 +123,8 @@ class TestHttp < Zold::Test
|
|
|
141
123
|
Zold::Http.new(uri: "http://127.0.0.1:#{port}/").put(f)
|
|
142
124
|
end
|
|
143
125
|
assert_equal(200, res.status, res)
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
assert_includes(body, 'Content-Length: 12', body)
|
|
127
|
+
assert_includes(body, 'Content-Type: text/plain')
|
|
146
128
|
headers = body.split("\n").grep(/^[a-zA-Z-]+:.+$/)
|
|
147
129
|
assert_equal(headers.count, headers.uniq.count)
|
|
148
130
|
thread.kill
|
|
@@ -192,7 +174,7 @@ class TestHttp < Zold::Test
|
|
|
192
174
|
Zold::Http.new(uri: "http://localhost:#{port}/").put(f)
|
|
193
175
|
end
|
|
194
176
|
assert_equal(200, res.status, res)
|
|
195
|
-
|
|
177
|
+
assert_includes(res.body, content, res)
|
|
196
178
|
thread.kill
|
|
197
179
|
thread.join
|
|
198
180
|
end
|
|
@@ -217,7 +199,7 @@ class TestHttp < Zold::Test
|
|
|
217
199
|
Zold::Http.new(uri: "http://localhost:#{port}/").get_file(f)
|
|
218
200
|
File.read(f)
|
|
219
201
|
end
|
|
220
|
-
|
|
202
|
+
assert_includes(body, content, body)
|
|
221
203
|
thread.kill
|
|
222
204
|
thread.join
|
|
223
205
|
end
|
data/test/test_hungry_wallets.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'webmock/minitest'
|
|
25
7
|
require_relative 'test__helper'
|
|
26
8
|
require_relative 'fake_home'
|
|
@@ -31,7 +13,7 @@ require_relative '../lib/zold/hungry_wallets'
|
|
|
31
13
|
|
|
32
14
|
# HungryWallets test.
|
|
33
15
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
34
|
-
# Copyright:: Copyright (c) 2018-
|
|
16
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
35
17
|
# License:: MIT
|
|
36
18
|
class TestHungryWallets < Zold::Test
|
|
37
19
|
def test_pulls_wallet
|
|
@@ -45,7 +27,7 @@ class TestHungryWallets < Zold::Test
|
|
|
45
27
|
home.wallets, remotes, File.join(home.dir, 'copies'),
|
|
46
28
|
pool, log: fake_log
|
|
47
29
|
)
|
|
48
|
-
wallets.acq(id) { |w|
|
|
30
|
+
wallets.acq(id) { |w| refute_predicate(w, :exists?) }
|
|
49
31
|
pool.join(2)
|
|
50
32
|
assert_requested(get, times: 1)
|
|
51
33
|
end
|
|
@@ -63,7 +45,7 @@ class TestHungryWallets < Zold::Test
|
|
|
63
45
|
pool, log: fake_log
|
|
64
46
|
)
|
|
65
47
|
3.times do
|
|
66
|
-
wallets.acq(id) { |w|
|
|
48
|
+
wallets.acq(id) { |w| refute_predicate(w, :exists?) }
|
|
67
49
|
sleep 0.2
|
|
68
50
|
end
|
|
69
51
|
pool.join(2)
|
|
@@ -82,7 +64,7 @@ class TestHungryWallets < Zold::Test
|
|
|
82
64
|
home.wallets, remotes, File.join(home.dir, 'copies'),
|
|
83
65
|
pool, log: fake_log
|
|
84
66
|
)
|
|
85
|
-
wallets.acq(wallet.id) { |w|
|
|
67
|
+
wallets.acq(wallet.id) { |w| assert_predicate(w, :exists?) }
|
|
86
68
|
pool.join(2)
|
|
87
69
|
assert_requested(get, times: 0)
|
|
88
70
|
end
|
data/test/test_id.rb
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require_relative 'test__helper'
|
|
26
8
|
require_relative '../lib/zold/id'
|
|
27
9
|
|
|
28
10
|
# ID test.
|
|
29
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2018-
|
|
12
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
31
13
|
# License:: MIT
|
|
32
14
|
class TestId < Zold::Test
|
|
33
15
|
def test_generates_new_id
|
|
34
16
|
50.times do
|
|
35
17
|
id = Zold::Id.new
|
|
36
|
-
|
|
18
|
+
assert_equal 16, id.to_s.length
|
|
37
19
|
end
|
|
38
20
|
end
|
|
39
21
|
|
|
@@ -41,31 +23,31 @@ class TestId < Zold::Test
|
|
|
41
23
|
before = ''
|
|
42
24
|
500.times do
|
|
43
25
|
id = Zold::Id.new
|
|
44
|
-
|
|
26
|
+
refute_equal id.to_s, before.to_s
|
|
45
27
|
before = id
|
|
46
28
|
end
|
|
47
29
|
end
|
|
48
30
|
|
|
49
31
|
def test_list_of_banned_ids_is_not_empty
|
|
50
|
-
|
|
32
|
+
refute_empty(Zold::Id::BANNED)
|
|
51
33
|
end
|
|
52
34
|
|
|
53
35
|
def test_checks_for_root
|
|
54
|
-
|
|
36
|
+
assert_predicate(Zold::Id::ROOT, :root?)
|
|
55
37
|
end
|
|
56
38
|
|
|
57
39
|
def test_generates_id_only_once
|
|
58
40
|
id = Zold::Id.new
|
|
59
41
|
before = id.to_s
|
|
60
42
|
5.times do
|
|
61
|
-
|
|
43
|
+
assert_equal id.to_s, before
|
|
62
44
|
end
|
|
63
45
|
end
|
|
64
46
|
|
|
65
47
|
def test_parses_id
|
|
66
48
|
hex = 'ff01889402fe0954'
|
|
67
49
|
id = Zold::Id.new(hex)
|
|
68
|
-
|
|
50
|
+
assert_equal(id.to_s, hex, "#{id} is not equal to #{hex}")
|
|
69
51
|
end
|
|
70
52
|
|
|
71
53
|
def test_compares_two_ids_by_text
|
|
@@ -74,6 +56,6 @@ class TestId < Zold::Test
|
|
|
74
56
|
end
|
|
75
57
|
|
|
76
58
|
def test_compares_two_ids
|
|
77
|
-
|
|
59
|
+
assert_equal Zold::Id.new(Zold::Id::ROOT.to_s), Zold::Id.new('0000000000000000')
|
|
78
60
|
end
|
|
79
61
|
end
|
data/test/test_json_page.rb
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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/json_page'
|
|
26
8
|
|
|
27
9
|
# JsonPage test.
|
|
28
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
29
|
-
# Copyright:: Copyright (c) 2018-
|
|
11
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
30
12
|
# License:: MIT
|
|
31
13
|
class TestJsonPage < Zold::Test
|
|
32
14
|
def test_parses_json_page
|
data/test/test_key.rb
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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 'tmpdir'
|
|
25
7
|
require 'openssl'
|
|
26
8
|
require_relative 'test__helper'
|
|
@@ -28,14 +10,14 @@ require_relative '../lib/zold/key'
|
|
|
28
10
|
|
|
29
11
|
# Key test.
|
|
30
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
31
|
-
# Copyright:: Copyright (c) 2018-
|
|
13
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
32
14
|
# License:: MIT
|
|
33
15
|
class TestKey < Zold::Test
|
|
34
16
|
def test_reads_public_rsa
|
|
35
17
|
key = Zold::Key.new(file: 'fixtures/id_rsa.pub')
|
|
36
18
|
assert(key.to_pub.start_with?('MIICI'))
|
|
37
19
|
assert(key.to_pub.end_with?('EAAQ=='))
|
|
38
|
-
|
|
20
|
+
refute_includes(key.to_pub, "\n")
|
|
39
21
|
assert(Zold::Key.new(text: key.to_pub).to_pub.start_with?('MIICI'))
|
|
40
22
|
end
|
|
41
23
|
|
|
@@ -77,7 +59,7 @@ class TestKey < Zold::Test
|
|
|
77
59
|
Dir.new('fixtures/keys').grep(/\.pub$/).each do |f|
|
|
78
60
|
path = "fixtures/keys/#{f}"
|
|
79
61
|
pub = Zold::Key.new(file: path)
|
|
80
|
-
|
|
62
|
+
assert_operator(pub.to_pub.length, :>, 100)
|
|
81
63
|
end
|
|
82
64
|
end
|
|
83
65
|
|
data/test/test_metronome.rb
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
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/metronome'
|
|
26
8
|
|
|
27
9
|
# Metronome test.
|
|
28
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
29
|
-
# Copyright:: Copyright (c) 2018-
|
|
11
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
30
12
|
# License:: MIT
|
|
31
13
|
class TestMetronome < Zold::Test
|
|
32
14
|
def test_start_and_stop
|
|
@@ -42,14 +24,14 @@ class TestMetronome < Zold::Test
|
|
|
42
24
|
metronome = Zold::Metronome.new(fake_log)
|
|
43
25
|
metronome.add(FakeRoutine.new([]))
|
|
44
26
|
metronome.start do |m|
|
|
45
|
-
|
|
27
|
+
refute_nil(m.to_text)
|
|
46
28
|
end
|
|
47
29
|
end
|
|
48
30
|
|
|
49
31
|
def test_prints_empty_to_text
|
|
50
32
|
metronome = Zold::Metronome.new(fake_log)
|
|
51
33
|
metronome.start do |m|
|
|
52
|
-
|
|
34
|
+
refute_nil(m.to_text)
|
|
53
35
|
end
|
|
54
36
|
end
|
|
55
37
|
|
|
@@ -59,7 +41,7 @@ class TestMetronome < Zold::Test
|
|
|
59
41
|
metronome.add(routine)
|
|
60
42
|
metronome.start do
|
|
61
43
|
assert_wait { routine.count >= 2 }
|
|
62
|
-
|
|
44
|
+
assert_operator(routine.count, :>, 1)
|
|
63
45
|
end
|
|
64
46
|
end
|
|
65
47
|
|