erc20 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +14 -14
- data/Gemfile.lock +111 -101
- data/Rakefile +1 -0
- data/bin/erc20 +6 -3
- data/erc20.gemspec +9 -9
- data/hardhat/Dockerfile +1 -1
- data/hardhat/package.json +2 -3
- data/lib/erc20/erc20.rb +1 -1
- data/lib/erc20/fake_wallet.rb +1 -1
- data/lib/erc20/wallet.rb +3 -3
- metadata +28 -53
- data/.0pdd.yml +0 -5
- data/.gitattributes +0 -7
- data/.github/workflows/actionlint.yml +0 -25
- data/.github/workflows/codecov.yml +0 -27
- data/.github/workflows/copyrights.yml +0 -19
- data/.github/workflows/hadolint.yml +0 -16
- data/.github/workflows/markdown-lint.yml +0 -23
- data/.github/workflows/pdd.yml +0 -19
- data/.github/workflows/rake.yml +0 -38
- data/.github/workflows/reuse.yml +0 -19
- data/.github/workflows/shellcheck.yml +0 -19
- data/.github/workflows/typos.yml +0 -19
- data/.github/workflows/xcop.yml +0 -19
- data/.github/workflows/yamllint.yml +0 -21
- data/.gitignore +0 -10
- data/.gitleaksignore +0 -2
- data/.pdd +0 -7
- data/.rubocop.yml +0 -49
- data/.rultor.yml +0 -26
- data/.yamllint.yml +0 -12
- data/renovate.json +0 -6
- data/test/erc20/test_fake_wallet.rb +0 -118
- data/test/erc20/test_wallet.rb +0 -343
- data/test/erc20/test_wallet_live.rb +0 -126
- data/test/test__helper.rb +0 -206
data/test/test__helper.rb
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
4
|
-
# SPDX-License-Identifier: MIT
|
|
5
|
-
|
|
6
|
-
$stdout.sync = true
|
|
7
|
-
|
|
8
|
-
require 'simplecov'
|
|
9
|
-
require 'simplecov-cobertura'
|
|
10
|
-
unless SimpleCov.running
|
|
11
|
-
SimpleCov.command_name('test')
|
|
12
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
13
|
-
[
|
|
14
|
-
SimpleCov::Formatter::HTMLFormatter,
|
|
15
|
-
SimpleCov::Formatter::CoberturaFormatter
|
|
16
|
-
]
|
|
17
|
-
)
|
|
18
|
-
SimpleCov.minimum_coverage 90
|
|
19
|
-
SimpleCov.minimum_coverage_by_file 90
|
|
20
|
-
SimpleCov.start do
|
|
21
|
-
add_filter 'test/'
|
|
22
|
-
add_filter 'vendor/'
|
|
23
|
-
add_filter 'target/'
|
|
24
|
-
track_files 'lib/**/*.rb'
|
|
25
|
-
track_files '*.rb'
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
require 'minitest/autorun'
|
|
30
|
-
require 'minitest/reporters'
|
|
31
|
-
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
|
32
|
-
|
|
33
|
-
# To make tests retry on failure:
|
|
34
|
-
if ENV['RAKE']
|
|
35
|
-
require 'minitest/retry'
|
|
36
|
-
Minitest::Retry.use!
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Primitive array.
|
|
40
|
-
class Primitivo
|
|
41
|
-
def initialize(array)
|
|
42
|
-
@array = array
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def clear
|
|
46
|
-
@array.clear
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def to_a
|
|
50
|
-
@array.to_a
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def append(item)
|
|
54
|
-
@array.append(item)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
require 'webmock/minitest'
|
|
59
|
-
|
|
60
|
-
# Test.
|
|
61
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
62
|
-
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
|
63
|
-
# License:: MIT
|
|
64
|
-
class ERC20::Test < Minitest::Test
|
|
65
|
-
def fake_loog
|
|
66
|
-
ENV['RAKE'] ? Loog::ERRORS : Loog::VERBOSE
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def wait_for(seconds = 30)
|
|
70
|
-
start = Time.now
|
|
71
|
-
loop do
|
|
72
|
-
sleep(0.1)
|
|
73
|
-
break if yield
|
|
74
|
-
passed = Time.now - start
|
|
75
|
-
raise "Giving up after #{passed} seconds of waiting" if passed > seconds
|
|
76
|
-
rescue Errno::ECONNREFUSED
|
|
77
|
-
retry
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def wait_for_port(port)
|
|
82
|
-
wait_for { Typhoeus::Request.get("http://localhost:#{port}").code == 200 }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def env(var)
|
|
86
|
-
key = ENV.fetch(var, nil)
|
|
87
|
-
skip("The #{var} environment variable is not set") if key.nil?
|
|
88
|
-
skip("The #{var} environment variable is empty") if key.empty?
|
|
89
|
-
key
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def mainnet
|
|
93
|
-
[
|
|
94
|
-
{
|
|
95
|
-
host: 'mainnet.infura.io',
|
|
96
|
-
http_path: "/v3/#{env('INFURA_KEY')}",
|
|
97
|
-
ws_path: "/ws/v3/#{env('INFURA_KEY')}"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
host: 'go.getblock.io',
|
|
101
|
-
http_path: "/#{env('GETBLOCK_KEY')}",
|
|
102
|
-
ws_path: "/#{env('GETBLOCK_WS_KEY')}"
|
|
103
|
-
}
|
|
104
|
-
].map do |server|
|
|
105
|
-
ERC20::Wallet.new(
|
|
106
|
-
host: server[:host],
|
|
107
|
-
http_path: server[:http_path],
|
|
108
|
-
ws_path: server[:ws_path],
|
|
109
|
-
log: fake_loog
|
|
110
|
-
)
|
|
111
|
-
end.sample
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def testnet
|
|
115
|
-
[
|
|
116
|
-
{
|
|
117
|
-
host: 'sepolia.infura.io',
|
|
118
|
-
http_path: "/v3/#{env('INFURA_KEY')}",
|
|
119
|
-
ws_path: "/ws/v3/#{env('INFURA_KEY')}"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
host: 'go.getblock.io',
|
|
123
|
-
http_path: "/#{env('GETBLOCK_SEPOILA_KEY')}",
|
|
124
|
-
ws_path: "/#{env('GETBLOCK_SEPOILA_KEY')}"
|
|
125
|
-
}
|
|
126
|
-
].map do |server|
|
|
127
|
-
ERC20::Wallet.new(
|
|
128
|
-
host: server[:host],
|
|
129
|
-
http_path: server[:http_path],
|
|
130
|
-
ws_path: server[:ws_path],
|
|
131
|
-
log: fake_loog
|
|
132
|
-
)
|
|
133
|
-
end.sample
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def through_proxy(wallet, proxy)
|
|
137
|
-
ERC20::Wallet.new(
|
|
138
|
-
contract: wallet.contract, chain: wallet.chain,
|
|
139
|
-
host: donce_host, port: wallet.port, http_path: wallet.http_path, ws_path: wallet.ws_path,
|
|
140
|
-
ssl: wallet.ssl, proxy:, log: fake_loog
|
|
141
|
-
)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def via_proxy
|
|
145
|
-
RandomPort::Pool::SINGLETON.acquire do |port|
|
|
146
|
-
donce(
|
|
147
|
-
image: 'yegor256/squid-proxy:latest',
|
|
148
|
-
ports: { port => 3128 },
|
|
149
|
-
env: { 'USERNAME' => 'jeffrey', 'PASSWORD' => 'swordfish' },
|
|
150
|
-
root: true, log: fake_loog
|
|
151
|
-
) do
|
|
152
|
-
yield "http://jeffrey:swordfish@localhost:#{port}"
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def on_hardhat(port: nil, die: nil)
|
|
158
|
-
RandomPort::Pool::SINGLETON.acquire do |rnd|
|
|
159
|
-
port = rnd if port.nil?
|
|
160
|
-
if die
|
|
161
|
-
killer = [
|
|
162
|
-
'&',
|
|
163
|
-
'HARDHAT_PID=$!;',
|
|
164
|
-
'export HARDHAT_PID;',
|
|
165
|
-
'while true; do',
|
|
166
|
-
" if [ -e #{Shellwords.escape(File.join('/die', File.basename(die)))} ]; then",
|
|
167
|
-
' kill -9 "${HARDHAT_PID}";',
|
|
168
|
-
' break;',
|
|
169
|
-
' else',
|
|
170
|
-
' sleep 0.1;',
|
|
171
|
-
' fi;',
|
|
172
|
-
'done'
|
|
173
|
-
].join(' ')
|
|
174
|
-
end
|
|
175
|
-
cmd = "npx hardhat node #{killer if die}"
|
|
176
|
-
donce(
|
|
177
|
-
home: File.join(__dir__, '../hardhat'),
|
|
178
|
-
ports: { port => 8545 },
|
|
179
|
-
volumes: die ? { File.dirname(die) => '/die' } : {},
|
|
180
|
-
command: "/bin/bash -c #{Shellwords.escape(cmd)}",
|
|
181
|
-
log: fake_loog
|
|
182
|
-
) do
|
|
183
|
-
wait_for_port(port)
|
|
184
|
-
cmd = [
|
|
185
|
-
'(cat hardhat.config.js)',
|
|
186
|
-
'(ls -al)',
|
|
187
|
-
'(echo y | npx hardhat ignition deploy ./ignition/modules/Foo.ts --network foo --deployment-id foo)',
|
|
188
|
-
'(npx hardhat ignition status foo | tail -1 | cut -d" " -f3)'
|
|
189
|
-
].join(' && ')
|
|
190
|
-
contract = donce(
|
|
191
|
-
home: File.join(__dir__, '../hardhat'),
|
|
192
|
-
command: "/bin/bash -c #{Shellwords.escape(cmd)}",
|
|
193
|
-
build_args: { 'HOST' => donce_host, 'PORT' => port },
|
|
194
|
-
log: fake_loog,
|
|
195
|
-
root: true
|
|
196
|
-
).split("\n").last
|
|
197
|
-
wallet = ERC20::Wallet.new(
|
|
198
|
-
contract:, chain: 4242,
|
|
199
|
-
host: 'localhost', port:, http_path: '/', ws_path: '/', ssl: false,
|
|
200
|
-
log: fake_loog
|
|
201
|
-
)
|
|
202
|
-
yield wallet
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|