zold 0.32.0 → 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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/zold/version.rb +1 -1
  4. data/zold.gemspec +1 -1
  5. metadata +2 -168
  6. data/.0pdd.yml +0 -12
  7. data/.gitattributes +0 -9
  8. data/.github/typos.toml +0 -11
  9. data/.github/workflows/actionlint.yml +0 -25
  10. data/.github/workflows/bashate.yml +0 -25
  11. data/.github/workflows/codecov.yml +0 -27
  12. data/.github/workflows/copyrights.yml +0 -15
  13. data/.github/workflows/hadolint.yml +0 -14
  14. data/.github/workflows/markdown-lint.yml +0 -19
  15. data/.github/workflows/pdd.yml +0 -19
  16. data/.github/workflows/rake.yml +0 -31
  17. data/.github/workflows/reuse.yml +0 -19
  18. data/.github/workflows/shellcheck.yml +0 -19
  19. data/.github/workflows/typos.yml +0 -21
  20. data/.github/workflows/xcop.yml +0 -15
  21. data/.github/workflows/yamllint.yml +0 -19
  22. data/.gitignore +0 -15
  23. data/.pdd +0 -7
  24. data/.rubocop.yml +0 -66
  25. data/.ruby-version +0 -1
  26. data/.rultor.yml +0 -41
  27. data/cucumber.yml +0 -6
  28. data/features/cli.feature +0 -18
  29. data/features/gem_package.feature +0 -28
  30. data/features/step_definitions/steps.rb +0 -67
  31. data/features/support/env.rb +0 -9
  32. data/fixtures/448b451bc62e8e16.z +0 -1005
  33. data/fixtures/id_rsa +0 -51
  34. data/fixtures/id_rsa-2 +0 -51
  35. data/fixtures/id_rsa-2.pub +0 -1
  36. data/fixtures/id_rsa.pub +0 -1
  37. data/fixtures/keys/1.pub +0 -1
  38. data/fixtures/keys/2 +0 -51
  39. data/fixtures/keys/2.pub +0 -1
  40. data/fixtures/merge/asserts.rb +0 -20
  41. data/fixtures/merge/id_rsa +0 -51
  42. data/fixtures/merge/id_rsa.pub +0 -1
  43. data/fixtures/merge/into_no_wallet/assert.rb +0 -8
  44. data/fixtures/merge/into_no_wallet/copies/0123456789abcdef/1.zc +0 -6
  45. data/fixtures/merge/into_no_wallet/copies/0123456789abcdef/scores.zc +0 -1
  46. data/fixtures/merge/into_no_wallet/opts +0 -1
  47. data/fixtures/merge/legacy_negatives_stay/0123456789abcdef.z +0 -6
  48. data/fixtures/merge/legacy_negatives_stay/assert.rb +0 -8
  49. data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/1.zc +0 -6
  50. data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +0 -1
  51. data/fixtures/merge/legacy_negatives_stay/opts +0 -2
  52. data/fixtures/merge/missed_wallets/0000000000000000.z +0 -6
  53. data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -4
  54. data/fixtures/merge/missed_wallets/assert.rb +0 -8
  55. data/fixtures/merge/missed_wallets/copies/0123456789abcdef/1.zc +0 -8
  56. data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +0 -1
  57. data/fixtures/merge/missed_wallets/opts +0 -3
  58. data/fixtures/merge/negative_overwriting/0123456789abcdef.z +0 -6
  59. data/fixtures/merge/negative_overwriting/146b852f2d9ad984.z +0 -6
  60. data/fixtures/merge/negative_overwriting/assert.rb +0 -8
  61. data/fixtures/merge/negative_overwriting/copies/0123456789abcdef/1.zc +0 -6
  62. data/fixtures/merge/negative_overwriting/copies/0123456789abcdef/scores.zc +0 -1
  63. data/fixtures/merge/negative_overwriting/opts +0 -2
  64. data/fixtures/merge/negatives_in_between/0000000000000000.z +0 -6
  65. data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -4
  66. data/fixtures/merge/negatives_in_between/assert.rb +0 -8
  67. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/1.zc +0 -6
  68. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -6
  69. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/3.zc +0 -6
  70. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/scores.zc +0 -3
  71. data/fixtures/merge/negatives_in_between/opts +0 -1
  72. data/fixtures/merge/random_expenses/0000000000000000.z +0 -6
  73. data/fixtures/merge/random_expenses/0123456789abcdef.z +0 -6
  74. data/fixtures/merge/random_expenses/assert.rb +0 -8
  75. data/fixtures/merge/random_expenses/copies/0123456789abcdef/1.zc +0 -7
  76. data/fixtures/merge/random_expenses/copies/0123456789abcdef/2.zc +0 -7
  77. data/fixtures/merge/random_expenses/copies/0123456789abcdef/3.zc +0 -7
  78. data/fixtures/merge/random_expenses/copies/0123456789abcdef/4.zc +0 -7
  79. data/fixtures/merge/random_expenses/copies/0123456789abcdef/5.zc +0 -7
  80. data/fixtures/merge/random_expenses/copies/0123456789abcdef/scores.zc +0 -5
  81. data/fixtures/merge/random_expenses/opts +0 -1
  82. data/fixtures/merge/simple_case/0000000000000000.z +0 -6
  83. data/fixtures/merge/simple_case/0123456789abcdef.z +0 -4
  84. data/fixtures/merge/simple_case/assert.rb +0 -8
  85. data/fixtures/merge/simple_case/copies/0123456789abcdef/1.zc +0 -6
  86. data/fixtures/merge/simple_case/copies/0123456789abcdef/scores.zc +0 -1
  87. data/fixtures/merge/simple_case/opts +0 -1
  88. data/fixtures/merge/unconfirmed_income/0123456789abcdef.z +0 -4
  89. data/fixtures/merge/unconfirmed_income/assert.rb +0 -8
  90. data/fixtures/merge/unconfirmed_income/copies/0123456789abcdef/1.zc +0 -6
  91. data/fixtures/merge/unconfirmed_income/copies/0123456789abcdef/scores.zc +0 -1
  92. data/fixtures/merge/unconfirmed_income/opts +0 -3
  93. data/fixtures/scripts/_head.sh +0 -72
  94. data/fixtures/scripts/calculate-scores.sh +0 -5
  95. data/fixtures/scripts/distribute-wallet.sh +0 -88
  96. data/fixtures/scripts/print-helps.sh +0 -9
  97. data/fixtures/scripts/pull-on-start.sh +0 -35
  98. data/fixtures/scripts/push-and-pull.sh +0 -46
  99. data/fixtures/scripts/redeploy-on-upgrade.sh +0 -40
  100. data/fixtures/scripts/spread-wallets.sh +0 -56
  101. data/renovate.json +0 -6
  102. data/test/commands/routines/test_audit.rb +0 -23
  103. data/test/commands/routines/test_gc.rb +0 -52
  104. data/test/commands/routines/test_reconcile.rb +0 -33
  105. data/test/commands/routines/test_reconnect.rb +0 -28
  106. data/test/commands/routines/test_retire.rb +0 -22
  107. data/test/commands/test_alias.rb +0 -58
  108. data/test/commands/test_calculate.rb +0 -22
  109. data/test/commands/test_clean.rb +0 -55
  110. data/test/commands/test_create.rb +0 -32
  111. data/test/commands/test_diff.rb +0 -43
  112. data/test/commands/test_fetch.rb +0 -144
  113. data/test/commands/test_invoice.rb +0 -32
  114. data/test/commands/test_list.rb +0 -29
  115. data/test/commands/test_merge.rb +0 -106
  116. data/test/commands/test_node.rb +0 -50
  117. data/test/commands/test_pay.rb +0 -203
  118. data/test/commands/test_propagate.rb +0 -33
  119. data/test/commands/test_pull.rb +0 -52
  120. data/test/commands/test_push.rb +0 -75
  121. data/test/commands/test_remote.rb +0 -247
  122. data/test/commands/test_remove.rb +0 -48
  123. data/test/commands/test_show.rb +0 -30
  124. data/test/commands/test_taxes.rb +0 -58
  125. data/test/fake_home.rb +0 -87
  126. data/test/node/fake_entrance.rb +0 -26
  127. data/test/node/fake_node.rb +0 -88
  128. data/test/node/test_async_entrance.rb +0 -85
  129. data/test/node/test_entrance.rb +0 -64
  130. data/test/node/test_farm.rb +0 -159
  131. data/test/node/test_farmers.rb +0 -58
  132. data/test/node/test_front.rb +0 -379
  133. data/test/node/test_nodup_entrance.rb +0 -31
  134. data/test/node/test_nospam_entrance.rb +0 -31
  135. data/test/node/test_safe_entrance.rb +0 -41
  136. data/test/node/test_spread_entrance.rb +0 -49
  137. data/test/node/test_sync_entrance.rb +0 -23
  138. data/test/node/test_trace.rb +0 -18
  139. data/test/test__helper.rb +0 -113
  140. data/test/test_age.rb +0 -37
  141. data/test/test_amount.rb +0 -62
  142. data/test/test_cached_wallets.rb +0 -55
  143. data/test/test_copies.rb +0 -127
  144. data/test/test_dir_items.rb +0 -72
  145. data/test/test_gem.rb +0 -23
  146. data/test/test_hands.rb +0 -51
  147. data/test/test_hexnum.rb +0 -18
  148. data/test/test_http.rb +0 -207
  149. data/test/test_hungry_wallets.rb +0 -72
  150. data/test/test_id.rb +0 -61
  151. data/test/test_json_page.rb +0 -29
  152. data/test/test_key.rb +0 -81
  153. data/test/test_metronome.rb +0 -71
  154. data/test/test_patch.rb +0 -160
  155. data/test/test_prefixes.rb +0 -31
  156. data/test/test_remotes.rb +0 -301
  157. data/test/test_signature.rb +0 -31
  158. data/test/test_size.rb +0 -21
  159. data/test/test_sync_wallets.rb +0 -39
  160. data/test/test_tax.rb +0 -153
  161. data/test/test_thread_pool.rb +0 -71
  162. data/test/test_tree_wallets.rb +0 -65
  163. data/test/test_txn.rb +0 -71
  164. data/test/test_upgrades.rb +0 -81
  165. data/test/test_verbose_thread.rb +0 -37
  166. data/test/test_version.rb +0 -17
  167. data/test/test_wallet.rb +0 -300
  168. data/test/test_wallets.rb +0 -67
  169. data/test/test_zold.rb +0 -81
  170. data/test/upgrades/test_delete_banned_wallets.rb +0 -29
  171. data/test/upgrades/test_protocol_up.rb +0 -24
