zold 0.18.4 → 0.18.5

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
  SHA256:
3
- metadata.gz: caa27451b7402bdf03dd157ca5e95cf41178e56ca7d7e83c8269b15c758b3fa9
4
- data.tar.gz: db13826b8a36fe66407b52b62bcaf2fb33113e1964582fb78916591c1adb429a
3
+ metadata.gz: 107b5e77f3c4f52c9331511957365add6116ffaf33fd8c1a0ffe61d86658deca
4
+ data.tar.gz: 38a6934d82c1fe5fafa93109bf587c5d108e703eaa8b832330845fd110be6b30
5
5
  SHA512:
6
- metadata.gz: c45a552acbce84ddcdc730cf667cbc6e4cad3a8e36374b97ef05b30d6ddc2642634ee3b165b9a4af8c0e6dd37f3eabd6d794d4827fcf15a1890228a75da28e19
7
- data.tar.gz: d1ef9b356816c1ad0a835f50694c6efc0d1cffa8c0faada91d95ab554ee6e7bc3428812befcc79a6d69da69ffd57b834213c12317f5b4d53d868089c8d2ee44c
6
+ metadata.gz: 30fc094ba1a6e69eb1e2dc8ca2b735197f29e8834c79baac950e3b1e873876beeaee169761115d9a8d50b0bbbfd8d453b9c5b6705ce0231aa5f4ed7dea5479f3
7
+ data.tar.gz: 92bdb792f17ba0d73b8375139dc510ac1897a637d95db712275423cbcadf4028a03ce3dc80290b37c32b55f95095a5d964b45a47043b7004c30925ed010d5621
@@ -47,7 +47,7 @@ module Zold
47
47
  removed = 0
48
48
  @wallets.all.each do |id|
49
49
  seen += 1
50
- next unless @wallets.acq(id) { |w| w.txns.empty? && w.mtime < Time.now - @opts['gc-age'] }
50
+ next unless @wallets.acq(id) { |w| w.exists? && w.txns.empty? && w.mtime < Time.now - @opts['gc-age'] }
51
51
  cmd.run(args + [id.to_s])
52
52
  removed += 1
53
53
  end
@@ -308,7 +308,7 @@ from #{request.ip} in #{Age.new(@start, limit: 1)}")
308
308
  end
309
309
 
310
310
  get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/txns.json} do
311
- fetch { |w| pretty(w.txns.map(&:to_json)) }
311
+ fetch('application/json') { |w| pretty(w.txns.map(&:to_json)) }
312
312
  end
313
313
 
314
314
  get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.txt} do
@@ -455,11 +455,7 @@ time to stop; use --skip-oom to never quit")
455
455
  yield header
456
456
  end
457
457
 
458
- # @todo #513:30min This method is temporarily disabled since it
459
- # takes a lot of time (when the amount of wallets is big, like 40K). However,
460
- # we must find a way to count them somehow faster.
461
458
  def total_wallets
462
- return 256 if settings.opts['network'] == Wallet::MAINET
463
459
  settings.zache.get(:wallets, lifetime: settings.opts['no-cache'] ? 0 : 60) do
464
460
  settings.wallets.count
465
461
  end
@@ -26,7 +26,7 @@
26
26
  # License:: MIT
27
27
  module Zold
28
28
  # Soft error
29
- module SoftError
29
+ class SoftError < StandardError
30
30
  # Nothing special
31
31
  end
32
32
  end
data/lib/zold/txn.rb CHANGED
@@ -100,7 +100,7 @@ module Zold
100
100
  date: @date.utc.iso8601,
101
101
  amount: @amount.to_i,
102
102
  prefix: @prefix,
103
- bfn: @bnf,
103
+ bnf: @bnf.to_s,
104
104
  details: @details,
105
105
  sign: @sign
106
106
  }
data/lib/zold/version.rb CHANGED
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.18.4'
28
+ VERSION = '0.18.5'
29
29
  PROTOCOL = 2
30
30
  end
@@ -27,6 +27,7 @@ require_relative '../../lib/zold/wallet'
27
27
  require_relative '../../lib/zold/id'
28
28
  require_relative '../../lib/zold/key'
29
29
  require_relative '../../lib/zold/node/safe_entrance'
30
+ require_relative '../../lib/zold/node/soft_error'
30
31
  require_relative 'fake_entrance'
31
32
 
32
33
  # SafeEntrance test.
@@ -40,7 +41,7 @@ class TestSafeEntrance < Zold::Test
40
41
  amount = Zold::Amount.new(zld: 39.99)
41
42
  key = Zold::Key.new(file: 'fixtures/id_rsa')
42
43
  wallet.sub(amount, "NOPREFIX@#{Zold::Id.new}", key)
43
- assert_raises StandardError do
44
+ assert_raises Zold::SoftError do
44
45
  Zold::SafeEntrance.new(FakeEntrance.new).push(wallet.id, IO.read(wallet.path))
45
46
  end
46
47
  end
data/test/test_age.rb CHANGED
@@ -21,6 +21,7 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'minitest/autorun'
24
+ require_relative 'test__helper'
24
25
  require_relative '../lib/zold/age'
25
26
 
26
27
  # Age test.
data/test/test_amount.rb CHANGED
@@ -21,6 +21,7 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'minitest/autorun'
24
+ require_relative 'test__helper'
24
25
  require_relative '../lib/zold/amount'
25
26
 
26
27
  # Amount test.
data/test/test_size.rb CHANGED
@@ -21,6 +21,7 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'minitest/autorun'
24
+ require_relative 'test__helper'
24
25
  require_relative '../lib/zold/size'
25
26
 
26
27
  # Size test.
data/test/test_txn.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  require 'minitest/autorun'
24
24
  require 'tmpdir'
25
25
  require 'time'
26
+ require_relative 'test__helper'
26
27
  require_relative '../lib/zold/id'
27
28
  require_relative '../lib/zold/txn'
28
29
  require_relative '../lib/zold/amount'
@@ -46,6 +47,21 @@ class TestTxn < Zold::Test
46
47
  assert_equal('NOPREFIX', txn.prefix)
47
48
  end
48
49
 
50
+ def test_converts_to_json
51
+ time = Time.now
52
+ txn = Zold::Txn.new(
53
+ 123, time, Zold::Amount.new(zld: -99.95),
54
+ 'NOPREFIX', Zold::Id.new('0123012301230123'),
55
+ 'Some details to see'
56
+ )
57
+ json = txn.to_json
58
+ assert_equal(123, json[:id])
59
+ assert_equal(-429_281_981_235, json[:amount])
60
+ assert_equal('NOPREFIX', json[:prefix])
61
+ assert_equal('0123012301230123', json[:bnf])
62
+ assert_equal('Some details to see', json[:details])
63
+ end
64
+
49
65
  def test_accepts_text_as_details
50
66
  details = 'How are you, dude?! I\'m @yegor256: *_hello_'
51
67
  txn = Zold::Txn.parse(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.4
4
+ version: 0.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -703,7 +703,7 @@ licenses:
703
703
  - MIT
704
704
  metadata: {}
705
705
  post_install_message: |-
706
- Thanks for installing Zold 0.18.4!
706
+ Thanks for installing Zold 0.18.5!
707
707
  Study our White Paper: https://papers.zold.io/wp.pdf
708
708
  Read our blog posts: https://blog.zold.io
709
709
  Try online wallet at: https://wts.zold.io