zold 0.13.30 → 0.13.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/id.rb +9 -0
- data/lib/zold/version.rb +1 -1
- data/test/node/test_entrance.rb +10 -0
- data/test/test_id.rb +5 -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: c98b1e9d02790f3993431a547adc638b53e7388e
|
4
|
+
data.tar.gz: fda7df22416b00eebc03f9bcefaed0aa847c8a7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4a715122869803cef3bf0045badbf837d9e64a550dcd2b3f0690dad7ea30b31824f923cc53e2bd1c2ae3b38ece51b3a1e5a80ba8dae8bde7ade0c3af98a3b9
|
7
|
+
data.tar.gz: 88c77327f5eeaf7a909c69bb5c85b9d10571491bf5503b1bf6d931bd8eafd336f2518d3320be404c1d4835dac2d71ef6731f94547cd1f3ac99eaa04505209dc8
|
data/lib/zold/id.rb
CHANGED
@@ -37,6 +37,15 @@ module Zold
|
|
37
37
|
# The ID of the root wallet.
|
38
38
|
ROOT = Id.new('0000000000000000')
|
39
39
|
|
40
|
+
def eql?(other)
|
41
|
+
raise 'Can only compare with Id' unless other.is_a?(Id)
|
42
|
+
to_s == other.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def hash
|
46
|
+
to_s.hash
|
47
|
+
end
|
48
|
+
|
40
49
|
def==(other)
|
41
50
|
raise 'Can only compare with Id' unless other.is_a?(Id)
|
42
51
|
to_s == other.to_s
|
data/lib/zold/version.rb
CHANGED
data/test/node/test_entrance.rb
CHANGED
@@ -42,6 +42,16 @@ class TestEntrance < Minitest::Test
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def test_ignores_duplicates
|
46
|
+
FakeHome.new.run do |home|
|
47
|
+
wallet = home.create_wallet(Zold::Id.new)
|
48
|
+
entrance = Zold::Entrance.new(home.wallets, home.remotes, home.copies(wallet).root, 'x', log: test_log)
|
49
|
+
id = Zold::Id.new.to_s
|
50
|
+
8.times { entrance.spread([Zold::Id.new(id)]) }
|
51
|
+
assert_equal(1, entrance.to_json[:modified])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
45
55
|
def test_pushes_wallet
|
46
56
|
sid = Zold::Id.new
|
47
57
|
tid = Zold::Id.new
|
data/test/test_id.rb
CHANGED
@@ -48,6 +48,11 @@ class TestId < Minitest::Test
|
|
48
48
|
assert(id.to_s == hex, "#{id} is not equal to #{hex}")
|
49
49
|
end
|
50
50
|
|
51
|
+
def test_compares_two_ids_by_text
|
52
|
+
id = Zold::Id.new.to_s
|
53
|
+
assert_equal(Zold::Id.new(id), Zold::Id.new(id))
|
54
|
+
end
|
55
|
+
|
51
56
|
def test_compares_two_ids
|
52
57
|
assert Zold::Id.new(Zold::Id::ROOT.to_s) == Zold::Id.new('0000000000000000')
|
53
58
|
end
|