zold 0.13.35 → 0.13.36

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: d72a17dead59c9ae473afc46355b7189dccde252
4
- data.tar.gz: cd9e2182faaae9ef62448e099bbe836246832fef
3
+ metadata.gz: e23be41e6c8dadef6629a272c916ccee80df3f3b
4
+ data.tar.gz: '08289f098335807fc9c20d51c8a3d594a55fe556'
5
5
  SHA512:
6
- metadata.gz: c2e3e6e3d3d34fc1f0442397efbf4fceb6b269d8d7b4099cf46a70c130beb4f35fe53d2397c63d4032576d1fd10d3e448835e808a7b79149c1d364de06fc8b24
7
- data.tar.gz: 2b8283cb8e7d7661cf002f24b6430dae1c5c1ec1ab522c02f1ef650aef425dfe24383f9fc7c80132d676ba9510154698bd6b82040b8eac92d5104906524c255f
6
+ metadata.gz: 485792e64292fefdb142042688ee14c4dff2cec23b38342a93b0cefc0a60fc81d5f4a61eb1609412ed5adfa0457ef7947831b8c4e6fafbba78ce105b8a880b59
7
+ data.tar.gz: 15d0813c27821df32484ea4b34c48c6ad70cd6a750fd450e61fa22c5ee5a3816c3c900f6992e09400c6ff23b1c5f73f5fac8db32fcd4510303047870b411dbfb
data/lib/zold/patch.rb CHANGED
@@ -69,7 +69,7 @@ module Zold
69
69
  @log.error("Transaction ID is not greater than max ID #{max}: #{txn.to_text}")
70
70
  next
71
71
  end
72
- dup = @txns.find { |t| t.id == txn.id }
72
+ dup = @txns.find { |t| t.id == txn.id && t.amount.negative? }
73
73
  if dup
74
74
  @log.error("An attempt to overwrite #{dup.to_text} with this: #{txn.to_text}")
75
75
  next
data/lib/zold/remotes.rb CHANGED
@@ -173,9 +173,9 @@ module Zold
173
173
  best = farm.best[0]
174
174
  require_relative 'score'
175
175
  score = best.nil? ? Score::ZERO : best
176
- start = Time.now
177
176
  idx = 0
178
177
  all.each do |r|
178
+ start = Time.now
179
179
  begin
180
180
  yield Remotes::Remote.new(r[:host], r[:port], score, idx, log: log, network: @network)
181
181
  idx += 1
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.35'.freeze
26
+ VERSION = '0.13.36'.freeze
27
27
  end
data/test/test_patch.rb CHANGED
@@ -87,4 +87,21 @@ class TestPatch < Minitest::Test
87
87
  assert_equal(amount * -1, first.balance)
88
88
  end
89
89
  end
90
+
91
+ def test_merges_similar_ids_but_different_signs
92
+ FakeHome.new.run do |home|
93
+ first = home.create_wallet(Zold::Id::ROOT)
94
+ second = home.create_wallet
95
+ File.write(second.path, File.read(first.path))
96
+ key = Zold::Key.new(file: 'fixtures/id_rsa')
97
+ second.sub(Zold::Amount.new(zld: 7.0), "NOPREFIX@#{Zold::Id.new}", key)
98
+ first.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 9.0), 'NOPREFIX', Zold::Id.new, 'fake'))
99
+ patch = Zold::Patch.new(home.wallets, log: test_log)
100
+ patch.join(first)
101
+ patch.join(second)
102
+ FileUtils.rm(first.path)
103
+ assert_equal(true, patch.save(first.path))
104
+ assert_equal(Zold::Amount.new(zld: 2.0), first.balance)
105
+ end
106
+ end
90
107
  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.35
4
+ version: 0.13.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko