zold 0.31.5 → 0.31.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codecov.yml +20 -0
- data/.github/workflows/pdd.yml +11 -0
- data/.github/workflows/rake.yml +23 -0
- data/.github/workflows/xcop.yml +11 -0
- data/.rubocop.yml +9 -5
- data/.ruby-version +1 -1
- data/.rultor.yml +4 -5
- data/.simplecov +15 -19
- data/Dockerfile +1 -1
- data/Gemfile +13 -13
- data/Guardfile +1 -1
- data/README.md +0 -5
- data/Rakefile +1 -1
- data/bin/zold +1 -1
- data/features/step_definitions/steps.rb +5 -5
- data/features/support/env.rb +1 -1
- data/fixtures/merge/asserts.rb +1 -1
- data/fixtures/merge/into_no_wallet/assert.rb +1 -1
- data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -2
- data/fixtures/merge/missed_wallets/assert.rb +2 -2
- data/fixtures/merge/negative_overwriting/assert.rb +1 -1
- data/fixtures/merge/negatives_in_between/assert.rb +2 -2
- data/fixtures/merge/random_expenses/assert.rb +2 -2
- data/fixtures/merge/simple_case/assert.rb +1 -1
- data/fixtures/merge/unconfirmed_income/assert.rb +1 -1
- data/lib/zold/age.rb +1 -1
- data/lib/zold/amount.rb +3 -3
- data/lib/zold/cached_wallets.rb +1 -1
- data/lib/zold/commands/args.rb +1 -1
- data/lib/zold/commands/calculate.rb +2 -2
- data/lib/zold/commands/clean.rb +1 -1
- data/lib/zold/commands/create.rb +6 -2
- data/lib/zold/commands/diff.rb +3 -3
- data/lib/zold/commands/fetch.rb +3 -3
- data/lib/zold/commands/invoice.rb +1 -1
- data/lib/zold/commands/list.rb +1 -1
- data/lib/zold/commands/merge.rb +4 -4
- data/lib/zold/commands/next.rb +1 -1
- data/lib/zold/commands/node.rb +3 -3
- data/lib/zold/commands/pay.rb +2 -2
- data/lib/zold/commands/propagate.rb +2 -2
- data/lib/zold/commands/pull.rb +1 -1
- data/lib/zold/commands/push.rb +1 -1
- data/lib/zold/commands/remote.rb +1 -1
- data/lib/zold/commands/remove.rb +1 -1
- data/lib/zold/commands/routines/audit.rb +7 -8
- data/lib/zold/commands/routines/gc.rb +1 -1
- data/lib/zold/commands/routines/reconcile.rb +1 -1
- data/lib/zold/commands/routines/reconnect.rb +1 -1
- data/lib/zold/commands/routines/retire.rb +1 -1
- data/lib/zold/commands/routines.rb +1 -1
- data/lib/zold/commands/show.rb +5 -6
- data/lib/zold/commands/taxes.rb +2 -2
- data/lib/zold/commands/thread_badge.rb +1 -1
- data/lib/zold/copies.rb +4 -4
- data/lib/zold/dir_items.rb +2 -2
- data/lib/zold/endless.rb +3 -5
- data/lib/zold/gem.rb +1 -1
- data/lib/zold/hands.rb +4 -4
- data/lib/zold/head.rb +1 -1
- data/lib/zold/hexnum.rb +1 -1
- data/lib/zold/http.rb +5 -4
- data/lib/zold/hungry_wallets.rb +2 -2
- data/lib/zold/id.rb +3 -5
- data/lib/zold/json_page.rb +2 -2
- data/lib/zold/key.rb +5 -5
- data/lib/zold/log.rb +7 -7
- data/lib/zold/metronome.rb +2 -2
- data/lib/zold/node/async_entrance.rb +9 -9
- data/lib/zold/node/entrance.rb +5 -5
- data/lib/zold/node/farm.rb +4 -4
- data/lib/zold/node/farmers.rb +2 -4
- data/lib/zold/node/front.rb +23 -19
- data/lib/zold/node/journaled_pipeline.rb +6 -6
- data/lib/zold/node/nodup_entrance.rb +1 -1
- data/lib/zold/node/nospam_entrance.rb +2 -2
- data/lib/zold/node/pipeline.rb +6 -6
- data/lib/zold/node/safe_entrance.rb +2 -2
- data/lib/zold/node/soft_error.rb +1 -1
- data/lib/zold/node/spread_entrance.rb +3 -3
- data/lib/zold/node/sync_entrance.rb +1 -1
- data/lib/zold/node/trace.rb +1 -1
- data/lib/zold/patch.rb +14 -15
- data/lib/zold/prefixes.rb +1 -1
- data/lib/zold/remotes.rb +4 -6
- data/lib/zold/signature.rb +1 -1
- data/lib/zold/size.rb +1 -1
- data/lib/zold/sync_wallets.rb +1 -1
- data/lib/zold/tax.rb +6 -4
- data/lib/zold/thread_pool.rb +3 -3
- data/lib/zold/tree_wallets.rb +1 -1
- data/lib/zold/txn.rb +26 -19
- data/lib/zold/txns.rb +1 -1
- data/lib/zold/upgrades.rb +2 -2
- data/lib/zold/verbose_thread.rb +2 -2
- data/lib/zold/version.rb +2 -2
- data/lib/zold/version_file.rb +1 -1
- data/lib/zold/wallet.rb +3 -3
- data/lib/zold/wallets.rb +6 -1
- data/lib/zold.rb +1 -1
- data/renovate.json +6 -0
- data/test/commands/routines/test_audit.rb +2 -2
- data/test/commands/routines/test_gc.rb +2 -2
- data/test/commands/routines/test_reconcile.rb +2 -2
- data/test/commands/routines/test_reconnect.rb +2 -2
- data/test/commands/routines/test_retire.rb +2 -2
- data/test/commands/test_alias.rb +1 -1
- data/test/commands/test_calculate.rb +1 -1
- data/test/commands/test_clean.rb +4 -4
- data/test/commands/test_create.rb +1 -1
- data/test/commands/test_diff.rb +5 -5
- data/test/commands/test_fetch.rb +21 -21
- data/test/commands/test_invoice.rb +1 -1
- data/test/commands/test_list.rb +1 -1
- data/test/commands/test_merge.rb +11 -11
- data/test/commands/test_node.rb +1 -1
- data/test/commands/test_pay.rb +4 -4
- data/test/commands/test_propagate.rb +1 -1
- data/test/commands/test_pull.rb +1 -1
- data/test/commands/test_push.rb +1 -1
- data/test/commands/test_remote.rb +2 -2
- data/test/commands/test_remove.rb +1 -1
- data/test/commands/test_show.rb +1 -1
- data/test/commands/test_taxes.rb +2 -2
- data/test/fake_home.rb +4 -3
- data/test/node/fake_entrance.rb +1 -1
- data/test/node/fake_node.rb +2 -2
- data/test/node/test_async_entrance.rb +6 -4
- data/test/node/test_entrance.rb +4 -4
- data/test/node/test_farm.rb +2 -2
- data/test/node/test_farmers.rb +1 -1
- data/test/node/test_front.rb +4 -4
- data/test/node/test_nodup_entrance.rb +2 -2
- data/test/node/test_nospam_entrance.rb +1 -1
- data/test/node/test_safe_entrance.rb +3 -3
- data/test/node/test_spread_entrance.rb +2 -2
- data/test/node/test_sync_entrance.rb +1 -1
- data/test/node/test_trace.rb +1 -1
- data/test/test__helper.rb +5 -4
- data/test/test_age.rb +2 -2
- data/test/test_amount.rb +1 -1
- data/test/test_cached_wallets.rb +3 -3
- data/test/test_copies.rb +6 -6
- data/test/test_dir_items.rb +2 -4
- data/test/test_gem.rb +1 -1
- data/test/test_hands.rb +1 -1
- data/test/test_hexnum.rb +1 -1
- data/test/test_http.rb +5 -5
- data/test/test_hungry_wallets.rb +1 -1
- data/test/test_id.rb +1 -1
- data/test/test_json_page.rb +1 -1
- data/test/test_key.rb +5 -5
- data/test/test_log.rb +1 -1
- data/test/test_metronome.rb +2 -1
- data/test/test_patch.rb +9 -9
- data/test/test_prefixes.rb +1 -1
- data/test/test_remotes.rb +2 -2
- data/test/test_signature.rb +1 -1
- data/test/test_size.rb +1 -1
- data/test/test_sync_wallets.rb +1 -1
- data/test/test_tax.rb +4 -4
- data/test/test_thread_pool.rb +1 -1
- data/test/test_tree_wallets.rb +1 -1
- data/test/test_txn.rb +2 -2
- data/test/test_upgrades.rb +4 -4
- data/test/test_verbose_thread.rb +1 -1
- data/test/test_wallet.rb +14 -14
- data/test/test_wallets.rb +1 -1
- data/test/test_zold.rb +2 -2
- data/test/upgrades/test_delete_banned_wallets.rb +1 -1
- data/test/upgrades/test_protocol_up.rb +1 -1
- data/upgrades/2.rb +1 -1
- data/upgrades/delete_banned_wallets.rb +2 -2
- data/upgrades/move_wallets_into_tree.rb +1 -1
- data/upgrades/protocol_up.rb +3 -3
- data/upgrades/rename_foreign_wallets.rb +2 -2
- data/zold.gemspec +21 -24
- metadata +40 -117
- data/.github/CODE_OF_CONDUCT.md +0 -76
- data/.github/CONTRIBUTING.md +0 -11
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
data/lib/zold/txn.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -53,8 +53,8 @@ module Zold
|
|
53
53
|
REGEX_DETAILS = Regexp.new("^#{RE_DETAILS}$")
|
54
54
|
private_constant :REGEX_DETAILS
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
attr_accessor :amount, :bnf, :sign
|
57
|
+
attr_reader :id, :date, :prefix, :details
|
58
58
|
|
59
59
|
# Make a new object of this class (you must read the White Paper
|
60
60
|
# in order to understand this class).
|
@@ -152,15 +152,19 @@ module Zold
|
|
152
152
|
|
153
153
|
# Pattern to match the transaction from text
|
154
154
|
PTN = Regexp.new(
|
155
|
-
|
156
|
-
'
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
155
|
+
[
|
156
|
+
'^',
|
157
|
+
[
|
158
|
+
'(?<id>[0-9a-f]{4})',
|
159
|
+
'(?<date>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)',
|
160
|
+
'(?<amount>[0-9a-f]{16})',
|
161
|
+
"(?<prefix>#{RE_PREFIX})",
|
162
|
+
'(?<bnf>[0-9a-f]{16})',
|
163
|
+
"(?<details>#{RE_DETAILS})",
|
164
|
+
'(?<sign>[A-Za-z0-9+/]+={0,3})?'
|
165
|
+
].join(';'),
|
166
|
+
'$'
|
167
|
+
].join
|
164
168
|
)
|
165
169
|
private_constant :PTN
|
166
170
|
|
@@ -184,13 +188,16 @@ module Zold
|
|
184
188
|
class CantParseTime < StandardError; end
|
185
189
|
|
186
190
|
ISO8601 = Regexp.new(
|
187
|
-
|
188
|
-
'
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
191
|
+
[
|
192
|
+
'^',
|
193
|
+
[
|
194
|
+
'(?<year>\d{4})',
|
195
|
+
'-(?<month>\d{2})',
|
196
|
+
'-(?<day>\d{2})',
|
197
|
+
'T(?<hours>\d{2})',
|
198
|
+
':(?<minutes>\d{2})',
|
199
|
+
':(?<seconds>\d{2})Z'
|
200
|
+
].join
|
194
201
|
].join
|
195
202
|
)
|
196
203
|
private_constant :ISO8601
|
data/lib/zold/txns.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/lib/zold/upgrades.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -34,7 +34,7 @@ module Zold
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def run
|
37
|
-
Dir.glob("#{@directory}/*.rb").
|
37
|
+
Dir.glob("#{@directory}/*.rb").grep(/^(\d+)\.rb$/).sort.each do |script|
|
38
38
|
@version.apply(script)
|
39
39
|
end
|
40
40
|
command = @opts[:command]
|
data/lib/zold/verbose_thread.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -36,7 +36,7 @@ module Zold
|
|
36
36
|
@log = log
|
37
37
|
end
|
38
38
|
|
39
|
-
def run(safe
|
39
|
+
def run(safe: false)
|
40
40
|
Thread.current.report_on_exception = false
|
41
41
|
yield
|
42
42
|
rescue Errno::ENOMEM => e
|
data/lib/zold/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@
|
|
25
25
|
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
26
26
|
# License:: MIT
|
27
27
|
module Zold
|
28
|
-
VERSION = '0.31.
|
28
|
+
VERSION = '0.31.6'
|
29
29
|
PROTOCOL = 2
|
30
30
|
REPO = 'zold-io/zold'
|
31
31
|
end
|
data/lib/zold/version_file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/lib/zold/wallet.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -114,7 +114,7 @@ module Zold
|
|
114
114
|
raise "File '#{path}' already exists" if File.exist?(path) && !overwrite
|
115
115
|
raise "Invalid network name '#{network}'" unless network =~ /^[a-z]{4,16}$/
|
116
116
|
FileUtils.mkdir_p(File.dirname(path))
|
117
|
-
|
117
|
+
File.write(path, "#{network}\n#{PROTOCOL}\n#{id}\n#{pubkey.to_pub}\n\n")
|
118
118
|
@txns.flush
|
119
119
|
@head.flush
|
120
120
|
end
|
@@ -231,7 +231,7 @@ module Zold
|
|
231
231
|
# in order to make sure two wallets with the same content are identical,
|
232
232
|
# no matter whether they were formatted differently.
|
233
233
|
def refurbish
|
234
|
-
|
234
|
+
File.write(path, "#{(@head.fetch + [''] + @txns.fetch.map(&:to_s)).join("\n")}\n")
|
235
235
|
@txns.flush
|
236
236
|
end
|
237
237
|
|
data/lib/zold/wallets.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -52,6 +52,11 @@ module Zold
|
|
52
52
|
File.expand_path(@dir)
|
53
53
|
end
|
54
54
|
|
55
|
+
# This wallet exists?
|
56
|
+
def exists?(id)
|
57
|
+
File.exist?(File.join(path, id.to_s + Wallet::EXT))
|
58
|
+
end
|
59
|
+
|
55
60
|
# Returns the list of their IDs (as plain text)
|
56
61
|
def all
|
57
62
|
DirItems.new(path).fetch(recursive: false).select do |f|
|
data/lib/zold.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/renovate.json
ADDED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,7 +24,7 @@ require 'minitest/autorun'
|
|
24
24
|
require 'tmpdir'
|
25
25
|
require 'webmock/minitest'
|
26
26
|
require_relative '../../test__helper'
|
27
|
-
require_relative '../../../lib/zold/commands/routines/audit
|
27
|
+
require_relative '../../../lib/zold/commands/routines/audit'
|
28
28
|
|
29
29
|
# Audit test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,7 +24,7 @@ require 'minitest/autorun'
|
|
24
24
|
require_relative '../../test__helper'
|
25
25
|
require_relative '../../fake_home'
|
26
26
|
require_relative '../../../lib/zold/wallets'
|
27
|
-
require_relative '../../../lib/zold/commands/routines/gc
|
27
|
+
require_relative '../../../lib/zold/commands/routines/gc'
|
28
28
|
|
29
29
|
# Gc test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require 'webmock/minitest'
|
|
25
25
|
require_relative '../../test__helper'
|
26
26
|
require_relative '../../fake_home'
|
27
27
|
require_relative '../../../lib/zold/remotes'
|
28
|
-
require_relative '../../../lib/zold/commands/routines/reconcile
|
28
|
+
require_relative '../../../lib/zold/commands/routines/reconcile'
|
29
29
|
|
30
30
|
# Reconcile test.
|
31
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require 'tmpdir'
|
|
25
25
|
require 'webmock/minitest'
|
26
26
|
require_relative '../../test__helper'
|
27
27
|
require_relative '../../../lib/zold/remotes'
|
28
|
-
require_relative '../../../lib/zold/commands/routines/reconnect
|
28
|
+
require_relative '../../../lib/zold/commands/routines/reconnect'
|
29
29
|
|
30
30
|
# Reconnect test.
|
31
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require 'tmpdir'
|
|
25
25
|
require 'webmock/minitest'
|
26
26
|
require_relative '../../test__helper'
|
27
27
|
require_relative '../../../lib/zold/remotes'
|
28
|
-
require_relative '../../../lib/zold/commands/routines/retire
|
28
|
+
require_relative '../../../lib/zold/commands/routines/retire'
|
29
29
|
|
30
30
|
# Retire test.
|
31
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
data/test/commands/test_alias.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_clean.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -37,8 +37,8 @@ class TestClean < Zold::Test
|
|
37
37
|
FakeHome.new(log: test_log).run do |home|
|
38
38
|
wallet = home.create_wallet
|
39
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)
|
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
42
|
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: test_log).run(['clean', wallet.id.to_s])
|
43
43
|
assert(copies.all.empty?)
|
44
44
|
end
|
@@ -63,7 +63,7 @@ class TestClean < Zold::Test
|
|
63
63
|
FakeHome.new(log: test_log).run do |home|
|
64
64
|
wallet = home.create_wallet
|
65
65
|
copies = home.copies(wallet)
|
66
|
-
copies.add(
|
66
|
+
copies.add(File.read(wallet.path), 'host-2', 80, 2, time: Time.now)
|
67
67
|
Threads.new(20).assert do
|
68
68
|
Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: test_log).run(['clean'])
|
69
69
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_diff.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -43,15 +43,15 @@ class TestDiff < Zold::Test
|
|
43
43
|
FakeHome.new(log: test_log).run do |home|
|
44
44
|
wallet = home.create_wallet
|
45
45
|
first = home.create_wallet
|
46
|
-
|
46
|
+
File.write(first.path, File.read(wallet.path))
|
47
47
|
second = home.create_wallet
|
48
|
-
|
48
|
+
File.write(second.path, File.read(wallet.path))
|
49
49
|
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
50
50
|
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
51
51
|
)
|
52
52
|
copies = home.copies(wallet)
|
53
|
-
copies.add(
|
54
|
-
copies.add(
|
53
|
+
copies.add(File.read(first.path), 'host-1', 80, 5)
|
54
|
+
copies.add(File.read(second.path), 'host-2', 80, 5)
|
55
55
|
diff = Zold::Diff.new(wallets: home.wallets, copies: copies.root, log: test_log).run(
|
56
56
|
['diff', wallet.id.to_s]
|
57
57
|
)
|
data/test/commands/test_fetch.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -47,13 +47,13 @@ class TestFetch < Zold::Test
|
|
47
47
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
48
48
|
status: 200,
|
49
49
|
body: {
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
score: Zold::Score::ZERO.to_h,
|
51
|
+
size: 10_000,
|
52
|
+
mtime: Time.now.utc.iso8601
|
53
53
|
}.to_json
|
54
54
|
)
|
55
55
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
56
|
-
.to_return(status: 200, body:
|
56
|
+
.to_return(status: 200, body: File.read(wallet.path))
|
57
57
|
stub_request(:get, "http://localhost:81/wallet/#{wallet.id}").to_return(status: 404)
|
58
58
|
remotes = home.remotes
|
59
59
|
remotes.add('localhost', 4096)
|
@@ -75,24 +75,24 @@ class TestFetch < Zold::Test
|
|
75
75
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}").to_return(
|
76
76
|
status: 200,
|
77
77
|
body: {
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
score: Zold::Score::ZERO.to_h,
|
79
|
+
size: 10_000,
|
80
|
+
mtime: Time.now.utc.iso8601
|
81
81
|
}.to_json
|
82
82
|
)
|
83
83
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}.bin")
|
84
|
-
.to_return(status: 200, body:
|
84
|
+
.to_return(status: 200, body: File.read(wallet_a.path))
|
85
85
|
wallet_b = home.create_wallet
|
86
86
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}").to_return(
|
87
87
|
status: 200,
|
88
88
|
body: {
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
score: Zold::Score::ZERO.to_h,
|
90
|
+
size: 10_000,
|
91
|
+
mtime: Time.now.utc.iso8601
|
92
92
|
}.to_json
|
93
93
|
)
|
94
94
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}.bin")
|
95
|
-
.to_return(status: 200, body:
|
95
|
+
.to_return(status: 200, body: File.read(wallet_b.path))
|
96
96
|
remotes = home.remotes
|
97
97
|
remotes.add('localhost', 4096)
|
98
98
|
copies_a = home.copies(wallet_a)
|
@@ -118,13 +118,13 @@ class TestFetch < Zold::Test
|
|
118
118
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
119
119
|
status: 200,
|
120
120
|
body: {
|
121
|
-
|
122
|
-
|
123
|
-
|
121
|
+
score: Zold::Score::ZERO.to_h,
|
122
|
+
size: 10_000,
|
123
|
+
mtime: Time.now.utc.iso8601
|
124
124
|
}.to_json
|
125
125
|
)
|
126
126
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
127
|
-
.to_return(status: 200, body:
|
127
|
+
.to_return(status: 200, body: File.read(wallet.path))
|
128
128
|
remotes = home.remotes
|
129
129
|
remotes.add('localhost', 4096)
|
130
130
|
copies = home.copies(wallet)
|
@@ -142,13 +142,13 @@ class TestFetch < Zold::Test
|
|
142
142
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
|
143
143
|
status: 200,
|
144
144
|
body: {
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
score: Zold::Score::ZERO.to_h,
|
146
|
+
size: 10_000,
|
147
|
+
mtime: Time.now.utc.iso8601
|
148
148
|
}.to_json
|
149
149
|
)
|
150
150
|
stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
|
151
|
-
.to_return(status: 200, body:
|
151
|
+
.to_return(status: 200, body: File.read(wallet.path))
|
152
152
|
remotes = home.remotes
|
153
153
|
remotes.add('localhost', 4096)
|
154
154
|
copies = home.copies(wallet)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_list.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_merge.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -46,15 +46,15 @@ class TestMerge < Zold::Test
|
|
46
46
|
FakeHome.new(log: test_log).run do |home|
|
47
47
|
wallet = home.create_wallet
|
48
48
|
first = home.create_wallet
|
49
|
-
|
49
|
+
File.write(first.path, File.read(wallet.path))
|
50
50
|
second = home.create_wallet
|
51
|
-
|
51
|
+
File.write(second.path, File.read(wallet.path))
|
52
52
|
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
53
53
|
['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
|
54
54
|
)
|
55
55
|
copies = home.copies(wallet)
|
56
|
-
copies.add(
|
57
|
-
copies.add(
|
56
|
+
copies.add(File.read(first.path), 'host-1', 80, 5)
|
57
|
+
copies.add(File.read(second.path), 'host-2', 80, 5)
|
58
58
|
modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
|
59
59
|
['merge', wallet.id.to_s]
|
60
60
|
)
|
@@ -67,7 +67,7 @@ class TestMerge < Zold::Test
|
|
67
67
|
FakeHome.new(log: test_log).run do |home|
|
68
68
|
wallet = home.create_wallet
|
69
69
|
copies = home.copies(wallet)
|
70
|
-
copies.add(
|
70
|
+
copies.add(File.read(wallet.path), 'good-host', 80, 5)
|
71
71
|
copies.add('some garbage', 'bad-host', 80, 5)
|
72
72
|
modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
|
73
73
|
['merge', wallet.id.to_s]
|
@@ -80,7 +80,7 @@ class TestMerge < Zold::Test
|
|
80
80
|
FakeHome.new(log: test_log).run do |home|
|
81
81
|
wallet = home.create_wallet(Zold::Id::ROOT)
|
82
82
|
copies = home.copies(wallet)
|
83
|
-
copies.add(
|
83
|
+
copies.add(File.read(wallet.path), 'good-host', 80, 5)
|
84
84
|
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
85
85
|
wallet.sub(Zold::Amount.new(zld: 9.99), "NOPREFIX@#{Zold::Id.new}", key)
|
86
86
|
Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
|
@@ -94,10 +94,10 @@ class TestMerge < Zold::Test
|
|
94
94
|
FakeHome.new(log: test_log).run do |home|
|
95
95
|
main = home.create_wallet
|
96
96
|
remote = home.create_wallet
|
97
|
-
|
97
|
+
File.write(remote.path, File.read(main.path))
|
98
98
|
remote.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 11.0), 'NOPREFIX', Zold::Id.new, 'fake'))
|
99
99
|
copies = home.copies(main)
|
100
|
-
copies.add(
|
100
|
+
copies.add(File.read(remote.path), 'fake-host', 80, 0)
|
101
101
|
Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
|
102
102
|
['merge', main.id.to_s, '--no-baseline']
|
103
103
|
)
|
@@ -112,13 +112,13 @@ class TestMerge < Zold::Test
|
|
112
112
|
Dir.mktmpdir do |dir|
|
113
113
|
FileUtils.cp_r(File.join('fixtures/merge', "#{f}/."), dir)
|
114
114
|
scores = File.join(dir, "copies/0123456789abcdef/scores#{Zold::Copies::EXT}")
|
115
|
-
|
115
|
+
File.write(scores, File.read(scores).gsub('NOW', Time.now.utc.iso8601))
|
116
116
|
FileUtils.cp('fixtures/merge/asserts.rb', dir)
|
117
117
|
wallets = Zold::Wallets.new(dir)
|
118
118
|
copies = File.join(dir, 'copies')
|
119
119
|
remotes = Zold::Remotes.new(file: File.join(dir, 'remotes'))
|
120
120
|
Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: test_log).run(
|
121
|
-
%w[merge 0123456789abcdef] +
|
121
|
+
%w[merge 0123456789abcdef] + File.read(File.join(dir, 'opts')).split("\n")
|
122
122
|
)
|
123
123
|
Dir.chdir(dir) do
|
124
124
|
require File.join(dir, 'assert.rb')
|
data/test/commands/test_node.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_pay.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -88,9 +88,9 @@ class TestPay < Zold::Test
|
|
88
88
|
wallet = home.create_wallet
|
89
89
|
amount = Zold::Amount.new(zld: 2.0)
|
90
90
|
Tempfile.open do |f|
|
91
|
-
pem =
|
91
|
+
pem = File.read('fixtures/id_rsa')
|
92
92
|
keygap = pem[100..120]
|
93
|
-
|
93
|
+
File.write(f, pem.gsub(keygap, '*' * keygap.length))
|
94
94
|
Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
|
95
95
|
[
|
96
96
|
'pay', '--force', "--private-key=#{Shellwords.escape(f.path)}",
|
@@ -189,7 +189,7 @@ class TestPay < Zold::Test
|
|
189
189
|
wallet.add(
|
190
190
|
Zold::Txn.new(
|
191
191
|
i + 1,
|
192
|
-
Time.now - 24 * 60 * 60 * 365 * 300,
|
192
|
+
Time.now - (24 * 60 * 60 * 365 * 300),
|
193
193
|
fund,
|
194
194
|
'NOPREFIX', Zold::Id.new, '-'
|
195
195
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_pull.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/commands/test_push.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-2023 Zerocracy
|
3
|
+
# Copyright (c) 2018-2023 Zerocracy
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -95,7 +95,7 @@ class TestRemote < Zold::Test
|
|
95
95
|
)
|
96
96
|
stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return(
|
97
97
|
status: 200,
|
98
|
-
body:
|
98
|
+
body: "{\"version\": \"9.9.9\", \"repo\": \"#{Zold::REPO}\"}"
|
99
99
|
)
|
100
100
|
log = TestLogger.new
|
101
101
|
cmd = Zold::Remote.new(remotes: remotes, log: log)
|