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 +4 -4
- data/lib/zold/patch.rb +1 -1
- data/lib/zold/remotes.rb +1 -1
- data/lib/zold/version.rb +1 -1
- data/test/test_patch.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e23be41e6c8dadef6629a272c916ccee80df3f3b
|
4
|
+
data.tar.gz: '08289f098335807fc9c20d51c8a3d594a55fe556'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|