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,72 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Copyright (c) 2018-2024 Zerocracy
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
# furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
# copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
# SOFTWARE.
|
|
21
|
-
|
|
22
|
-
function start_node {
|
|
23
|
-
port=$(reserve_port)
|
|
24
|
-
mkdir ${port}
|
|
25
|
-
cd ${port}
|
|
26
|
-
zold remote clean
|
|
27
|
-
zold node --trace --invoice=SPREADWALLETS@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
|
|
28
|
-
--host=127.0.0.1 --port=${port} --bind-port=${port} \
|
|
29
|
-
--threads=0 > log.txt 2>&1 &
|
|
30
|
-
pid=$!
|
|
31
|
-
echo ${pid} > pid
|
|
32
|
-
cd ..
|
|
33
|
-
wait_for_url http://localhost:${port}/
|
|
34
|
-
echo ${port}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
first=$(start_node)
|
|
38
|
-
second=$(start_node)
|
|
39
|
-
trap "halt_nodes ${first} ${second}" EXIT
|
|
40
|
-
|
|
41
|
-
zold --home=${first} remote add 127.0.0.1 ${second}
|
|
42
|
-
zold --home=${second} remote add 127.0.0.1 ${first}
|
|
43
|
-
|
|
44
|
-
zold --public-key=id_rsa.pub create 0000000000000000
|
|
45
|
-
zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4000000z 'To help you, dude!'
|
|
46
|
-
zold remote clean
|
|
47
|
-
zold remote add 127.0.0.1 ${first}
|
|
48
|
-
zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
|
|
49
|
-
zold remote clean
|
|
50
|
-
zold remote add 127.0.0.1 ${second}
|
|
51
|
-
|
|
52
|
-
i=0
|
|
53
|
-
until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
|
|
54
|
-
echo 'Failed to fetch, let us try again'
|
|
55
|
-
((i++)) || sleep 0
|
|
56
|
-
if ((i==5)); then
|
|
57
|
-
cat ${first}/log.txt
|
|
58
|
-
echo "The wallet has not been distributed, after ${i} attempts"
|
|
59
|
-
exit -1
|
|
60
|
-
fi
|
|
61
|
-
sleep 2
|
|
62
|
-
done
|
|
63
|
-
|
|
64
|
-
json=$(curl --silent --show-error http://127.0.0.1:${first})
|
|
65
|
-
if [ ! $(echo ${json} | jq -r '.entrance.queue') == "0" ]; then
|
|
66
|
-
echo "The queue is not empty after PUSH, it's a bug"
|
|
67
|
-
exit -1
|
|
68
|
-
fi
|
|
69
|
-
if [ ! $(echo ${json} | jq -r '.entrance.history_size') == "1" ]; then
|
|
70
|
-
echo "The history doesn't have a wallet, it's a bug"
|
|
71
|
-
exit -1
|
|
72
|
-
fi
|
data/lib/zold/log.rb
DELETED
|
@@ -1,139 +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 'logger'
|
|
24
|
-
require 'rainbow'
|
|
25
|
-
|
|
26
|
-
# Zold module.
|
|
27
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
28
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
29
|
-
# License:: MIT
|
|
30
|
-
module Zold
|
|
31
|
-
# Logging facilities.
|
|
32
|
-
#
|
|
33
|
-
# There are a few logging classes, which can be used depending on what
|
|
34
|
-
# you want a user to see. There are three logging levels: INFO, ERROR,
|
|
35
|
-
# and DEBUG. In "quiet" mode the user won't see anything. This logging
|
|
36
|
-
# mode is used only for testing, when we don't want to see absolutely
|
|
37
|
-
# anything in the console. In order to turn off logging entirely, see
|
|
38
|
-
# how we configure it in test__helper.rb
|
|
39
|
-
#
|
|
40
|
-
# The default "regular" logging mode is what a user gets when he/she runs
|
|
41
|
-
# the gem in commmand line without any specific flags. In that case,
|
|
42
|
-
# the user will see only INFO and ERROR messages.
|
|
43
|
-
#
|
|
44
|
-
# In a "verbose" mode the user will see everything, including DEBUG
|
|
45
|
-
# messages. The user turns this mode by using --verbose command line argument.
|
|
46
|
-
#
|
|
47
|
-
module Log
|
|
48
|
-
def self.colored(text, severity)
|
|
49
|
-
case severity
|
|
50
|
-
when 'ERROR', 'FATAL'
|
|
51
|
-
return Rainbow(text).red
|
|
52
|
-
when 'DEBUG'
|
|
53
|
-
return Rainbow(text).yellow
|
|
54
|
-
end
|
|
55
|
-
text
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Compact formatter
|
|
59
|
-
COMPACT = proc do |severity, _time, _target, msg|
|
|
60
|
-
prefix = ''
|
|
61
|
-
case severity
|
|
62
|
-
when 'ERROR', 'FATAL'
|
|
63
|
-
prefix = 'E: '
|
|
64
|
-
when 'DEBUG'
|
|
65
|
-
prefix = 'D: '
|
|
66
|
-
end
|
|
67
|
-
"#{colored(prefix, severity)}#{msg.to_s.rstrip.gsub("\n", "\n#{' ' * prefix.length}")}\n"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Short formatter
|
|
71
|
-
SHORT = proc do |_severity, _time, _target, msg|
|
|
72
|
-
"#{msg.to_s.rstrip}\n"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Full formatter
|
|
76
|
-
FULL = proc do |severity, time, _target, msg|
|
|
77
|
-
format(
|
|
78
|
-
"%<time>s %<severity>5s %<msg>s\n",
|
|
79
|
-
time: time.utc.iso8601,
|
|
80
|
-
severity: colored(severity, severity),
|
|
81
|
-
msg: msg.to_s.rstrip
|
|
82
|
-
)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# No logging at all
|
|
86
|
-
NULL = Logger.new($stdout)
|
|
87
|
-
NULL.level = Logger::UNKNOWN
|
|
88
|
-
NULL.freeze
|
|
89
|
-
|
|
90
|
-
# Everything, including debug
|
|
91
|
-
VERBOSE = Logger.new($stdout)
|
|
92
|
-
VERBOSE.level = Logger::DEBUG
|
|
93
|
-
VERBOSE.formatter = COMPACT
|
|
94
|
-
VERBOSE.freeze
|
|
95
|
-
|
|
96
|
-
# Info and errors, no debug info
|
|
97
|
-
REGULAR = Logger.new($stdout)
|
|
98
|
-
REGULAR.level = Logger::INFO
|
|
99
|
-
REGULAR.formatter = COMPACT
|
|
100
|
-
REGULAR.freeze
|
|
101
|
-
|
|
102
|
-
# Errors only
|
|
103
|
-
ERRORS = Logger.new($stdout)
|
|
104
|
-
ERRORS.level = Logger::ERROR
|
|
105
|
-
ERRORS.formatter = COMPACT
|
|
106
|
-
ERRORS.freeze
|
|
107
|
-
|
|
108
|
-
# Tee logger.
|
|
109
|
-
class Tee
|
|
110
|
-
def initialize(first, second)
|
|
111
|
-
@first = first
|
|
112
|
-
@second = second
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def debug(msg)
|
|
116
|
-
@first.debug(msg)
|
|
117
|
-
@second.debug(msg)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def debug?
|
|
121
|
-
@first.debug? || @second.debug?
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def info(msg)
|
|
125
|
-
@first.info(msg)
|
|
126
|
-
@second.info(msg)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def info?
|
|
130
|
-
@first.info? || @second.info?
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def error(msg)
|
|
134
|
-
@first.error(msg)
|
|
135
|
-
@second.error(msg)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
data/renovate.json
DELETED
|
@@ -1,41 +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/commands/routines/audit'
|
|
28
|
-
|
|
29
|
-
# Audit test.
|
|
30
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
31
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
32
|
-
# License:: MIT
|
|
33
|
-
class TestAudit < Zold::Test
|
|
34
|
-
def test_audits
|
|
35
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
36
|
-
opts = { 'routine-immediately' => true }
|
|
37
|
-
routine = Zold::Routines::Audit.new(opts, home.wallets, log: fake_log)
|
|
38
|
-
routine.exec
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,70 +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 '../../fake_home'
|
|
26
|
-
require_relative '../../../lib/zold/wallets'
|
|
27
|
-
require_relative '../../../lib/zold/commands/routines/gc'
|
|
28
|
-
|
|
29
|
-
# Gc test.
|
|
30
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
31
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
32
|
-
# License:: MIT
|
|
33
|
-
class TestGc < Zold::Test
|
|
34
|
-
def test_collects_garbage
|
|
35
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
36
|
-
wallets = home.wallets
|
|
37
|
-
home.create_wallet
|
|
38
|
-
opts = { 'routine-immediately' => true, 'gc-age' => 0 }
|
|
39
|
-
assert_equal(1, wallets.count)
|
|
40
|
-
routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
|
|
41
|
-
routine.exec
|
|
42
|
-
assert_equal(0, wallets.count)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_doesnt_touch_non_empty_wallets
|
|
47
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
48
|
-
wallets = home.wallets
|
|
49
|
-
wallet = home.create_wallet
|
|
50
|
-
amount = Zold::Amount.new(zld: 39.99)
|
|
51
|
-
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
|
52
|
-
wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
|
|
53
|
-
opts = { 'routine-immediately' => true, 'gc-age' => 0 }
|
|
54
|
-
routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
|
|
55
|
-
routine.exec
|
|
56
|
-
assert_equal(1, wallets.count)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_doesnt_touch_fresh_wallets
|
|
61
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
62
|
-
wallets = home.wallets
|
|
63
|
-
home.create_wallet
|
|
64
|
-
opts = { 'routine-immediately' => true, 'gc-age' => 60 * 60 }
|
|
65
|
-
routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
|
|
66
|
-
routine.exec
|
|
67
|
-
assert_equal(1, wallets.count)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,51 +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 'webmock/minitest'
|
|
25
|
-
require_relative '../../test__helper'
|
|
26
|
-
require_relative '../../fake_home'
|
|
27
|
-
require_relative '../../../lib/zold/remotes'
|
|
28
|
-
require_relative '../../../lib/zold/commands/routines/reconcile'
|
|
29
|
-
|
|
30
|
-
# Reconcile test.
|
|
31
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
33
|
-
# License:: MIT
|
|
34
|
-
class TestReconcile < Zold::Test
|
|
35
|
-
def test_reconciles
|
|
36
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
37
|
-
remotes = home.remotes
|
|
38
|
-
remotes.clean
|
|
39
|
-
remotes.masters
|
|
40
|
-
m = remotes.all[0]
|
|
41
|
-
remotes.all.each_with_index { |r, idx| remotes.remove(r[:host], r[:port]) if idx.positive? }
|
|
42
|
-
stub_request(:get, "http://#{m[:host]}:#{m[:port]}/wallets").to_return(status: 200, body: Zold::Id::ROOT.to_s)
|
|
43
|
-
stub_request(:get, "http://#{m[:host]}:#{m[:port]}/wallet/#{Zold::Id::ROOT}").to_return(status: 404)
|
|
44
|
-
opts = { 'never-reboot' => true, 'routine-immediately' => true }
|
|
45
|
-
routine = Zold::Routines::Reconcile.new(
|
|
46
|
-
opts, home.wallets, remotes, home.copies.root, 'some-fake-host:2096', log: fake_log
|
|
47
|
-
)
|
|
48
|
-
routine.exec
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,46 +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/remotes'
|
|
28
|
-
require_relative '../../../lib/zold/commands/routines/reconnect'
|
|
29
|
-
|
|
30
|
-
# Reconnect test.
|
|
31
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
33
|
-
# License:: MIT
|
|
34
|
-
class TestReconnect < Zold::Test
|
|
35
|
-
def test_reconnects
|
|
36
|
-
Dir.mktmpdir do |dir|
|
|
37
|
-
remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.csv'))
|
|
38
|
-
remotes.clean
|
|
39
|
-
remotes.add('localhost', 4096)
|
|
40
|
-
stub_request(:get, 'http://localhost:4096/remotes').to_return(status: 404)
|
|
41
|
-
opts = { 'never-reboot' => true, 'routine-immediately' => true }
|
|
42
|
-
routine = Zold::Routines::Reconnect.new(opts, remotes, log: fake_log)
|
|
43
|
-
routine.exec
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,40 +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/remotes'
|
|
28
|
-
require_relative '../../../lib/zold/commands/routines/retire'
|
|
29
|
-
|
|
30
|
-
# Retire test.
|
|
31
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
33
|
-
# License:: MIT
|
|
34
|
-
class TestRetire < Zold::Test
|
|
35
|
-
def test_retires
|
|
36
|
-
opts = { 'never-reboot' => false, 'routine-immediately' => true }
|
|
37
|
-
routine = Zold::Routines::Retire.new(opts, log: fake_log)
|
|
38
|
-
routine.exec(10 * 24 * 60)
|
|
39
|
-
end
|
|
40
|
-
end
|
data/test/commands/test_alias.rb
DELETED
|
@@ -1,76 +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 '../fake_home'
|
|
26
|
-
require_relative '../../lib/zold/commands/alias'
|
|
27
|
-
|
|
28
|
-
class TestAlias < Zold::Test
|
|
29
|
-
# alias set <wallet> <alias>
|
|
30
|
-
# @todo #322:30min Implement the set command and unskip this test.
|
|
31
|
-
# The syntax is already documented in the alias command in the help.
|
|
32
|
-
def test_set_writes_alias_to_the_alias_file
|
|
33
|
-
skip
|
|
34
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
35
|
-
wallet = home.create_wallet
|
|
36
|
-
Zold::Alias.new(wallets: home.wallets, log: fake_log).run(%W[set #{wallet.id} my-alias])
|
|
37
|
-
assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# alias remove <alias>
|
|
42
|
-
# @todo #322:30min Implement the remove command and unskip this test.
|
|
43
|
-
# The syntax is already documented in the alias command in the help.
|
|
44
|
-
def test_remove_removes_the_alias_from_the_alias_file
|
|
45
|
-
skip
|
|
46
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
47
|
-
wallet = home.create_wallet
|
|
48
|
-
cmd = Zold::Alias.new(wallets: home.wallets, log: fake_log)
|
|
49
|
-
cmd.run(%W[set #{wallet.id} my-alias])
|
|
50
|
-
assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
|
|
51
|
-
cmd.run(%w[remove my-alias])
|
|
52
|
-
assert_empty read_alias_file(home)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# alias show <alias>
|
|
57
|
-
# @todo #322:30min Implement the show command and unskip this test.
|
|
58
|
-
# The syntax is already documented in the alias command in the help.
|
|
59
|
-
def test_show_prints_out_the_aliased_wallet_id
|
|
60
|
-
skip
|
|
61
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
62
|
-
wallet = home.create_wallet
|
|
63
|
-
cmd = Zold::Alias.new(wallets: home.wallets, log: fake_log)
|
|
64
|
-
cmd.run(%W[set #{wallet.id} my-alias])
|
|
65
|
-
assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
|
|
66
|
-
stdout, = capture_io { cmd.run(%w[show my-alias]) }
|
|
67
|
-
assert_match wallet.id.to_s, stdout
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
private
|
|
72
|
-
|
|
73
|
-
def read_alias_file(home)
|
|
74
|
-
File.read(File.join(home.dir, 'aliases')).split
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,40 +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/log'
|
|
26
|
-
require_relative '../../lib/zold/commands/calculate'
|
|
27
|
-
|
|
28
|
-
# SCORE test.
|
|
29
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
31
|
-
# License:: MIT
|
|
32
|
-
class TestCalculate < Zold::Test
|
|
33
|
-
def test_calculates_score
|
|
34
|
-
score = Zold::Calculate.new(log: fake_log).run(
|
|
35
|
-
['score', '--strength=2', '--max=8', '--invoice=NOSUFFIX@ffffffffffffffff']
|
|
36
|
-
)
|
|
37
|
-
assert(score.valid?)
|
|
38
|
-
assert_equal(8, score.value)
|
|
39
|
-
end
|
|
40
|
-
end
|
data/test/commands/test_clean.rb
DELETED
|
@@ -1,73 +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 'time'
|
|
25
|
-
require 'threads'
|
|
26
|
-
require_relative '../fake_home'
|
|
27
|
-
require_relative '../test__helper'
|
|
28
|
-
require_relative '../../lib/zold/copies'
|
|
29
|
-
require_relative '../../lib/zold/commands/clean'
|
|
30
|
-
|
|
31
|
-
# CLEAN test.
|
|
32
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2018-2024 Zerocracy
|
|
34
|
-
# License:: MIT
|
|
35
|
-
class TestClean < Zold::Test
|
|
36
|
-
def test_cleans_copies
|
|
37
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
38
|
-
wallet = home.create_wallet
|
|
39
|
-
copies = home.copies(wallet)
|
|
40
|
-
copies.add('a1', 'host-1', 80, 1, time: Time.now - (26 * 60 * 60))
|
|
41
|
-
copies.add('a2', 'host-2', 80, 2, time: Time.now - (26 * 60 * 60))
|
|
42
|
-
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: fake_log).run(['clean', wallet.id.to_s])
|
|
43
|
-
assert(copies.all.empty?)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_clean_no_copies
|
|
48
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
49
|
-
wallet = home.create_wallet
|
|
50
|
-
copies = home.copies(wallet)
|
|
51
|
-
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: fake_log).run(['clean'])
|
|
52
|
-
assert(copies.all.empty?)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_cleans_empty_wallets
|
|
57
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
58
|
-
Zold::Clean.new(wallets: home.wallets, copies: File.join(home.dir, 'c'), log: fake_log).run(['clean'])
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_cleans_copies_in_threads
|
|
63
|
-
FakeHome.new(log: fake_log).run do |home|
|
|
64
|
-
wallet = home.create_wallet
|
|
65
|
-
copies = home.copies(wallet)
|
|
66
|
-
copies.add(File.read(wallet.path), 'host-2', 80, 2, time: Time.now)
|
|
67
|
-
Threads.new(20).assert do
|
|
68
|
-
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: fake_log).run(['clean'])
|
|
69
|
-
end
|
|
70
|
-
assert_equal(1, copies.all.count)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|