@@ -1,6 +0,0 @@
1
- test
2
- 1
3
- 0123456789abcdef
4
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnppnkzrCreiKaHF09XKS6bO+2274+wSGo+F8KHvVrNbqear/e09r9PB/P6bFdLoMh4Xc7p/7+NSEZLeu2Eg/dBkQLEb8M/zgkT4gBDGyETW/zusYHIznX/lgf0f8qleIQIIB/3Y7QpDztkamWYTKWlnmlrcQvCVB0uRRPm4ZMcMJouKR9n7E2DpL9eolKyOwr/JY08iJOuK3HuW6tRdvE+0x7I+wDprM65OH/PoArlfO5qnIGbeXwsEGRXt0w6a/ubPpeadFjPXotE7cT1SA4YSD1tWTIVm1ZWppOE967XoDIum6tzt5KfzDNRfs9GbCfO0BL235HxbO8I9rTlVLTKcNAiEe0CWolY9HR5pMaosOgZ6PB54InJEZJs4L2b10c+IlVUX1RSnwfFYg0vy5oqrYyqt7gnipl/06YW4PKIYc7TljogsEHf9Cz/kpEKzqDtsH2LrmjMNsbWiousvNHM+MPgcuMg8ZnwLKwDy9NWdI4XLTpg6hVRJNH9erZdfAO5tg/3ub3JLeJbyNo4Bd5f/Bnr5YN/9ahZ87kSpI7v0Qk94dR4hDPjstEcghyZ9RVUoN52+h1g83cd3cIqksJd0kifMCoBmObD013RSPQqNwr9GGU2JaJEm25Vq35dy2DHAkOQpUZVT8GNg9IM4qUDV0yagTN3bZyvuLWIgufb0CAwEAAQ==
5
-
6
- 0001;2018-06-22T07:38:23Z;0000020000000000;g6hVRJNH;0000000000000000;To help you;
@@ -1 +0,0 @@
1
- 1,0.0.0.0,4096,50,NOW,M
@@ -1 +0,0 @@
1
- --verbose
@@ -1,4 +0,0 @@
1
- test
2
- 1
3
- 0123456789abcdef
4
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnppnkzrCreiKaHF09XKS6bO+2274+wSGo+F8KHvVrNbqear/e09r9PB/P6bFdLoMh4Xc7p/7+NSEZLeu2Eg/dBkQLEb8M/zgkT4gBDGyETW/zusYHIznX/lgf0f8qleIQIIB/3Y7QpDztkamWYTKWlnmlrcQvCVB0uRRPm4ZMcMJouKR9n7E2DpL9eolKyOwr/JY08iJOuK3HuW6tRdvE+0x7I+wDprM65OH/PoArlfO5qnIGbeXwsEGRXt0w6a/ubPpeadFjPXotE7cT1SA4YSD1tWTIVm1ZWppOE967XoDIum6tzt5KfzDNRfs9GbCfO0BL235HxbO8I9rTlVLTKcNAiEe0CWolY9HR5pMaosOgZ6PB54InJEZJs4L2b10c+IlVUX1RSnwfFYg0vy5oqrYyqt7gnipl/06YW4PKIYc7TljogsEHf9Cz/kpEKzqDtsH2LrmjMNsbWiousvNHM+MPgcuMg8ZnwLKwDy9NWdI4XLTpg6hVRJNH9erZdfAO5tg/3ub3JLeJbyNo4Bd5f/Bnr5YN/9ahZ87kSpI7v0Qk94dR4hDPjstEcghyZ9RVUoN52+h1g83cd3cIqksJd0kifMCoBmObD013RSPQqNwr9GGU2JaJEm25Vq35dy2DHAkOQpUZVT8GNg9IM4qUDV0yagTN3bZyvuLWIgufb0CAwEAAQ==
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative 'asserts'
7
- wallet = Zold::Wallet.new('0123456789abcdef.z')
8
- assert_equal(Zold::Amount::ZERO, wallet.balance)
@@ -1,6 +0,0 @@
1
- test
2
- 1
3
- 0123456789abcdef
4
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnppnkzrCreiKaHF09XKS6bO+2274+wSGo+F8KHvVrNbqear/e09r9PB/P6bFdLoMh4Xc7p/7+NSEZLeu2Eg/dBkQLEb8M/zgkT4gBDGyETW/zusYHIznX/lgf0f8qleIQIIB/3Y7QpDztkamWYTKWlnmlrcQvCVB0uRRPm4ZMcMJouKR9n7E2DpL9eolKyOwr/JY08iJOuK3HuW6tRdvE+0x7I+wDprM65OH/PoArlfO5qnIGbeXwsEGRXt0w6a/ubPpeadFjPXotE7cT1SA4YSD1tWTIVm1ZWppOE967XoDIum6tzt5KfzDNRfs9GbCfO0BL235HxbO8I9rTlVLTKcNAiEe0CWolY9HR5pMaosOgZ6PB54InJEZJs4L2b10c+IlVUX1RSnwfFYg0vy5oqrYyqt7gnipl/06YW4PKIYc7TljogsEHf9Cz/kpEKzqDtsH2LrmjMNsbWiousvNHM+MPgcuMg8ZnwLKwDy9NWdI4XLTpg6hVRJNH9erZdfAO5tg/3ub3JLeJbyNo4Bd5f/Bnr5YN/9ahZ87kSpI7v0Qk94dR4hDPjstEcghyZ9RVUoN52+h1g83cd3cIqksJd0kifMCoBmObD013RSPQqNwr9GGU2JaJEm25Vq35dy2DHAkOQpUZVT8GNg9IM4qUDV0yagTN3bZyvuLWIgufb0CAwEAAQ==
5
-
6
- 0001;2018-06-22T07:38:23Z;0000020000000000;g6hVRJNH;0000000000000000;To help you;
@@ -1 +0,0 @@
1
- 1,0.0.0.0,4096,50,NOW,M
@@ -1,3 +0,0 @@
1
- --verbose
2
- --depth=2
3
- --no-baseline
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- set -e
6
- set -x
7
- shopt -s expand_aliases
8
-
9
- export RUBYOPT="-W0"
10
-
11
- # shellcheck disable=SC2139
12
- alias zold="$1 --ignore-this-stupid-option --halt-code=test --ignore-global-config --trace --network=test --no-colors --dump-errors"
13
-
14
- function reserve_port {
15
- python -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1]); s.close()'
16
- }
17
-
18
- function wait_for_url {
19
- i=0
20
- while ! curl --silent --fail "$1" > /dev/null; do
21
- i=$((i + 1))
22
- if [ "${i}" -eq 30 ]; then
23
- echo "URL $1 is not available after ${i} attempts"
24
- exit 12
25
- fi
26
- sleep 2
27
- done
28
- }
29
-
30
- function wait_for_port {
31
- i=0
32
- while ! nc -z localhost "$1"; do
33
- i=$((i + 1))
34
- if [ "${i}" -eq 30 ]; then
35
- echo "Port $1 is not available after ${i} attempts"
36
- exit 13
37
- fi
38
- sleep 2
39
- done
40
- }
41
-
42
- function wait_for_file {
43
- i=0
44
- while [ ! -f "$1" ]; do
45
- i=$((i + 1))
46
- if [ "${i}" -eq 30 ]; then
47
- echo "File $1 not found, giving up after ${i} attempts"
48
- exit 14
49
- fi
50
- sleep 2
51
- done
52
- }
53
-
54
- function halt_nodes {
55
- for p in "$@"; do
56
- pid=$(curl --silent "http://127.0.0.1:$p/pid?halt=test" || echo 'absent')
57
- if [[ "${pid}" =~ ^[0-9]+$ ]]; then
58
- i=0
59
- while kill -0 "${pid}"; do
60
- i=$((i + 1))
61
- if [ "${i}" -eq 30 ]; then
62
- echo "Process ${pid} didn't die, it's a bug"
63
- exit 15
64
- fi
65
- echo "Still waiting for process ${pid} to die, attempt no.${i}"
66
- sleep 2
67
- done
68
- echo "Process ${pid} is dead!"
69
- fi
70
- echo "Node at TCP port ${p} stopped!"
71
- done
72
- }
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- zold score --host=zold.io --port=4096 --invoice=CALCSCORE@ffffffffffffffff --strength=2 --max=5
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- function start_node {
6
- port=$(reserve_port)
7
- mkdir "${port}"
8
- cd "${port}" || exit
9
- zold node --trace --invoice=DISTRWALLET@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
10
- --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
11
- --threads=0 --routine-immediately --never-reboot > log.txt 2>&1 &
12
- pid=$!
13
- echo "${pid}" > pid
14
- cd ..
15
- wait_for_url "http://127.0.0.1:${port}/"
16
- echo "${port}"
17
- }
18
-
19
- # We start two nodes and kill them both at the end of the script. If we
20
- # don't do the TRAP for killing, the test will never end.
21
- first=$(start_node)
22
- second=$(start_node)
23
- # shellcheck disable=SC2064
24
- trap "halt_nodes ${first} ${second}" EXIT
25
-
26
- # The first node is linked to the second one and the second one
27
- # is linked to the first one. The --home argument specifies their
28
- # locations.
29
- zold --home="${first}" remote clean
30
- zold --home="${first}" remote add 127.0.0.1 "${second}"
31
- zold --home="${second}" remote clean
32
- zold --home="${second}" remote add 127.0.0.1 "${first}"
33
-
34
- # Locally we create a new root wallet (to avoid negative balance checking)
35
- # and connect our local Zold home to the first remote node. Then, we push
36
- # the wallet to the remote, expecting it to distribute it to the second
37
- # wallet automatically.
38
- zold --public-key=id_rsa.pub create 0000000000000000
39
- zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4.95 'For the book'
40
- zold remote clean
41
- zold remote add 127.0.0.1 "${first}"
42
- zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
43
- zold remote clean
44
- zold remote add 127.0.0.1 "${second}"
45
-
46
- # Here we fetch the wallet from the second remote node. The wallet has
47
- # to be visible there. We are doing a number of attempts with a small
48
- # delay between them, in order to give the first node a chance to distribute
49
- # the wallet.
50
- i=0
51
- until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
52
- echo 'Failed to fetch, let us try again'
53
- i=$((i + 1))
54
- if [ "${i}" -eq 5 ]; then
55
- cat "${first}/log.txt"
56
- echo "The wallet has not been distributed, after ${i} attempts"
57
- exit 9
58
- fi
59
- sleep 2
60
- done
61
-
62
- # Here we check the JSON of the first node to make sure all status
63
- # indicators are clean.
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 5
68
- fi
69
- if [ "$(echo "${json}" | jq -r '.entrance.history_size')" == "0" ]; then
70
- echo "The history doesn't have a wallet, it's a bug"
71
- exit 6
72
- fi
73
-
74
- # Now, we remove the wallet from the second node and expect the first
75
- # one to "spread" it again, almost immediately. The second node should
76
- # have the wallet very soon.
77
- rm -f "${second}"/**/*.z
78
- i=0
79
- until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
80
- echo 'Failed to fetch, let us try again'
81
- i=$((i + 1))
82
- if [ "${i}" -eq 5 ]; then
83
- echo "The wallet 0000000000000000 has not been spread, after ${i} attempts, here is the log:"
84
- cat "${first}/log.txt"
85
- exit 8
86
- fi
87
- sleep 2
88
- done
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- zold --help
6
- declare -a commands=(node create invoice remote pay show fetch clean diff merge propagate pull push taxes)
7
- for c in "${commands[@]}"; do
8
- zold --ignore-global-config --trace "$c" --help
9
- done
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- port=$(reserve_port)
6
- mkdir server
7
- cd server || exit
8
- zold remote clean
9
- zold node --trace --invoice=PULLONSTART@ffffffffffffffff --no-metronome --tolerate-edges --tolerate-quorum=1 \
10
- --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
11
- --threads=0 --standalone --pretty=full 2>&1 &
12
- cd ..
13
-
14
- wait_for_port "${port}"
15
-
16
- zold remote clean
17
- zold remote add 127.0.0.1 "${port}"
18
-
19
- zold --public-key=id_rsa.pub create abcdabcdabcdabcd
20
- zold push abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
21
- zold remove abcdabcdabcdabcd
22
- zold invoice abcdabcdabcdabcd --tolerate-edges --tolerate-quorum=1
23
-
24
- second_port=$(reserve_port)
25
- mkdir second
26
- cd second || exit
27
- zold remote clean
28
- zold remote add 127.0.0.1 "${port}"
29
- zold node --trace --invoice=abcdabcdabcdabcd --no-metronome --tolerate-edges --tolerate-quorum=1 \
30
- --host=127.0.0.1 --port="${second_port}" --bind-port="${second_port}" \
31
- --threads=0 &
32
-
33
- wait_for_port "${second_port}"
34
-
35
- halt_nodes "${second_port}" "${port}"
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- port=$(reserve_port)
6
-
7
- mkdir server
8
- cd server || exit
9
- zold node --trace --invoice=PUSHNPULL@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
10
- --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
11
- --threads=0 --standalone 2>&1 &
12
- # shellcheck disable=SC2064
13
- trap "halt_nodes ${port}" EXIT
14
- cd ..
15
-
16
- wait_for_port "${port}"
17
-
18
- zold remote clean
19
- zold remote add 127.0.0.1 "${port}"
20
- zold remote trim
21
- zold remote show
22
-
23
- zold --public-key=id_rsa.pub create 0000000000000000
24
- target=$(zold create --public-key=id_rsa.pub)
25
- invoice=$(zold invoice "${target}")
26
- zold pay --private-key=id_rsa 0000000000000000 "${invoice}" 14.99Z 'To save the world!'
27
- zold propagate
28
- zold propagate 0000000000000000
29
- zold show
30
- zold show 0000000000000000
31
- zold taxes debt 0000000000000000
32
-
33
- zold remote show
34
- zold push --tolerate-edges --tolerate-quorum=1
35
- zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
36
- until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
37
- echo 'Failed to fetch, let us try again'
38
- sleep 1
39
- done
40
- zold fetch --tolerate-edges --tolerate-quorum=1
41
- zold diff 0000000000000000
42
- zold merge
43
- zold merge 0000000000000000
44
- zold clean
45
- zold clean 0000000000000000
46
- zold remove
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- function start_node {
6
- mkdir "$1"
7
- cd "$1" || exit
8
- zold remote clean
9
- zold node ${3:+"$3"} --nohup --nohup-command='touch restarted' --nohup-log=log --nohup-max-cycles=0 --nohup-log-truncate=10240 \
10
- --expose-version="$2" --save-pid=pid --routine-immediately --tolerate-edges --tolerate-quorum=1 \
11
- --verbose --trace --invoice=REDEPLOY@ffffffffffffffff --ignore-empty-remotes \
12
- --host=127.0.0.1 --port="$1" --bind-port="$1" --threads=1 --strength=20 > /dev/null 2>&1
13
- wait_for_port "$1"
14
- cat pid
15
- cd ..
16
- }
17
-
18
- high=$(reserve_port)
19
- start_node "${high}" 9.9.9 --standalone
20
-
21
- low=$(reserve_port)
22
- start_node "${low}" 1.1.1
23
-
24
- zold remote clean
25
- zold remote add 127.0.0.1 "${high}" --home="${low}" --skip-ping
26
-
27
- # shellcheck disable=SC2064
28
- trap "halt_nodes ${high}" EXIT
29
-
30
- wait_for_file "${low}/restarted"
31
-
32
- if [ -n "$(pgrep -f "zold.*${low}")" ]; then
33
- echo "The score finder process is still there, it's a bug"
34
- exit 1
35
- fi
36
-
37
- echo "High node logs (port ${high}):"
38
- cat "${high}/log"
39
- echo "Low node logs (port ${low}):"
40
- cat "${low}/log"
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env bash
2
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
3
- # SPDX-License-Identifier: MIT
4
-
5
- function start_node {
6
- port=$(reserve_port)
7
- mkdir "${port}"
8
- cd "${port}" || exit
9
- zold remote clean
10
- zold node --trace --invoice=SPREADWALLETS@ffffffffffffffff --tolerate-edges --tolerate-quorum=1 \
11
- --host=127.0.0.1 --port="${port}" --bind-port="${port}" \
12
- --threads=0 --never-reboot > log.txt 2>&1 &
13
- pid=$!
14
- echo "${pid}" > pid
15
- cd ..
16
- wait_for_url "http://localhost:${port}/"
17
- echo "${port}"
18
- }
19
-
20
- first=$(start_node)
21
- second=$(start_node)
22
- # shellcheck disable=SC2064
23
- trap "halt_nodes ${first} ${second}" EXIT
24
-
25
- zold --home="${first}" remote add 127.0.0.1 "${second}"
26
- zold --home="${second}" remote add 127.0.0.1 "${first}"
27
-
28
- zold --public-key=id_rsa.pub create 0000000000000000
29
- zold pay --private-key=id_rsa 0000000000000000 NOPREFIX@aaaabbbbccccdddd 4000000z 'To help you, dude!'
30
- zold remote clean
31
- zold remote add 127.0.0.1 "${first}"
32
- zold push 0000000000000000 --tolerate-edges --tolerate-quorum=1
33
- zold remote clean
34
- zold remote add 127.0.0.1 "${second}"
35
-
36
- i=0
37
- until zold fetch 0000000000000000 --ignore-score-weakness --tolerate-edges --tolerate-quorum=1; do
38
- echo 'Failed to fetch, let us try again'
39
- i=$((i + 1))
40
- if [ "${i}" -eq 5 ]; then
41
- cat "${first}/log.txt"
42
- echo "The wallet has not been distributed, after ${i} attempts"
43
- exit 1
44
- fi
45
- sleep 2
46
- done
47
-
48
- json=$(curl --silent --show-error "http://127.0.0.1:${first}")
49
- if [ ! "$(echo "${json}" | jq -r '.entrance.queue')" == "0" ]; then
50
- echo "The queue is not empty after PUSH, it's a bug"
51
- exit 1
52
- fi
53
- if [ ! "$(echo "${json}" | jq -r '.entrance.history_size')" == "1" ]; then
54
- echo "The history doesn't have a wallet, it's a bug"
55
- exit 1
56
- fi
data/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ]
6
- }
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'tmpdir'
7
- require 'webmock/minitest'
8
- require_relative '../../test__helper'
9
- require_relative '../../../lib/zold/commands/routines/audit'
10
-
11
- # Audit test.
12
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
13
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
14
- # License:: MIT
15
- class TestAudit < Zold::Test
16
- def test_audits
17
- FakeHome.new(log: fake_log).run do |home|
18
- opts = { 'routine-immediately' => true }
19
- routine = Zold::Routines::Audit.new(opts, home.wallets, log: fake_log)
20
- routine.exec
21
- end
22
- end
23
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../../test__helper'
7
- require_relative '../../fake_home'
8
- require_relative '../../../lib/zold/wallets'
9
- require_relative '../../../lib/zold/commands/routines/gc'
10
-
11
- # Gc test.
12
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
13
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
14
- # License:: MIT
15
- class TestGc < Zold::Test
16
- def test_collects_garbage
17
- FakeHome.new(log: fake_log).run do |home|
18
- wallets = home.wallets
19
- home.create_wallet
20
- opts = { 'routine-immediately' => true, 'gc-age' => 0 }
21
- assert_equal(1, wallets.count)
22
- routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
23
- routine.exec
24
- assert_equal(0, wallets.count)
25
- end
26
- end
27
-
28
- def test_doesnt_touch_non_empty_wallets
29
- FakeHome.new(log: fake_log).run do |home|
30
- wallets = home.wallets
31
- wallet = home.create_wallet
32
- amount = Zold::Amount.new(zld: 39.99)
33
- key = Zold::Key.new(file: 'fixtures/id_rsa')
34
- wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
35
- opts = { 'routine-immediately' => true, 'gc-age' => 0 }
36
- routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
37
- routine.exec
38
- assert_equal(1, wallets.count)
39
- end
40
- end
41
-
42
- def test_doesnt_touch_fresh_wallets
43
- FakeHome.new(log: fake_log).run do |home|
44
- wallets = home.wallets
45
- home.create_wallet
46
- opts = { 'routine-immediately' => true, 'gc-age' => 60 * 60 }
47
- routine = Zold::Routines::Gc.new(opts, wallets, log: fake_log)
48
- routine.exec
49
- assert_equal(1, wallets.count)
50
- end
51
- end
52
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'webmock/minitest'
7
- require_relative '../../test__helper'
8
- require_relative '../../fake_home'
9
- require_relative '../../../lib/zold/remotes'
10
- require_relative '../../../lib/zold/commands/routines/reconcile'
11
-
12
- # Reconcile test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
15
- # License:: MIT
16
- class TestReconcile < Zold::Test
17
- def test_reconciles
18
- FakeHome.new(log: fake_log).run do |home|
19
- remotes = home.remotes
20
- remotes.clean
21
- remotes.masters
22
- m = remotes.all[0]
23
- remotes.all.each_with_index { |r, idx| remotes.remove(r[:host], r[:port]) if idx.positive? }
24
- stub_request(:get, "http://#{m[:host]}:#{m[:port]}/wallets").to_return(status: 200, body: Zold::Id::ROOT.to_s)
25
- stub_request(:get, "http://#{m[:host]}:#{m[:port]}/wallet/#{Zold::Id::ROOT}").to_return(status: 404)
26
- opts = { 'never-reboot' => true, 'routine-immediately' => true }
27
- routine = Zold::Routines::Reconcile.new(
28
- opts, home.wallets, remotes, home.copies.root, 'some-fake-host:2096', log: fake_log
29
- )
30
- routine.exec
31
- end
32
- end
33
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'tmpdir'
7
- require 'webmock/minitest'
8
- require_relative '../../test__helper'
9
- require_relative '../../../lib/zold/remotes'
10
- require_relative '../../../lib/zold/commands/routines/reconnect'
11
-
12
- # Reconnect test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
15
- # License:: MIT
16
- class TestReconnect < Zold::Test
17
- def test_reconnects
18
- Dir.mktmpdir do |dir|
19
- remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.csv'))
20
- remotes.clean
21
- remotes.add('localhost', 4096)
22
- stub_request(:get, 'http://localhost:4096/remotes').to_return(status: 404)
23
- opts = { 'never-reboot' => true, 'routine-immediately' => true }
24
- routine = Zold::Routines::Reconnect.new(opts, remotes, log: fake_log)
25
- routine.exec
26
- end
27
- end
28
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'tmpdir'
7
- require 'webmock/minitest'
8
- require_relative '../../test__helper'
9
- require_relative '../../../lib/zold/remotes'
10
- require_relative '../../../lib/zold/commands/routines/retire'
11
-
12
- # Retire test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
15
- # License:: MIT
16
- class TestRetire < Zold::Test
17
- def test_retires
18
- opts = { 'never-reboot' => false, 'routine-immediately' => true }
19
- routine = Zold::Routines::Retire.new(opts, log: fake_log)
20
- routine.exec(10 * 24 * 60)
21
- end
22
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../test__helper'
7
- require_relative '../fake_home'
8
- require_relative '../../lib/zold/commands/alias'
9
-
10
- class TestAlias < Zold::Test
11
- # alias set <wallet> <alias>
12
- # @todo #322:30min Implement the set command and unskip this test.
13
- # The syntax is already documented in the alias command in the help.
14
- def test_set_writes_alias_to_the_alias_file
15
- skip
16
- FakeHome.new(log: fake_log).run do |home|
17
- wallet = home.create_wallet
18
- Zold::Alias.new(wallets: home.wallets, log: fake_log).run(%W[set #{wallet.id} my-alias])
19
- assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
20
- end
21
- end
22
-
23
- # alias remove <alias>
24
- # @todo #322:30min Implement the remove command and unskip this test.
25
- # The syntax is already documented in the alias command in the help.
26
- def test_remove_removes_the_alias_from_the_alias_file
27
- skip
28
- FakeHome.new(log: fake_log).run do |home|
29
- wallet = home.create_wallet
30
- cmd = Zold::Alias.new(wallets: home.wallets, log: fake_log)
31
- cmd.run(%W[set #{wallet.id} my-alias])
32
- assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
33
- cmd.run(%w[remove my-alias])
34
- assert_empty read_alias_file(home)
35
- end
36
- end
37
-
38
- # alias show <alias>
39
- # @todo #322:30min Implement the show command and unskip this test.
40
- # The syntax is already documented in the alias command in the help.
41
- def test_show_prints_out_the_aliased_wallet_id
42
- skip
43
- FakeHome.new(log: fake_log).run do |home|
44
- wallet = home.create_wallet
45
- cmd = Zold::Alias.new(wallets: home.wallets, log: fake_log)
46
- cmd.run(%W[set #{wallet.id} my-alias])
47
- assert_equal read_alias_file(home), %W[my-alias #{wallet.id}]
48
- stdout, = capture_io { cmd.run(%w[show my-alias]) }
49
- assert_match wallet.id.to_s, stdout
50
- end
51
- end
52
-
53
- private
54
-
55
- def read_alias_file(home)
56
- File.read(File.join(home.dir, 'aliases')).split
57
- end
58
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../test__helper'
7
- require 'loog'
8
- require_relative '../../lib/zold/commands/calculate'
9
-
10
- # SCORE test.
11
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
12
- # Copyright:: Copyright (c) 2018-2025 Zerocracy
13
- # License:: MIT
14
- class TestCalculate < Zold::Test
15
- def test_calculates_score
16
- score = Zold::Calculate.new(log: fake_log).run(
17
- ['score', '--strength=2', '--max=8', '--invoice=NOSUFFIX@ffffffffffffffff']
18
- )
19
- assert_predicate(score, :valid?)
20
- assert_equal(8, score.value)
21
- end
22
- end