zold-stress 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 20a4f93a2a89ef506dbdfdbe3c55c2a5a56f91e675087bcd17c746453844cdf5
4
+ data.tar.gz: 1cc77a327d0f2610421ada34ab62d49bd0bdd8697eba4df0c283c00f1ad80e43
5
+ SHA512:
6
+ metadata.gz: a4a09956cc8815c9f6fa944442e20f2fa51fa49106a6489b095535486ffaeae852da67af4ade4fbc2813fb4a4a08c838a963c843d1c20b9e865c1f11b6ef3dc2
7
+ data.tar.gz: 2b20d477ffd5e30908331399153017ab37c5f2a5910437a85cf0fea2c85dbeff3ec25452c18537211b23ca6f16a66f69e34bc002c25a9d6a6b0bf48076ab287a
@@ -0,0 +1,9 @@
1
+ errors:
2
+ - yegor256@gmail.com
3
+ # alerts:
4
+ # github:
5
+ # - yegor256
6
+
7
+ tags:
8
+ - pdd
9
+ - bug
@@ -0,0 +1,9 @@
1
+ # Check out all text files in UNIX format, with LF as end of line
2
+ # Don't change this file. If you have any ideas about it, please
3
+ # submit a separate issue about it and we'll discuss.
4
+
5
+ * text=auto eol=lf
6
+ *.rb ident
7
+ *.xml ident
8
+ *.png binary
9
+ *.pdf binary
@@ -0,0 +1,9 @@
1
+ coverage/
2
+ .idea/
3
+ *.gem
4
+ .bundle/
5
+ .DS_Store
6
+ rdoc/
7
+ Gemfile.lock
8
+ .zoldata/
9
+ home/
data/.pdd ADDED
@@ -0,0 +1,7 @@
1
+ --source=.
2
+ --verbose
3
+ --exclude target/**/*
4
+ --exclude coverage/**/*
5
+ --rule min-words:20
6
+ --rule min-estimate:15
7
+ --rule max-estimate:90
@@ -0,0 +1,28 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.3.3
4
+
5
+ Style/EndOfLine:
6
+ EnforcedStyle: lf
7
+ Metrics/LineLength:
8
+ Max: 120
9
+ Metrics/AbcSize:
10
+ Max: 100
11
+ Metrics/MethodLength:
12
+ Max: 80
13
+ Metrics/BlockLength:
14
+ Max: 70
15
+ Metrics/ClassLength:
16
+ Max: 150
17
+ Metrics/ParameterLists:
18
+ Max: 10
19
+ Layout/AlignParameters:
20
+ Enabled: false
21
+ Layout/MultilineMethodCallIndentation:
22
+ Enabled: false
23
+ Layout/EmptyLineAfterGuardClause:
24
+ Enabled: false
25
+ Style/ClassAndModuleChildren:
26
+ Enabled: false
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 7
@@ -0,0 +1,26 @@
1
+ assets:
2
+ rubygems.yml: zerocracy/home#assets/rubygems.yml
3
+ install: |-
4
+ export GEM_HOME=~/.ruby
5
+ export GEM_PATH=$GEM_HOME:$GEM_PATH
6
+ release:
7
+ script: |-
8
+ bundle install
9
+ rake
10
+ rm -rf *.gem
11
+ sed -i "s/0\.0\.0/${tag}/g" zold-stress.gemspec
12
+ git add zold-stress.gemspec
13
+ git commit -m "Version set to ${tag}"
14
+ gem build zold-stress.gemspec
15
+ chmod 0600 ../rubygems.yml
16
+ gem push *.gem --config-file ../rubygems.yml
17
+ commanders:
18
+ - yegor256
19
+ architect:
20
+ - yegor256
21
+ merge:
22
+ commanders: []
23
+ script: |-
24
+ bundle install
25
+ rake
26
+ deploy: {}
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2018 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ if Gem.win_platform? then
24
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
25
+ SimpleCov::Formatter::HTMLFormatter
26
+ ]
27
+ SimpleCov.start do
28
+ add_filter "/test/"
29
+ add_filter "/features/"
30
+ end
31
+ else
32
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
33
+ [SimpleCov::Formatter::HTMLFormatter]
34
+ )
35
+ SimpleCov.start do
36
+ add_filter "/test/"
37
+ add_filter "/features/"
38
+ # minimum_coverage 30
39
+ end
40
+ end
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ - 2.3.3
5
+ cache: bundler
6
+ branches:
7
+ only:
8
+ - master
9
+ install:
10
+ - travis_retry bundle update
11
+ - gem install pdd
12
+ script:
13
+ - pdd -f /dev/null
14
+ - export RUBYOPT="-W0"
15
+ - rake --quiet
16
+ after_success:
17
+ - "bash <(curl -s https://codecov.io/bash)"
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ source 'https://rubygems.org'
24
+ gemspec
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2018 Yegor Bugayenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ <img src="http://www.zold.io/logo.svg" width="92px" height="92px"/>
2
+
3
+ [![Donate via Zerocracy](https://www.0crat.com/contrib-badge/CAZPZR9FS.svg)](https://www.0crat.com/contrib/CAZPZR9FS)
4
+
5
+ [![EO principles respected here](http://www.elegantobjects.org/badge.svg)](http://www.elegantobjects.org)
6
+ [![Managed by Zerocracy](https://www.0crat.com/badge/CAZPZR9FS.svg)](https://www.0crat.com/p/CAZPZR9FS)
7
+ [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/zold)](http://www.rultor.com/p/yegor256/zold)
8
+ [![We recommend RubyMine](http://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
9
+
10
+ [![Build Status](https://travis-ci.org/zold-io/zold-stress.svg)](https://travis-ci.org/zold-io/zold-stress)
11
+ [![PDD status](http://www.0pdd.com/svg?name=zold-io/zold-stress)](http://www.0pdd.com/p?name=zold-io/zold-stress)
12
+ [![Gem Version](https://badge.fury.io/rb/zold-stress.svg)](http://badge.fury.io/rb/zold-stress)
13
+ [![Test Coverage](https://img.shields.io/codecov/c/github/zold-io/zold-stress.svg)](https://codecov.io/github/zold-io/zold-stress?branch=master)
14
+
15
+ Here is the [White Paper](https://papers.zold.io/wp.pdf).
16
+
17
+ Join our [Telegram group](https://t.me/zold_io) to discuss it all live.
18
+
19
+ The license is [MIT](https://github.com/zold-io/zold-stress/blob/master/LICENSE.txt).
20
+
21
+ This is a command line testing toolkit.
22
+
23
+ # How to contribute
24
+
25
+ Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
26
+ Make sure you build is green before you contribute
27
+ your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
28
+ [Bundler](https://bundler.io/) installed. Then:
29
+
30
+ ```
31
+ $ bundle update
32
+ $ rake
33
+ ```
34
+
35
+ If it's clean and you don't see any error messages, submit your pull request.
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'rubygems'
24
+ require 'rake'
25
+ require 'rdoc'
26
+ require 'rake/clean'
27
+
28
+ def name
29
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
30
+ end
31
+
32
+ def version
33
+ Gem::Specification.load(Dir['*.gemspec'].first).version
34
+ end
35
+
36
+ task default: %i[clean test features rubocop copyright]
37
+
38
+ require 'rake/testtask'
39
+ desc 'Run all unit tests'
40
+ Rake::TestTask.new(:test) do |test|
41
+ ENV['TEST_QUIET_LOG'] = 'true' if ARGV.include?('--quiet')
42
+ Rake::Cleaner.cleanup_files(['coverage'])
43
+ test.libs << 'lib' << 'test'
44
+ test.pattern = 'test/**/test_*.rb'
45
+ test.verbose = true
46
+ test.warning = false
47
+ end
48
+
49
+ require 'rdoc/task'
50
+ desc 'Build RDoc documentation'
51
+ Rake::RDocTask.new do |rdoc|
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "#{name} #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
58
+ require 'rubocop/rake_task'
59
+ desc 'Run RuboCop on all directories'
60
+ RuboCop::RakeTask.new(:rubocop) do |task|
61
+ task.fail_on_error = true
62
+ task.requires << 'rubocop-rspec'
63
+ end
64
+
65
+ require 'cucumber/rake/task'
66
+ Cucumber::Rake::Task.new(:features) do |t|
67
+ t.cucumber_opts = 'features --format pretty'
68
+ Rake::Cleaner.cleanup_files(['coverage'])
69
+ end
70
+ Cucumber::Rake::Task.new(:'features:html') do |t|
71
+ t.profile = 'html_report'
72
+ end
73
+
74
+ task :copyright do
75
+ sh "grep -q -r '#{Date.today.strftime('%Y')}' \
76
+ --include '*.rb' \
77
+ --include '*.txt' \
78
+ --include 'Rakefile' \
79
+ ."
80
+ end
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2018 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ STDOUT.sync = true
25
+
26
+ start = Time.now
27
+
28
+ require 'slop'
29
+ require 'rainbow'
30
+ require 'zold/log'
31
+ require 'zold/age'
32
+ require 'zold/wallet'
33
+ require 'zold/wallets'
34
+ require 'zold/sync_wallets'
35
+ require 'zold/cached_wallets'
36
+ require 'zold/remotes'
37
+ require_relative '../lib/zold/stress/round'
38
+ require_relative '../lib/zold/stress/stats'
39
+ require_relative '../lib/zold/stress/air'
40
+
41
+ Thread.current.name = 'main'
42
+
43
+ Encoding.default_external = Encoding::UTF_8
44
+ Encoding.default_internal = Encoding::UTF_8
45
+
46
+ log = Zold::Log::Regular.new
47
+
48
+ begin
49
+ opts = Slop.parse(ARGV, strict: false, suppress_errors: true) do |o|
50
+ o.banner = "Usage: zold-stress [options]
51
+ Available options:"
52
+ o.integer '-r', '--rounds',
53
+ 'Total amount of paying rounds to complete (default: 16)',
54
+ default: 16
55
+ o.integer '-p', '--pool',
56
+ 'From how many wallets to send payments (default: 8)',
57
+ default: 8
58
+ o.integer '-t', '--threads',
59
+ "How many threads to use for each operation (default: #{Concurrent.processor_count * 8})",
60
+ default: Concurrent.processor_count * 8
61
+ o.integer '-b', '--batch',
62
+ 'How many transactions to send in each round (default: 64)',
63
+ default: 64
64
+ o.string '--private-key',
65
+ 'The location of RSA private key (default: ~/.ssh/id_rsa)',
66
+ require: true,
67
+ default: File.expand_path('~/.ssh/id_rsa')
68
+ o.string '--home',
69
+ "Home directory (default: #{Dir.pwd})",
70
+ default: Dir.pwd
71
+ o.string '--network',
72
+ "The name of the network we work in (default: #{Zold::Wallet::MAIN_NETWORK}",
73
+ required: true,
74
+ default: Zold::Wallet::MAIN_NETWORK
75
+ o.bool '-h', '--help', 'Show these instructions'
76
+ o.on '--no-colors', 'Disable colors in the ouput' do
77
+ Rainbow.enabled = false
78
+ end
79
+ end
80
+
81
+ log = Zold::Log::Sync.new(log)
82
+
83
+ if opts.help?
84
+ log.info(opts.to_s)
85
+ exit
86
+ end
87
+
88
+ home = File.expand_path(opts[:home])
89
+ FileUtils.mkdir_p(home)
90
+ Dir.chdir(home)
91
+
92
+ zoldata = File.join(home, '.zoldata')
93
+
94
+ wallets = Zold::SyncWallets.new(
95
+ Zold::CachedWallets.new(Zold::Wallets.new(home)),
96
+ log: log
97
+ )
98
+ remotes = Zold::Remotes.new(file: File.join(zoldata, 'remotes'), network: opts['network'])
99
+ remotes.defaults
100
+ copies = File.join(zoldata, 'copies')
101
+
102
+ stats = Zold::Stress::Stats.new
103
+ air = Zold::Stress::Air.new
104
+ round = Zold::Stress::Round.new(
105
+ pvt: Zold::Key.new(file: opts['private-key']),
106
+ wallets: wallets, remotes: remotes, copies: copies,
107
+ stats: stats, air: air, log: log, opts: opts
108
+ )
109
+ opts['rounds'].times do
110
+ round.update
111
+ round.prepare
112
+ round.send
113
+ round.pull
114
+ round.match
115
+ log.info(stats.to_console)
116
+ end
117
+ rescue StandardError => ex
118
+ log.error(Backtrace.new(ex))
119
+ exit(-1)
120
+ end
121
+
122
+ log.info("Successfully finished in #{Zold::Age.new(start)}")