zold 0.13.44 → 0.13.45

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf5190e58996ff52177172576009917026da5136
4
- data.tar.gz: 7f0ce81b3a4ae8b21eb835cd6eb2d0e6aecd2aee
3
+ metadata.gz: 622dc23ea0837dff3dd0dfefb7fb14cf2dadc7b7
4
+ data.tar.gz: a41c3ecde8b70c7d91ba87750122d7ec4183818f
5
5
  SHA512:
6
- metadata.gz: a8e5c2b7ed530521fc5d3f8bda21b3f547a3a8757e3e4fa083be4b1cbf3cb59e793514d8ea85feb3f4a195e0e398312956bc7b7fa5b0c0f1587250d61a278bfd
7
- data.tar.gz: a64b280273fcfae4bccf039b01419450065757cc8d3de53e88435864f3f026b6c2f49778c2d5b9dbe3565172681906a893fc4c3adfb04b3eee77675daef0a276
6
+ metadata.gz: 0f570ce49f29485a9651c48ede80cab98cd270d2a750f4ec02570ee0886dad62be9e0f4444d45f582b210c6ae2b87a6ec9a9dfc4486696bf09101c55d16700cf
7
+ data.tar.gz: d8b64b55bfe0f04daa6830b4246a3d50f7a6277c15de193148b8a52fccee0c461d17ca2754090116c654b835be12b70f3a120010807725382e2c6c42fb007419
@@ -65,10 +65,6 @@ Available options:"
65
65
  private
66
66
 
67
67
  def merge(id, cps, opts)
68
- if cps.all.empty?
69
- @log.error("There are no remote copies of #{id}, try 'zold fetch' first")
70
- return
71
- end
72
68
  cps = cps.all.sort_by { |c| c[:score] }.reverse
73
69
  patch = Patch.new(@wallets, log: @log)
74
70
  cps.each do |c|
@@ -39,8 +39,8 @@ module Zold
39
39
  def start
40
40
  @entrance.start do
41
41
  @pool = Concurrent::FixedThreadPool.new(
42
- Concurrent.processor_count,
43
- max_queue: Concurrent.processor_count * 10,
42
+ Concurrent.processor_count * 8,
43
+ max_queue: Concurrent.processor_count * 32,
44
44
  fallback_policy: :abort
45
45
  )
46
46
  begin
@@ -89,7 +89,8 @@ module Zold
89
89
  end
90
90
  @mutex.synchronize do
91
91
  @history.shift if @history.length > 16
92
- @history << "#{id}/#{sec}/#{modified.count}"
92
+ wallet = @wallets.find(id)
93
+ @history << "#{id}/#{sec}/#{modified.count}/#{wallet.balance.to_zld}/#{wallet.txns.count}t"
93
94
  end
94
95
  modified
95
96
  end
@@ -181,7 +181,11 @@ module Zold
181
181
  wallet.id.to_s,
182
182
  wallet.key.to_s,
183
183
  '',
184
- wallet.txns.map(&:to_text).join("\n")
184
+ wallet.txns.map(&:to_text).join("\n"),
185
+ '',
186
+ '--',
187
+ 'Balance: ' + wallet.balance,
188
+ 'Transactions: ' + wallet.txns.count
185
189
  ].join("\n")
186
190
  end
187
191
 
data/lib/zold/remotes.rb CHANGED
@@ -234,7 +234,7 @@ in #{(Time.now - start).round}s; errors=#{errors}")
234
234
  }
235
235
  end
236
236
  raw.reject { |r| !r[:host] || r[:port].zero? }.map do |r|
237
- r[:home] = URI("http://#{r[0]}:#{r[1]}/")
237
+ r[:home] = URI("http://#{r[:host]}:#{r[:port]}/")
238
238
  r
239
239
  end
240
240
  end
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.13.44'.freeze
26
+ VERSION = '0.13.45'.freeze
27
27
  end
@@ -123,6 +123,18 @@ class TestMerge < Minitest::Test
123
123
  end
124
124
  end
125
125
 
126
+ def test_removes_negative_fakes
127
+ FakeHome.new.run do |home|
128
+ wallet = home.create_wallet
129
+ key = Zold::Key.new(file: 'fixtures/id_rsa')
130
+ wallet.sub(Zold::Amount.new(zld: 9.99), "NOPREFIX@#{Zold::Id.new}", key)
131
+ Zold::Merge.new(wallets: home.wallets, copies: home.copies.root, log: test_log).run(
132
+ ['merge', wallet.id.to_s, '--no-baseline']
133
+ )
134
+ assert_equal(Zold::Amount::ZERO, wallet.balance)
135
+ end
136
+ end
137
+
126
138
  def test_merges_scenarios
127
139
  base = 'fixtures/merge'
128
140
  Dir.new(base).select { |f| File.directory?(File.join(base, f)) && !f.start_with?('.') }.each do |f|
data/test/test_remotes.rb CHANGED
@@ -118,10 +118,11 @@ class TestRemotes < Minitest::Test
118
118
  file = File.join(dir, 'remotes')
119
119
  FileUtils.touch(file)
120
120
  remotes = Zold::Remotes.new(file)
121
- remotes.add('127.0.0.1', 80)
122
- remotes.rescore('127.0.0.1', 80, 15)
121
+ remotes.add('127.0.0.1', 1024)
122
+ remotes.rescore('127.0.0.1', 1024, 15)
123
123
  remotes.all.each do |r|
124
124
  assert_equal(15, r[:score])
125
+ assert_equal('http://127.0.0.1:1024/', r[:home].to_s)
125
126
  end
126
127
  end
127
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.44
4
+ version: 0.13.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko