zold 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b465026197a0d5f1aa6d9821a7d56dfd8a47ff27
4
- data.tar.gz: e135309f6d0eb7a08b3939002285cf8d5fba34ee
3
+ metadata.gz: 9a77da32d7c42f8614442e76efa0eb9560e645a8
4
+ data.tar.gz: 5840bb2844ef57929752da61d40158a2f2eba758
5
5
  SHA512:
6
- metadata.gz: 3ed88e357053350010c898b4d90dddc32ab36e4cd7dc34155db296b539b36f4dbd9b3c680fcd95e491bb44887a73201c51f1a2897a5b9c8d59a1bbea7c2d3a24
7
- data.tar.gz: 4999f7da3a1f05da20c7f4e2a78fd66ea407de1ad15368e51b79fd393ee98baf01b368596fdf454f42558bd311ac2c9552e3e08aa2996533d41cc246b5abb884
6
+ metadata.gz: ebf8e676c08b13bf103d7cf155191bbf05e95d09138a815d0357782a2e9fba499c1bb8499dfbdf39f6cf8541d181f3ad26bfd0d0399bba1912a0db28727cfb31
7
+ data.tar.gz: a8d9e92bfa9a5f4660bb089a6ea80862547f51b84f5fc454d5d22bd18f79a36858dbfc2949efffde70da25f6d90ba7bca68585f64062e5c58db27c8edc8b44cf
@@ -30,7 +30,7 @@ zold taxes debt 0000000000000000
30
30
  zold remote show
31
31
  zold push 0000000000000000
32
32
  sleep 2
33
- zold fetch 0000000000000000 --ignore-score-weakness
33
+ zold fetch 0000000000000000 --ignore-score-weakness || echo 'Failed'
34
34
  zold diff 0000000000000000
35
35
  zold merge 0000000000000000
36
36
  zold clean 0000000000000000
data/lib/zold/id.rb CHANGED
@@ -29,7 +29,7 @@ module Zold
29
29
  if id.nil?
30
30
  @id = rand(2**32..2**64 - 1)
31
31
  else
32
- raise "Invalid wallet ID '#{id}'" unless id =~ /^[0-9a-fA-F]{16}$/
32
+ raise "Invalid wallet ID: #{id}" unless id =~ /^[0-9a-fA-F]{16}$/
33
33
  @id = Integer("0x#{id}", 16)
34
34
  end
35
35
  end
@@ -78,7 +78,7 @@ module Zold
78
78
  end
79
79
  modified = Merge.new(
80
80
  wallets: @wallets, copies: copies.root, log: @log
81
- ).run(['merge', id.to_s, '--no-baseline'])
81
+ ).run(['merge', id.to_s])
82
82
  Clean.new(wallets: @wallets, copies: copies.root, log: @log).run(['clean', id.to_s])
83
83
  copies.remove(localhost, Remotes::PORT)
84
84
  sec = (Time.now - start).round(2)
data/lib/zold/upgrades.rb CHANGED
@@ -37,21 +37,12 @@ module Zold
37
37
  # This is a workaround, remove it once this class works correctly
38
38
  require_relative '../../upgrades/2.rb'
39
39
  UpgradeTo2.new(Dir.pwd, @log).exec
40
+ require_relative '../../upgrades/protocol_up.rb'
41
+ ProtocolUp.new(Dir.pwd, @log).exec
40
42
 
41
- scripts.each do |script|
43
+ Dir.glob("#{@directory}/*.rb").select { |f| f =~ /^(\d+)\.rb$/ }.sort.each do |script|
42
44
  @version.apply(script)
43
45
  end
44
46
  end
45
-
46
- private
47
-
48
- def scripts
49
- Dir.glob("#{@directory}/*.rb").sort.map do |path|
50
- basename = File.basename(path)
51
- match = basename.match(/^(\d+)\.rb$/)
52
- raise 'An upgrade script has to be named <number>.rb.' unless match
53
- match[1]
54
- end
55
- end
56
47
  end
57
48
  end
data/lib/zold/version.rb CHANGED
@@ -23,6 +23,6 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.14.2'.freeze
26
+ VERSION = '0.14.3'.freeze
27
27
  PROTOCOL = 2
28
28
  end
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require_relative '../test__helper'
23
+ require_relative '../../upgrades/protocol_up'
24
+ require_relative '../fake_home'
25
+
26
+ # Protocol up.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestProtocolUp < Minitest::Test
31
+ def test_upgrades_protocol_in_wallet
32
+ FakeHome.new.run do |home|
33
+ id = home.create_wallet.id
34
+ Zold::ProtocolUp.new(home.dir, test_log).exec
35
+ wallet = home.wallets.find(id)
36
+ assert_equal(Zold::PROTOCOL, wallet.protocol)
37
+ end
38
+ end
39
+ end
data/upgrades/2.rb CHANGED
@@ -1,3 +1,23 @@
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
1
21
  # https://github.com/zold-io/zold/issues/358
2
22
  # rename all wallets from their current names into *.z
3
23
 
@@ -0,0 +1,44 @@
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require_relative '../lib/zold/version'
22
+ require_relative '../lib/zold/wallet'
23
+
24
+ module Zold
25
+ # Upgrade protocol in each wallet
26
+ class ProtocolUp
27
+ def initialize(home, log)
28
+ @home = home
29
+ @log = log
30
+ end
31
+
32
+ def exec
33
+ Dir.new(@home).each do |path|
34
+ next unless path =~ /^[a-f0-9]{16}#{Wallet::EXTENSION}$/
35
+ f = File.join(@home, path)
36
+ lines = File.read(f).split("\n")
37
+ next if lines[1].to_i == Zold::PROTOCOL
38
+ lines[1] = Zold::PROTOCOL
39
+ File.write(f, lines.join("\n"))
40
+ @log.info("Protocol set to #{Zold::PROTOCOL} in #{f}")
41
+ end
42
+ end
43
+ end
44
+ 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.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -462,7 +462,9 @@ files:
462
462
  - test/test_wallet.rb
463
463
  - test/test_wallets.rb
464
464
  - test/test_zold.rb
465
+ - test/upgrades/test_protocol_up.rb
465
466
  - upgrades/2.rb
467
+ - upgrades/protocol_up.rb
466
468
  - zold.gemspec
467
469
  homepage: http://github.com/zold-io/zold
468
470
  licenses:
@@ -546,3 +548,4 @@ test_files:
546
548
  - test/test_wallet.rb
547
549
  - test/test_wallets.rb
548
550
  - test/test_zold.rb
551
+ - test/upgrades/test_protocol_up.rb