test/zold/stress/test_round.rb in zold-stress-0.6.0 vs test/zold/stress/test_round.rb in zold-stress-0.7.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# Copyright (c) 2018 Yegor Bugayenko
+# Copyright (c) 2018-2019 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -50,34 +50,40 @@
Dir.mktmpdir do |home|
remotes = Zold::Remotes.new(file: File.join(home, 'remotes'), network: 'test')
remotes.clean
remotes.add('localhost', port)
wallets = Zold::SyncWallets.new(Zold::CachedWallets.new(Zold::Wallets.new(home)))
- Zold::Create.new(wallets: wallets, log: test_log).run(
- ['create', '--public-key=fixtures/id_rsa.pub', Zold::Id::ROOT.to_s, '--network=test']
+ Zold::Create.new(wallets: wallets, log: test_log, remotes: nil).run(
+ ['create', '--public-key=fixtures/id_rsa.pub', Zold::Id::ROOT.to_s, '--network=test', '--skip-test']
)
wallets.acq(Zold::Id::ROOT) do |w|
w.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 1.0), 'NOPREFIX', Zold::Id.new, '-'))
end
- stats = Zold::Stress::Stats.new
+ stats = Zold::Stress::Stats.new(log: test_log)
air = Zold::Stress::Air.new
- batch = 20
+ batch = 4
summary = Zold::Stress::Summary.new(stats, batch)
round = Zold::Stress::Round.new(
pvt: Zold::Key.new(file: 'fixtures/id_rsa'),
- wallets: wallets, remotes: remotes,
- air: air, stats: stats,
+ wallets: wallets,
+ remotes: remotes,
+ air: air,
+ stats: stats,
opts: test_opts('--pool=5', "--batch=#{batch}"),
copies: File.join(home, 'copies'),
- log: test_log, vlog: test_log
+ log: test_log,
+ vlog: test_log
)
round.update
round.prepare
round.send
attempt = 0
loop do
- break if air.fetch.empty?
- break if attempt > 50
+ if air.fetch.empty?
+ test_log.info('There is nothing in the air, time to stop')
+ break
+ end
+ break if attempt > 4
round.pull
round.match
test_log.info(summary)
attempt += 1
sleep 0.2