zold 0.31.10 → 0.32.1
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/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/deploy.sh +4 -22
- 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/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 +6 -22
- metadata +26 -174
- data/.0pdd.yml +0 -29
- data/.gitattributes +0 -9
- data/.github/workflows/actionlint.yml +0 -41
- data/.github/workflows/codecov.yml +0 -40
- data/.github/workflows/copyrights.yml +0 -30
- data/.github/workflows/pdd.yml +0 -34
- data/.github/workflows/rake.yml +0 -45
- data/.github/workflows/xcop.yml +0 -30
- data/.github/workflows/yamllint.yml +0 -34
- data/.gitignore +0 -12
- data/.pdd +0 -7
- data/.rubocop.yml +0 -70
- data/.ruby-version +0 -1
- data/.rultor.yml +0 -57
- data/.simplecov +0 -36
- data/cucumber.yml +0 -23
- data/features/cli.feature +0 -16
- data/features/gem_package.feature +0 -26
- data/features/step_definitions/steps.rb +0 -84
- data/features/support/env.rb +0 -26
- data/fixtures/448b451bc62e8e16.z +0 -1005
- data/fixtures/id_rsa +0 -51
- data/fixtures/id_rsa-2 +0 -51
- data/fixtures/id_rsa-2.pub +0 -1
- data/fixtures/id_rsa.pub +0 -1
- data/fixtures/keys/1.pub +0 -1
- data/fixtures/keys/2 +0 -51
- data/fixtures/keys/2.pub +0 -1
- data/fixtures/merge/asserts.rb +0 -36
- data/fixtures/merge/id_rsa +0 -51
- data/fixtures/merge/id_rsa.pub +0 -1
- data/fixtures/merge/into_no_wallet/assert.rb +0 -25
- data/fixtures/merge/into_no_wallet/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/into_no_wallet/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/into_no_wallet/opts +0 -1
- data/fixtures/merge/legacy_negatives_stay/0123456789abcdef.z +0 -6
- data/fixtures/merge/legacy_negatives_stay/assert.rb +0 -25
- data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/legacy_negatives_stay/opts +0 -2
- data/fixtures/merge/missed_wallets/0000000000000000.z +0 -6
- data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -6
- data/fixtures/merge/missed_wallets/assert.rb +0 -25
- data/fixtures/merge/missed_wallets/copies/0123456789abcdef/1.zc +0 -8
- data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/missed_wallets/opts +0 -3
- data/fixtures/merge/negative_overwriting/0123456789abcdef.z +0 -6
- data/fixtures/merge/negative_overwriting/146b852f2d9ad984.z +0 -6
- data/fixtures/merge/negative_overwriting/assert.rb +0 -25
- data/fixtures/merge/negative_overwriting/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/negative_overwriting/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/negative_overwriting/opts +0 -2
- data/fixtures/merge/negatives_in_between/0000000000000000.z +0 -6
- data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -5
- data/fixtures/merge/negatives_in_between/assert.rb +0 -25
- data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -7
- data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/3.zc +0 -6
- data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/scores.zc +0 -3
- data/fixtures/merge/negatives_in_between/opts +0 -1
- data/fixtures/merge/random_expenses/0000000000000000.z +0 -6
- data/fixtures/merge/random_expenses/0123456789abcdef.z +0 -6
- data/fixtures/merge/random_expenses/assert.rb +0 -25
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/1.zc +0 -7
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/2.zc +0 -7
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/3.zc +0 -7
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/4.zc +0 -7
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/5.zc +0 -7
- data/fixtures/merge/random_expenses/copies/0123456789abcdef/scores.zc +0 -5
- data/fixtures/merge/random_expenses/opts +0 -1
- data/fixtures/merge/simple_case/0000000000000000.z +0 -6
- data/fixtures/merge/simple_case/0123456789abcdef.z +0 -4
- data/fixtures/merge/simple_case/assert.rb +0 -25
- data/fixtures/merge/simple_case/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/simple_case/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/simple_case/opts +0 -1
- data/fixtures/merge/unconfirmed_income/0123456789abcdef.z +0 -4
- data/fixtures/merge/unconfirmed_income/assert.rb +0 -25
- data/fixtures/merge/unconfirmed_income/copies/0123456789abcdef/1.zc +0 -6
- data/fixtures/merge/unconfirmed_income/copies/0123456789abcdef/scores.zc +0 -1
- data/fixtures/merge/unconfirmed_income/opts +0 -3
- data/fixtures/scripts/_head.sh +0 -89
- data/fixtures/scripts/calculate-scores.sh +0 -22
- data/fixtures/scripts/distribute-wallet.sh +0 -105
- data/fixtures/scripts/print-helps.sh +0 -27
- data/fixtures/scripts/pull-on-start.sh +0 -52
- data/fixtures/scripts/push-and-pull.sh +0 -63
- data/fixtures/scripts/redeploy-on-upgrade.sh +0 -56
- data/fixtures/scripts/spread-wallets.sh +0 -72
- data/lib/zold/log.rb +0 -139
- data/renovate.json +0 -6
- data/test/commands/routines/test_audit.rb +0 -41
- data/test/commands/routines/test_gc.rb +0 -70
- data/test/commands/routines/test_reconcile.rb +0 -51
- data/test/commands/routines/test_reconnect.rb +0 -46
- data/test/commands/routines/test_retire.rb +0 -40
- data/test/commands/test_alias.rb +0 -76
- data/test/commands/test_calculate.rb +0 -40
- data/test/commands/test_clean.rb +0 -73
- data/test/commands/test_create.rb +0 -50
- data/test/commands/test_diff.rb +0 -61
- data/test/commands/test_fetch.rb +0 -162
- data/test/commands/test_invoice.rb +0 -50
- data/test/commands/test_list.rb +0 -47
- data/test/commands/test_merge.rb +0 -129
- data/test/commands/test_node.rb +0 -68
- data/test/commands/test_pay.rb +0 -221
- data/test/commands/test_propagate.rb +0 -51
- data/test/commands/test_pull.rb +0 -70
- data/test/commands/test_push.rb +0 -93
- data/test/commands/test_remote.rb +0 -265
- data/test/commands/test_remove.rb +0 -66
- data/test/commands/test_show.rb +0 -48
- data/test/commands/test_taxes.rb +0 -76
- data/test/fake_home.rb +0 -104
- data/test/node/fake_entrance.rb +0 -43
- data/test/node/fake_node.rb +0 -105
- data/test/node/test_async_entrance.rb +0 -103
- data/test/node/test_entrance.rb +0 -82
- data/test/node/test_farm.rb +0 -177
- data/test/node/test_farmers.rb +0 -76
- data/test/node/test_front.rb +0 -399
- data/test/node/test_nodup_entrance.rb +0 -49
- data/test/node/test_nospam_entrance.rb +0 -49
- data/test/node/test_safe_entrance.rb +0 -59
- data/test/node/test_spread_entrance.rb +0 -67
- data/test/node/test_sync_entrance.rb +0 -41
- data/test/node/test_trace.rb +0 -36
- data/test/test__helper.rb +0 -112
- data/test/test_age.rb +0 -55
- data/test/test_amount.rb +0 -81
- data/test/test_cached_wallets.rb +0 -73
- data/test/test_copies.rb +0 -145
- data/test/test_dir_items.rb +0 -90
- data/test/test_gem.rb +0 -41
- data/test/test_hands.rb +0 -69
- data/test/test_hexnum.rb +0 -36
- data/test/test_http.rb +0 -225
- data/test/test_hungry_wallets.rb +0 -90
- data/test/test_id.rb +0 -79
- data/test/test_json_page.rb +0 -47
- data/test/test_key.rb +0 -99
- data/test/test_log.rb +0 -49
- data/test/test_metronome.rb +0 -89
- data/test/test_patch.rb +0 -178
- data/test/test_prefixes.rb +0 -49
- data/test/test_remotes.rb +0 -319
- data/test/test_signature.rb +0 -49
- data/test/test_size.rb +0 -39
- data/test/test_sync_wallets.rb +0 -57
- data/test/test_tax.rb +0 -171
- data/test/test_thread_pool.rb +0 -89
- data/test/test_tree_wallets.rb +0 -83
- data/test/test_txn.rb +0 -89
- data/test/test_upgrades.rb +0 -99
- data/test/test_verbose_thread.rb +0 -55
- data/test/test_version.rb +0 -35
- data/test/test_wallet.rb +0 -318
- data/test/test_wallets.rb +0 -85
- data/test/test_zold.rb +0 -99
- data/test/upgrades/test_delete_banned_wallets.rb +0 -47
- data/test/upgrades/test_protocol_up.rb +0 -42
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require_relative '../test__helper'
|
|
26
|
-
require_relative '../../lib/zold/wallets'
|
|
27
|
-
require_relative '../../lib/zold/key'
|
|
28
|
-
require_relative '../../lib/zold/commands/create'
|
|
29
|
-
|
|
30
|
-
# CREATE test.
|
|
31
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
33
|
-
# License:: MIT
|
|
34
|
-
class TestCreate < Zold::Test
|
|
35
|
-
def test_creates_wallet
|
|
36
|
-
Dir.mktmpdir do |dir|
|
|
37
|
-
wallets = Zold::Wallets.new(dir)
|
|
38
|
-
id = Zold::Create.new(wallets: wallets, remotes: nil, log: fake_log).run(
|
|
39
|
-
['create', '--public-key=fixtures/id_rsa.pub', '--skip-test']
|
|
40
|
-
)
|
|
41
|
-
wallets.acq(id) do |wallet|
|
|
42
|
-
assert(wallet.balance.zero?)
|
|
43
|
-
assert(
|
|
44
|
-
File.exist?(File.join(dir, "#{wallet.id}#{Zold::Wallet::EXT}")),
|
|
45
|
-
"Wallet file not found: #{wallet.id}#{Zold::Wallet::EXT}"
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
data/test/commands/test_diff.rb
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'json'
|
|
25
|
-
require 'time'
|
|
26
|
-
require 'webmock/minitest'
|
|
27
|
-
require_relative '../test__helper'
|
|
28
|
-
require_relative '../fake_home'
|
|
29
|
-
require_relative '../../lib/zold/wallets'
|
|
30
|
-
require_relative '../../lib/zold/wallet'
|
|
31
|
-
require_relative '../../lib/zold/id'
|
|
32
|
-
require_relative '../../lib/zold/copies'
|
|
33
|
-
require_relative '../../lib/zold/key'
|
|
34
|
-
require_relative '../../lib/zold/commands/pay'
|
|
35
|
-
require_relative '../../lib/zold/commands/diff'
|
|
36
|
-
|
|
37
|
-
# DIFF test.
|
|
38
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
39
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
40
|
-
# License:: MIT
|
|
41
|
-
class TestDiff < Zold::Test
|
|
42
|
-
def test_diff_with_copies
|
|
43
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
44
|
-
wallet = home.create_wallet
|
|
45
|
-
first = home.create_wallet
|
|
46
|
-
File.write(first.path, File.read(wallet.path))
|
|
47
|
-
second = home.create_wallet
|
|
48
|
-
File.write(second.path, File.read(wallet.path))
|
|
49
|
-
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
|
|
50
|
-
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
|
51
|
-
)
|
|
52
|
-
copies = home.copies(wallet)
|
|
53
|
-
copies.add(File.read(first.path), 'host-1', 80, 5)
|
|
54
|
-
copies.add(File.read(second.path), 'host-2', 80, 5)
|
|
55
|
-
diff = Zold::Diff.new(wallets: home.wallets, copies: copies.root, log: fake_log).run(
|
|
56
|
-
['diff', wallet.id.to_s]
|
|
57
|
-
)
|
|
58
|
-
assert(diff.include?('-0001;'), diff)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
data/test/commands/test_fetch.rb
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require 'json'
|
|
26
|
-
require 'time'
|
|
27
|
-
require 'webmock/minitest'
|
|
28
|
-
require 'zold/score'
|
|
29
|
-
require_relative '../test__helper'
|
|
30
|
-
require_relative '../fake_home'
|
|
31
|
-
require_relative '../../lib/zold/wallet'
|
|
32
|
-
require_relative '../../lib/zold/wallets'
|
|
33
|
-
require_relative '../../lib/zold/remotes'
|
|
34
|
-
require_relative '../../lib/zold/id'
|
|
35
|
-
require_relative '../../lib/zold/copies'
|
|
36
|
-
require_relative '../../lib/zold/key'
|
|
37
|
-
require_relative '../../lib/zold/commands/fetch'
|
|
38
|
-
|
|
39
|
-
# FETCH test.
|
|
40
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
41
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
42
|
-
# License:: MIT
|
|
43
|
-
class TestFetch < Zold::Test
|
|
44
|
-
def test_fetches_wallet
|
|
45
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
46
|
-
wallet = home.create_wallet
|
|
47
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
|
48
|
-
status: 200,
|
|
49
|
-
body: {
|
|
50
|
-
score: Zold::Score::ZERO.to_h,
|
|
51
|
-
size: 10_000,
|
|
52
|
-
mtime: Time.now.utc.iso8601
|
|
53
|
-
}.to_json
|
|
54
|
-
)
|
|
55
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
|
56
|
-
.to_return(status: 200, body: File.read(wallet.path))
|
|
57
|
-
stub_request(:get, "http://localhost:81/wallet/#{wallet.id}").to_return(status: 404)
|
|
58
|
-
remotes = home.remotes
|
|
59
|
-
remotes.add('localhost', 4096)
|
|
60
|
-
remotes.add('localhost', 81)
|
|
61
|
-
copies = home.copies(wallet)
|
|
62
|
-
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: fake_log).run(
|
|
63
|
-
['fetch', '--tolerate-edges', '--tolerate-quorum=1', '--ignore-score-weakness', wallet.id.to_s]
|
|
64
|
-
)
|
|
65
|
-
assert_equal(1, copies.all.count)
|
|
66
|
-
assert_equal('1', copies.all[0][:name])
|
|
67
|
-
assert_equal(0, copies.all[0][:score])
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_fetches_multiple_wallets
|
|
72
|
-
log = TestLogger.new(fake_log)
|
|
73
|
-
FakeHome.new(log: log).run do |home|
|
|
74
|
-
wallet_a = home.create_wallet
|
|
75
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}").to_return(
|
|
76
|
-
status: 200,
|
|
77
|
-
body: {
|
|
78
|
-
score: Zold::Score::ZERO.to_h,
|
|
79
|
-
size: 10_000,
|
|
80
|
-
mtime: Time.now.utc.iso8601
|
|
81
|
-
}.to_json
|
|
82
|
-
)
|
|
83
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}.bin")
|
|
84
|
-
.to_return(status: 200, body: File.read(wallet_a.path))
|
|
85
|
-
wallet_b = home.create_wallet
|
|
86
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}").to_return(
|
|
87
|
-
status: 200,
|
|
88
|
-
body: {
|
|
89
|
-
score: Zold::Score::ZERO.to_h,
|
|
90
|
-
size: 10_000,
|
|
91
|
-
mtime: Time.now.utc.iso8601
|
|
92
|
-
}.to_json
|
|
93
|
-
)
|
|
94
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}.bin")
|
|
95
|
-
.to_return(status: 200, body: File.read(wallet_b.path))
|
|
96
|
-
remotes = home.remotes
|
|
97
|
-
remotes.add('localhost', 4096)
|
|
98
|
-
copies_a = home.copies(wallet_a)
|
|
99
|
-
copies_b = home.copies(wallet_b)
|
|
100
|
-
Zold::Fetch.new(wallets: home.wallets, copies: copies_a.root, remotes: remotes, log: log).run(
|
|
101
|
-
[
|
|
102
|
-
'fetch', '--tolerate-edges', '--tolerate-quorum=1', '--ignore-score-weakness',
|
|
103
|
-
'--threads 2', wallet_a.id.to_s, wallet_b.id.to_s
|
|
104
|
-
]
|
|
105
|
-
)
|
|
106
|
-
assert_equal(1, copies_a.all.count)
|
|
107
|
-
assert_equal('1', copies_a.all[0][:name])
|
|
108
|
-
assert_equal(0, copies_a.all[0][:score])
|
|
109
|
-
assert_equal(1, copies_b.all.count)
|
|
110
|
-
assert_equal('1', copies_b.all[0][:name])
|
|
111
|
-
assert_equal(0, copies_b.all[0][:score])
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def test_fails_when_only_edge_nodes
|
|
116
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
117
|
-
wallet = home.create_wallet
|
|
118
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
|
119
|
-
status: 200,
|
|
120
|
-
body: {
|
|
121
|
-
score: Zold::Score::ZERO.to_h,
|
|
122
|
-
size: 10_000,
|
|
123
|
-
mtime: Time.now.utc.iso8601
|
|
124
|
-
}.to_json
|
|
125
|
-
)
|
|
126
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
|
127
|
-
.to_return(status: 200, body: File.read(wallet.path))
|
|
128
|
-
remotes = home.remotes
|
|
129
|
-
remotes.add('localhost', 4096)
|
|
130
|
-
copies = home.copies(wallet)
|
|
131
|
-
assert_raises Zold::Fetch::EdgesOnly do
|
|
132
|
-
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: fake_log).run(
|
|
133
|
-
['fetch', '--ignore-score-weakness', wallet.id.to_s]
|
|
134
|
-
)
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def test_fails_when_only_one_node
|
|
140
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
141
|
-
wallet = home.create_wallet
|
|
142
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
|
143
|
-
status: 200,
|
|
144
|
-
body: {
|
|
145
|
-
score: Zold::Score::ZERO.to_h,
|
|
146
|
-
size: 10_000,
|
|
147
|
-
mtime: Time.now.utc.iso8601
|
|
148
|
-
}.to_json
|
|
149
|
-
)
|
|
150
|
-
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
|
151
|
-
.to_return(status: 200, body: File.read(wallet.path))
|
|
152
|
-
remotes = home.remotes
|
|
153
|
-
remotes.add('localhost', 4096)
|
|
154
|
-
copies = home.copies(wallet)
|
|
155
|
-
assert_raises Zold::Fetch::NoQuorum do
|
|
156
|
-
Zold::Fetch.new(wallets: home.wallets, copies: copies.root, remotes: remotes, log: fake_log).run(
|
|
157
|
-
['fetch', '--tolerate-edges', '--ignore-score-weakness', wallet.id.to_s]
|
|
158
|
-
)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require_relative '../test__helper'
|
|
26
|
-
require_relative '../../lib/zold/wallets'
|
|
27
|
-
require_relative '../../lib/zold/amount'
|
|
28
|
-
require_relative '../../lib/zold/key'
|
|
29
|
-
require_relative '../../lib/zold/id'
|
|
30
|
-
require_relative '../../lib/zold/commands/invoice'
|
|
31
|
-
|
|
32
|
-
# INVOICE test.
|
|
33
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
34
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
35
|
-
# License:: MIT
|
|
36
|
-
class TestInvoice < Zold::Test
|
|
37
|
-
def test_generates_invoice
|
|
38
|
-
Dir.mktmpdir do |dir|
|
|
39
|
-
id = Zold::Id.new
|
|
40
|
-
wallets = Zold::Wallets.new(dir)
|
|
41
|
-
wallets.acq(id) do |source|
|
|
42
|
-
source.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
|
43
|
-
invoice = Zold::Invoice.new(wallets: wallets, remotes: nil, copies: nil, log: fake_log).run(
|
|
44
|
-
['invoice', id.to_s, '--length=16']
|
|
45
|
-
)
|
|
46
|
-
assert_equal(33, invoice.length)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
data/test/commands/test_list.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require_relative '../test__helper'
|
|
26
|
-
require_relative '../../lib/zold/wallet'
|
|
27
|
-
require_relative '../../lib/zold/wallets'
|
|
28
|
-
require_relative '../../lib/zold/key'
|
|
29
|
-
require_relative '../../lib/zold/id'
|
|
30
|
-
require_relative '../../lib/zold/commands/list'
|
|
31
|
-
|
|
32
|
-
# LIST test.
|
|
33
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
34
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
35
|
-
# License:: MIT
|
|
36
|
-
class TestList < Zold::Test
|
|
37
|
-
def test_lists_wallets_with_balances
|
|
38
|
-
Dir.mktmpdir do |dir|
|
|
39
|
-
id = Zold::Id.new
|
|
40
|
-
wallets = Zold::Wallets.new(dir)
|
|
41
|
-
wallets.acq(id) do |wallet|
|
|
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: fake_log).run
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
data/test/commands/test_merge.rb
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require 'time'
|
|
26
|
-
require 'webmock/minitest'
|
|
27
|
-
require 'zold/score'
|
|
28
|
-
require 'English'
|
|
29
|
-
require_relative '../test__helper'
|
|
30
|
-
require_relative '../fake_home'
|
|
31
|
-
require_relative '../../lib/zold/wallet'
|
|
32
|
-
require_relative '../../lib/zold/wallets'
|
|
33
|
-
require_relative '../../lib/zold/id'
|
|
34
|
-
require_relative '../../lib/zold/copies'
|
|
35
|
-
require_relative '../../lib/zold/key'
|
|
36
|
-
require_relative '../../lib/zold/patch'
|
|
37
|
-
require_relative '../../lib/zold/commands/merge'
|
|
38
|
-
require_relative '../../lib/zold/commands/pay'
|
|
39
|
-
|
|
40
|
-
# MERGE test.
|
|
41
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
42
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
43
|
-
# License:: MIT
|
|
44
|
-
class TestMerge < Zold::Test
|
|
45
|
-
def test_merges_wallet
|
|
46
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
47
|
-
wallet = home.create_wallet
|
|
48
|
-
first = home.create_wallet
|
|
49
|
-
File.write(first.path, File.read(wallet.path))
|
|
50
|
-
second = home.create_wallet
|
|
51
|
-
File.write(second.path, File.read(wallet.path))
|
|
52
|
-
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: fake_log).run(
|
|
53
|
-
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
|
54
|
-
)
|
|
55
|
-
copies = home.copies(wallet)
|
|
56
|
-
copies.add(File.read(first.path), 'host-1', 80, 5)
|
|
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: fake_log).run(
|
|
59
|
-
['merge', wallet.id.to_s]
|
|
60
|
-
)
|
|
61
|
-
assert(1, modified.count)
|
|
62
|
-
assert(wallet.id, modified[0])
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def test_merges_with_a_broken_copy
|
|
67
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
68
|
-
wallet = home.create_wallet
|
|
69
|
-
copies = home.copies(wallet)
|
|
70
|
-
copies.add(File.read(wallet.path), 'good-host', 80, 5)
|
|
71
|
-
copies.add('some garbage', 'bad-host', 80, 5)
|
|
72
|
-
modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: fake_log).run(
|
|
73
|
-
['merge', wallet.id.to_s]
|
|
74
|
-
)
|
|
75
|
-
assert(modified.empty?)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_merges_a_copy_on_top
|
|
80
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
81
|
-
wallet = home.create_wallet(Zold::Id::ROOT)
|
|
82
|
-
copies = home.copies(wallet)
|
|
83
|
-
copies.add(File.read(wallet.path), 'good-host', 80, 5)
|
|
84
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
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: fake_log).run(
|
|
87
|
-
['merge', wallet.id.to_s]
|
|
88
|
-
)
|
|
89
|
-
assert(!wallet.balance.zero?)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def test_rejects_fake_positives_in_new_wallet
|
|
94
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
95
|
-
main = home.create_wallet
|
|
96
|
-
remote = home.create_wallet
|
|
97
|
-
File.write(remote.path, File.read(main.path))
|
|
98
|
-
remote.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 11.0), 'NOPREFIX', Zold::Id.new, 'fake'))
|
|
99
|
-
copies = home.copies(main)
|
|
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: fake_log).run(
|
|
102
|
-
['merge', main.id.to_s, '--no-baseline']
|
|
103
|
-
)
|
|
104
|
-
assert_equal(Zold::Amount::ZERO, main.balance)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
base = 'fixtures/merge'
|
|
109
|
-
Dir.new(base).select { |f| File.directory?(File.join(base, f)) && !f.start_with?('.') }.each do |f|
|
|
110
|
-
method = "test_#{f}"
|
|
111
|
-
define_method(method) do
|
|
112
|
-
Dir.mktmpdir do |dir|
|
|
113
|
-
FileUtils.cp_r(File.join('fixtures/merge', "#{f}/."), dir)
|
|
114
|
-
scores = File.join(dir, "copies/0123456789abcdef/scores#{Zold::Copies::EXT}")
|
|
115
|
-
File.write(scores, File.read(scores).gsub('NOW', Time.now.utc.iso8601))
|
|
116
|
-
FileUtils.cp('fixtures/merge/asserts.rb', dir)
|
|
117
|
-
wallets = Zold::Wallets.new(dir)
|
|
118
|
-
copies = File.join(dir, 'copies')
|
|
119
|
-
remotes = Zold::Remotes.new(file: File.join(dir, 'remotes'))
|
|
120
|
-
Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: fake_log).run(
|
|
121
|
-
%w[merge 0123456789abcdef] + File.read(File.join(dir, 'opts')).split("\n")
|
|
122
|
-
)
|
|
123
|
-
Dir.chdir(dir) do
|
|
124
|
-
require File.join(dir, 'assert.rb')
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
data/test/commands/test_node.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'minitest/autorun'
|
|
24
|
-
require 'tmpdir'
|
|
25
|
-
require 'webmock/minitest'
|
|
26
|
-
require_relative '../test__helper'
|
|
27
|
-
require_relative '../../lib/zold/wallet'
|
|
28
|
-
require_relative '../../lib/zold/remotes'
|
|
29
|
-
require_relative '../../lib/zold/id'
|
|
30
|
-
require_relative '../../lib/zold/copies'
|
|
31
|
-
require_relative '../../lib/zold/key'
|
|
32
|
-
require_relative '../../lib/zold/commands/node'
|
|
33
|
-
require_relative '../../lib/zold/commands/fetch'
|
|
34
|
-
require_relative '../../lib/zold/commands/push'
|
|
35
|
-
require_relative '../node/fake_node'
|
|
36
|
-
|
|
37
|
-
# NODE test.
|
|
38
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
39
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
40
|
-
# License:: MIT
|
|
41
|
-
class TestNode < Zold::Test
|
|
42
|
-
def test_push_and_fetch
|
|
43
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
44
|
-
FakeNode.new(log: fake_log).run do |port|
|
|
45
|
-
wallets = home.wallets
|
|
46
|
-
wallet = home.create_wallet
|
|
47
|
-
remotes = home.remotes
|
|
48
|
-
remotes.add('localhost', port)
|
|
49
|
-
Zold::Push.new(wallets: wallets, remotes: remotes, log: fake_log).run(
|
|
50
|
-
['push', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1']
|
|
51
|
-
)
|
|
52
|
-
copies = home.copies(wallet)
|
|
53
|
-
begin
|
|
54
|
-
retries ||= 0
|
|
55
|
-
Zold::Fetch.new(
|
|
56
|
-
wallets: wallets, copies: copies.root,
|
|
57
|
-
remotes: remotes, log: fake_log
|
|
58
|
-
).run(['fetch', '--ignore-score-weakness', '--tolerate-edges', '--tolerate-quorum=1'])
|
|
59
|
-
rescue StandardError => _e
|
|
60
|
-
sleep 1
|
|
61
|
-
retry if (retries += 1) < 3
|
|
62
|
-
end
|
|
63
|
-
assert_equal(1, copies.all.count)
|
|
64
|
-
assert_equal('1', copies.all[0][:name])
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|