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
data/test/test_version.rb
DELETED
|
@@ -1,35 +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 'semantic'
|
|
24
|
-
require 'zold/version'
|
|
25
|
-
require 'minitest/autorun'
|
|
26
|
-
|
|
27
|
-
class TestVersion < Zold::Test
|
|
28
|
-
def test_has_version
|
|
29
|
-
assert Semantic::Version.new(Zold::VERSION)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_has_protocol
|
|
33
|
-
assert Zold::PROTOCOL
|
|
34
|
-
end
|
|
35
|
-
end
|
data/test/test_wallet.rb
DELETED
|
@@ -1,318 +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 'fake_home'
|
|
27
|
-
require_relative '../lib/zold/key'
|
|
28
|
-
require_relative '../lib/zold/age'
|
|
29
|
-
require_relative '../lib/zold/id'
|
|
30
|
-
require_relative '../lib/zold/wallet'
|
|
31
|
-
require_relative '../lib/zold/txn'
|
|
32
|
-
require_relative '../lib/zold/thread_pool'
|
|
33
|
-
require_relative '../lib/zold/amount'
|
|
34
|
-
require_relative '../lib/zold/commands/pay'
|
|
35
|
-
|
|
36
|
-
# Wallet test.
|
|
37
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
38
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
39
|
-
# License:: MIT
|
|
40
|
-
class TestWallet < Zold::Test
|
|
41
|
-
def test_reads_empty_wallet
|
|
42
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
43
|
-
wallet = home.create_wallet
|
|
44
|
-
assert(wallet.txns.empty?)
|
|
45
|
-
assert_equal(Zold::Amount::ZERO, wallet.balance)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_generates_memo
|
|
50
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
51
|
-
wallet = home.create_wallet
|
|
52
|
-
assert(!wallet.mnemo.nil?)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_reads_large_wallet
|
|
57
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
58
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
59
|
-
wallet = home.create_wallet(Zold::Id.new('448b451bc62e8e16'))
|
|
60
|
-
FileUtils.cp('fixtures/448b451bc62e8e16.z', wallet.path)
|
|
61
|
-
start = Time.now
|
|
62
|
-
wallet.txns
|
|
63
|
-
wallet.sub(Zold::Amount.new(zld: 39.99), "NOPREFIX@#{Zold::Id.new}", key)
|
|
64
|
-
time = Time.now - start
|
|
65
|
-
assert(time < 0.5, "Too slow: #{Zold::Age.new(start)} seconds")
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_adds_transaction
|
|
70
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
71
|
-
wallet = home.create_wallet
|
|
72
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
73
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
74
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
75
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
76
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
77
|
-
assert(
|
|
78
|
-
wallet.balance == amount * -3,
|
|
79
|
-
"#{wallet.balance} is not equal to #{amount * -3}"
|
|
80
|
-
)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_adds_similar_transaction
|
|
85
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
86
|
-
wallet = home.create_wallet
|
|
87
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
88
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
89
|
-
id = Zold::Id.new
|
|
90
|
-
wallet.sub(amount, "NOPREFIX@#{id}", key)
|
|
91
|
-
wallet.add(Zold::Txn.new(1, Time.now, amount, 'NOPREFIX', id, '-'))
|
|
92
|
-
assert_raises do
|
|
93
|
-
wallet.add(Zold::Txn.new(1, Time.now, amount, 'NOPREFIX', id, '-'))
|
|
94
|
-
end
|
|
95
|
-
assert_raises do
|
|
96
|
-
wallet.add(Zold::Txn.new(1, Time.now, amount * -1, 'NOPREFIX', id, '-'))
|
|
97
|
-
end
|
|
98
|
-
assert(wallet.balance.zero?)
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def test_checks_similar_transaction
|
|
103
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
104
|
-
wallet = home.create_wallet
|
|
105
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
106
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
107
|
-
id = Zold::Id.new
|
|
108
|
-
wallet.sub(amount, "NOPREFIX@#{id}", key)
|
|
109
|
-
wallet.add(Zold::Txn.new(1, Time.now, amount, 'NOPREFIX', id, '-'))
|
|
110
|
-
assert(wallet.includes_negative?(1))
|
|
111
|
-
assert(wallet.includes_positive?(1, id))
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def test_refurbishes_wallet
|
|
116
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
117
|
-
wallet = home.create_wallet
|
|
118
|
-
amount = Zold::Amount.new(zld: 5.99)
|
|
119
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
120
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
121
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
122
|
-
before = File.read(wallet.path)
|
|
123
|
-
File.write(wallet.path, "#{File.read(wallet.path)}\n\n\n")
|
|
124
|
-
wallet.refurbish
|
|
125
|
-
assert_equal(amount * -2, wallet.balance)
|
|
126
|
-
assert_equal(before, File.read(wallet.path))
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def test_refurbishes_empty_wallet
|
|
131
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
132
|
-
wallet = home.create_wallet
|
|
133
|
-
before = File.read(wallet.path)
|
|
134
|
-
File.write(wallet.path, "#{File.read(wallet.path)}\n\n\n")
|
|
135
|
-
wallet.refurbish
|
|
136
|
-
assert_equal(before, File.read(wallet.path))
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def test_positive_transactions_go_first
|
|
141
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
142
|
-
wallet = home.create_wallet
|
|
143
|
-
time = Time.now
|
|
144
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
145
|
-
wallet.add(Zold::Txn.new(1, time, Zold::Amount.new(zents: 1), 'NOPREFIX', Zold::Id.new, '-'))
|
|
146
|
-
wallet.sub(Zold::Amount.new(zents: 2), "NOPREFIX@#{Zold::Id.new}", key, time: time)
|
|
147
|
-
wallet.add(Zold::Txn.new(2, time, Zold::Amount.new(zents: 3), 'NOPREFIX', Zold::Id.new, '-'))
|
|
148
|
-
wallet.sub(Zold::Amount.new(zents: 4), "NOPREFIX@#{Zold::Id.new}", key, time: time)
|
|
149
|
-
assert_equal('3, 1, -2, -4', wallet.txns.map(&:amount).map(&:to_i).join(', '))
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def test_validate_key_on_payment
|
|
154
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
155
|
-
wallet = home.create_wallet
|
|
156
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
157
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa-2')
|
|
158
|
-
assert_raises RuntimeError do
|
|
159
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def test_adds_transaction_and_reads_back
|
|
165
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
166
|
-
wallet = home.create_wallet
|
|
167
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
168
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
169
|
-
txn = wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
170
|
-
wallet.add(txn.inverse(Zold::Id.new))
|
|
171
|
-
assert(!Zold::Wallet.new(wallet.path).txns[1].sign.end_with?("\n"))
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def test_calculates_wallet_age_in_hours
|
|
176
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
177
|
-
wallet = home.create_wallet
|
|
178
|
-
hours = 100
|
|
179
|
-
wallet.add(
|
|
180
|
-
Zold::Txn.new(
|
|
181
|
-
1,
|
|
182
|
-
Time.now - (100 * 60 * 60),
|
|
183
|
-
Zold::Amount.new(zld: 1.99),
|
|
184
|
-
'NOPREFIX', Zold::Id.new, '-'
|
|
185
|
-
)
|
|
186
|
-
)
|
|
187
|
-
assert_equal(hours, wallet.age.round)
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def test_flushes_and_reads_again
|
|
192
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
193
|
-
wallet = home.create_wallet
|
|
194
|
-
wallet.add(
|
|
195
|
-
Zold::Txn.new(
|
|
196
|
-
1,
|
|
197
|
-
Time.now,
|
|
198
|
-
Zold::Amount.new(zld: 1.99),
|
|
199
|
-
'NOPREFIX', Zold::Id.new, '-'
|
|
200
|
-
)
|
|
201
|
-
)
|
|
202
|
-
assert_equal(1, wallet.txns.count)
|
|
203
|
-
assert_equal('test', wallet.network)
|
|
204
|
-
wallet.flush
|
|
205
|
-
assert_equal(1, wallet.txns.count)
|
|
206
|
-
assert_equal('test', wallet.network)
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
def test_returns_modified_time
|
|
211
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
212
|
-
wallet = home.create_wallet
|
|
213
|
-
assert(wallet.mtime > Time.now - (60 * 60))
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
def test_returns_digest
|
|
218
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
219
|
-
wallet = home.create_wallet
|
|
220
|
-
assert_equal(64, wallet.digest.length)
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def test_raises_when_broken_format
|
|
225
|
-
Dir.mktmpdir do |dir|
|
|
226
|
-
file = File.join(dir, "0123456701234567#{Zold::Wallet::EXT}")
|
|
227
|
-
File.write(file, 'broken head')
|
|
228
|
-
assert_raises(Zold::Head::CantParse) do
|
|
229
|
-
Zold::Wallet.new(file).id
|
|
230
|
-
end
|
|
231
|
-
assert_raises(Zold::Txns::CantParse) do
|
|
232
|
-
Zold::Wallet.new(file).txns
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def test_returns_protocol
|
|
238
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
239
|
-
wallet = home.create_wallet
|
|
240
|
-
assert_equal(Zold::PROTOCOL, wallet.protocol)
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
def test_iterates_income_transactions
|
|
245
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
246
|
-
wallet = home.create_wallet
|
|
247
|
-
wallet.add(
|
|
248
|
-
Zold::Txn.new(
|
|
249
|
-
1, Time.now, Zold::Amount.new(zld: 39.99),
|
|
250
|
-
'NOPREFIX', Zold::Id.new, '-'
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
wallet.add(
|
|
254
|
-
Zold::Txn.new(
|
|
255
|
-
2, Time.now, Zold::Amount.new(zld: 14.95),
|
|
256
|
-
'NOPREFIX', Zold::Id.new, '-'
|
|
257
|
-
)
|
|
258
|
-
)
|
|
259
|
-
sum = Zold::Amount::ZERO
|
|
260
|
-
wallet.txns.each do |t|
|
|
261
|
-
sum += t.amount unless t.amount.negative?
|
|
262
|
-
end
|
|
263
|
-
assert(
|
|
264
|
-
sum == Zold::Amount.new(zents: 235_965_503_242),
|
|
265
|
-
"#{sum} (#{sum.to_i}) is not equal to #{Zold::Amount.new(zld: 54.94)}"
|
|
266
|
-
)
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
def test_sorts_them_always_right
|
|
271
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
272
|
-
time = Time.now
|
|
273
|
-
txns = []
|
|
274
|
-
50.times do
|
|
275
|
-
txns << Zold::Txn.new(
|
|
276
|
-
1,
|
|
277
|
-
time,
|
|
278
|
-
Zold::Amount.new(zld: 1.99),
|
|
279
|
-
'NOPREFIX', Zold::Id.new, '-'
|
|
280
|
-
)
|
|
281
|
-
end
|
|
282
|
-
wallet = home.create_wallet
|
|
283
|
-
empty = File.read(wallet.path)
|
|
284
|
-
text = ''
|
|
285
|
-
10.times do
|
|
286
|
-
File.write(wallet.path, empty)
|
|
287
|
-
txns.shuffle!
|
|
288
|
-
txns.each { |t| wallet.add(t) }
|
|
289
|
-
wallet.refurbish
|
|
290
|
-
if text.empty?
|
|
291
|
-
text = File.read(wallet.path)
|
|
292
|
-
next
|
|
293
|
-
end
|
|
294
|
-
assert_equal(text, File.read(wallet.path))
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
def test_collects_memory_garbage
|
|
300
|
-
skip
|
|
301
|
-
require 'get_process_mem'
|
|
302
|
-
start = GetProcessMem.new.bytes.to_i
|
|
303
|
-
Zold::Hands.exec(20) do
|
|
304
|
-
40.times do |i|
|
|
305
|
-
wallet = Zold::Wallet.new('fixtures/448b451bc62e8e16.z')
|
|
306
|
-
GC.start
|
|
307
|
-
wallet.id
|
|
308
|
-
wallet.txns.count
|
|
309
|
-
fake_log.debug("Memory: #{GetProcessMem.new.bytes.to_i}") if (i % 5).zero?
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
GC.stress = true
|
|
313
|
-
diff = GetProcessMem.new.bytes.to_i - start
|
|
314
|
-
GC.stress = false
|
|
315
|
-
fake_log.debug("Memory diff is #{diff}")
|
|
316
|
-
assert(diff < 20_000_000)
|
|
317
|
-
end
|
|
318
|
-
end
|
data/test/test_wallets.rb
DELETED
|
@@ -1,85 +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 'fake_home'
|
|
27
|
-
require_relative '../lib/zold/key'
|
|
28
|
-
require_relative '../lib/zold/id'
|
|
29
|
-
require_relative '../lib/zold/wallets'
|
|
30
|
-
require_relative '../lib/zold/amount'
|
|
31
|
-
|
|
32
|
-
# Wallets test.
|
|
33
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
34
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
35
|
-
# License:: MIT
|
|
36
|
-
class TestWallets < Zold::Test
|
|
37
|
-
def test_adds_wallet
|
|
38
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
39
|
-
wallets = home.wallets
|
|
40
|
-
id = Zold::Id.new
|
|
41
|
-
wallets.acq(id) do |wallet|
|
|
42
|
-
wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
|
43
|
-
assert_equal(1, wallets.all.count)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_lists_wallets_and_ignores_garbage
|
|
49
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
50
|
-
wallets = home.wallets
|
|
51
|
-
FileUtils.touch(File.join(home.dir, '0xaaaaaaaaaaaaaaaaaaahello'))
|
|
52
|
-
FileUtils.mkdir_p(File.join(home.dir, 'a/b/c'))
|
|
53
|
-
FileUtils.touch(File.join(home.dir, 'a/b/c/0000111122223333.z'))
|
|
54
|
-
id = Zold::Id.new
|
|
55
|
-
wallets.acq(id) do |wallet|
|
|
56
|
-
wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
|
57
|
-
assert_equal(1, wallets.all.count)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_substracts_dir_path_from_full_path
|
|
63
|
-
Dir.mktmpdir do |dir|
|
|
64
|
-
Dir.chdir(dir) do
|
|
65
|
-
wallets = Zold::Wallets.new(Dir.pwd)
|
|
66
|
-
assert_equal('.', wallets.to_s)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_count_wallets
|
|
72
|
-
Dir.mktmpdir do |dir|
|
|
73
|
-
Dir.chdir(dir) do
|
|
74
|
-
5.times { |i| FileUtils.touch("wallet_#{i}#{Zold::Wallet::EXT}") }
|
|
75
|
-
wallets = Zold::Wallets.new(Dir.pwd)
|
|
76
|
-
assert_equal(5, wallets.count)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
80
|
-
wallets = home.wallets
|
|
81
|
-
home.create_wallet
|
|
82
|
-
assert_equal(1, wallets.count)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
data/test/test_zold.rb
DELETED
|
@@ -1,99 +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 'open3'
|
|
26
|
-
require 'English'
|
|
27
|
-
require_relative 'test__helper'
|
|
28
|
-
require_relative '../lib/zold/version'
|
|
29
|
-
require_relative '../lib/zold/age'
|
|
30
|
-
|
|
31
|
-
# Zold main module test.
|
|
32
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
34
|
-
# License:: MIT
|
|
35
|
-
class TestZold < Zold::Test
|
|
36
|
-
Dir.new('fixtures/scripts').select { |f| f =~ /\.sh$/ && !f.start_with?('_') }.each do |f|
|
|
37
|
-
method = "test_#{f.gsub(/\.sh$/, '').gsub(/[^a-z]/, '_')}"
|
|
38
|
-
define_method(method) do
|
|
39
|
-
start = Time.now
|
|
40
|
-
fake_log.info("\n\n#{method} running (script at #{f})...")
|
|
41
|
-
Dir.mktmpdir do |dir|
|
|
42
|
-
FileUtils.cp('fixtures/id_rsa.pub', dir)
|
|
43
|
-
FileUtils.cp('fixtures/id_rsa', dir)
|
|
44
|
-
script = File.join(dir, f)
|
|
45
|
-
File.write(script, File.read('fixtures/scripts/_head.sh') + File.read(File.join('fixtures/scripts', f)))
|
|
46
|
-
bin = File.join(Dir.pwd, 'bin/zold')
|
|
47
|
-
out = []
|
|
48
|
-
Dir.chdir(dir) do
|
|
49
|
-
Open3.popen2e("/bin/bash #{f} #{bin} 2>&1") do |stdin, stdout, thr|
|
|
50
|
-
stdin.close
|
|
51
|
-
until stdout.eof?
|
|
52
|
-
line = stdout.gets
|
|
53
|
-
fake_log.info(line)
|
|
54
|
-
out << line
|
|
55
|
-
end
|
|
56
|
-
code = thr.value.to_i
|
|
57
|
-
assert_equal(0, code, "#{f}\n#{out.join}")
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
sleep 1 # It's a workaround, I can't fix the bug (tests crash sporadically)
|
|
61
|
-
end
|
|
62
|
-
fake_log.info("\n\n#{f} done in #{Zold::Age.new(start)}")
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def test_help
|
|
67
|
-
stdout = exec('--help')
|
|
68
|
-
assert(stdout.include?('Usage: zold'))
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_show_version
|
|
72
|
-
stdout = exec('--version')
|
|
73
|
-
assert(stdout.include?(Zold::VERSION))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def test_create_new_wallet
|
|
77
|
-
Dir.mktmpdir do |dir|
|
|
78
|
-
FileUtils.cp('fixtures/id_rsa.pub', dir)
|
|
79
|
-
FileUtils.cp('fixtures/id_rsa', dir)
|
|
80
|
-
stdout = exec(
|
|
81
|
-
'--verbose --trace create --public-key=id_rsa.pub',
|
|
82
|
-
dir
|
|
83
|
-
)
|
|
84
|
-
assert(stdout.include?('created at'))
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
def exec(tail, dir = Dir.pwd)
|
|
91
|
-
bin = File.expand_path(File.join(Dir.pwd, 'bin/zold'))
|
|
92
|
-
stdout = `cd #{dir} && #{bin} #{tail} 2>&1`
|
|
93
|
-
unless $CHILD_STATUS.exitstatus.zero?
|
|
94
|
-
puts stdout
|
|
95
|
-
assert_equal($CHILD_STATUS.exitstatus, 0)
|
|
96
|
-
end
|
|
97
|
-
stdout
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -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_relative '../test__helper'
|
|
25
|
-
require_relative '../../lib/zold/id'
|
|
26
|
-
require_relative '../../upgrades/delete_banned_wallets'
|
|
27
|
-
require_relative '../fake_home'
|
|
28
|
-
|
|
29
|
-
# Delete banned wallets.
|
|
30
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
31
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
32
|
-
# License:: MIT
|
|
33
|
-
class TestDeleteBannedWallets < Zold::Test
|
|
34
|
-
def test_delete_them
|
|
35
|
-
id = Zold::Id.new(Zold::Id::BANNED[0])
|
|
36
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
37
|
-
home.create_wallet(id)
|
|
38
|
-
FileUtils.mkdir_p(File.join(home.dir, 'a/b/c'))
|
|
39
|
-
File.rename(
|
|
40
|
-
File.join(home.dir, "#{id}#{Zold::Wallet::EXT}"),
|
|
41
|
-
File.join(home.dir, "a/b/c/#{id}#{Zold::Wallet::EXT}")
|
|
42
|
-
)
|
|
43
|
-
Zold::DeleteBannedWallets.new(home.dir, fake_log).exec
|
|
44
|
-
assert(File.exist?(File.join(home.dir, "a/b/c/#{id}#{Zold::Wallet::EXT}-banned")))
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,42 +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_relative '../test__helper'
|
|
25
|
-
require_relative '../../upgrades/protocol_up'
|
|
26
|
-
require_relative '../fake_home'
|
|
27
|
-
|
|
28
|
-
# Protocol up.
|
|
29
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
31
|
-
# License:: MIT
|
|
32
|
-
class TestProtocolUp < Zold::Test
|
|
33
|
-
def test_upgrades_protocol_in_wallet
|
|
34
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
35
|
-
id = home.create_wallet.id
|
|
36
|
-
Zold::ProtocolUp.new(home.dir, fake_log).exec
|
|
37
|
-
home.wallets.acq(id) do |wallet|
|
|
38
|
-
assert_equal(Zold::PROTOCOL, wallet.protocol)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|