Skip to content

Commit a224639

Browse files
author
linguopeng
committed
test: Parallel 5 thread test
1 parent f6fd100 commit a224639

File tree

99 files changed

+9949
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+9949
-168
lines changed

auto_config.py

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
#/ 自动生成pom
2+
# 自动生成config
3+
4+
HardhatConfigData = '''require('@nomiclabs/hardhat-waffle');
5+
require('@nomiclabs/hardhat-web3');
6+
require('dotenv').config();
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
11+
// const INFURA_PROJECT_ID = '719d739434254b88ac95d53e2b6ac997';
12+
13+
const argv = require('yargs/yargs')()
14+
.env('')
15+
.options({{
16+
ci: {{
17+
type: 'boolean',
18+
default: false,
19+
}},
20+
coverage: {{
21+
type: 'boolean',
22+
default: false,
23+
}},
24+
gas: {{
25+
alias: 'enableGasReport',
26+
type: 'boolean',
27+
default: false,
28+
}},
29+
mode: {{
30+
alias: 'compileMode',
31+
type: 'string',
32+
choices: ['production', 'development'],
33+
default: 'development',
34+
}},
35+
compiler: {{
36+
alias: 'compileVersion',
37+
type: 'string',
38+
default: '0.8.9',
39+
}},
40+
coinmarketcap: {{
41+
alias: 'coinmarketcapApiKey',
42+
type: 'string',
43+
}},
44+
}})
45+
.argv;
46+
47+
require('@nomiclabs/hardhat-truffle5');
48+
49+
if (argv.enableGasReport) {{
50+
require('hardhat-gas-reporter');
51+
}}
52+
53+
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {{
54+
require(path.join(__dirname, 'hardhat', f));
55+
}}
56+
57+
const withOptimizations = argv.enableGasReport || argv.compileMode === 'production';
58+
59+
/**
60+
* @type import('hardhat/config').HardhatUserConfig
61+
*/
62+
module.exports = {{
63+
solidity: {{
64+
version: argv.compiler,
65+
settings: {{
66+
optimizer: {{
67+
enabled: withOptimizations,
68+
runs: 200,
69+
}},
70+
}},
71+
}},
72+
defaultNetwork: 'testRpc',
73+
networks: {{
74+
hardhat: {{
75+
loggingEnabled: true,
76+
blockGasLimit: 10000000,
77+
allowUnlimitedContractSize: !withOptimizations,
78+
}},
79+
testRpc: {{
80+
url: process.env.TEST_RPC,
81+
// gas:10000000,
82+
accounts: {{
83+
mnemonic: process.env.MNEMONIC_STR,
84+
path: 'm/44\\\'/60\\\'/0\\\'/0',
85+
initialIndex: {idx},
86+
count: 10,
87+
passphrase: '',
88+
}},
89+
}},
90+
}},
91+
mocha: {{
92+
timeout: 100000,
93+
reporter: 'mochawesome',
94+
reporterOptions: {{
95+
reportFilename: '[status]-{contractName}-report',
96+
}},
97+
}},
98+
99+
}};
100+
101+
if (argv.coverage) {{
102+
require('solidity-coverage');
103+
module.exports.networks.hardhat.initialBaseFeePerGas = 0;
104+
}}
105+
'''
106+
ContractList = [
107+
"AccessControl",
108+
"AccessControlEnum",
109+
"Ownable",
110+
"CrossChainEnabled",
111+
"PaymentSplitter",
112+
"VestingWallet",
113+
"GovernorCompatibilityBravo",
114+
"GovernorComp",
115+
"GovernorERC721Mock",
116+
"GovernorPreventLateQuorum",
117+
"GovernorTimelockCompound",
118+
"GovernorTimelockControl",
119+
"GovernorVotesQuorumFraction",
120+
"GovernorWithParams",
121+
"Governor",
122+
"TimelockController",
123+
"Votes",
124+
"ERC2771Context",
125+
"MinimalForwarder",
126+
"BeaconProxy",
127+
"UpgradeableBeacon",
128+
"Clones",
129+
"ERC1967Proxy",
130+
"ProxyAdmin",
131+
"TransparentUpgradeableProxy",
132+
"Initializable",
133+
"UUPSUpgradeable",
134+
"Pausable",
135+
"PullPayment",
136+
"ReentrancyGuard",
137+
"ERC1155",
138+
"ERC1155Burnable",
139+
"ERC1155Pausable",
140+
"ERC1155Supply",
141+
"ERC1155URIStorage",
142+
"ERC1155PresetMinterPauser",
143+
"ERC1155Holder",
144+
"ERC20Test",
145+
"ERC20Permit",
146+
"ERC20Burnable",
147+
"ERC20Capped",
148+
"ERC20FlashMint",
149+
"ERC20Pausable",
150+
"ERC20Snapshot",
151+
"ERC20Votes",
152+
"ERC20VotesComp",
153+
"ERC20Wrapper",
154+
"ERC20PresetFixedSupply",
155+
"ERC20PresetMinterPauser",
156+
"SafeERC20",
157+
"TokenTimelock",
158+
"ERC721",
159+
"ERC721Enumerable",
160+
"ERC721Burnable",
161+
"ERC721Pausable",
162+
"ERC721Royalty",
163+
"ERC721URIStorage",
164+
"ERC721Votes",
165+
"ERC721PresetMinterPauserAutoId",
166+
"ERC721Holder",
167+
"ERC777",
168+
"ERC777PresetFixedSupply",
169+
"Address",
170+
"Arrays",
171+
"Strings",
172+
"Checkpoints",
173+
"Context",
174+
"Counters",
175+
"Create2",
176+
"EIP712",
177+
"ECDSA",
178+
"MerkleProof",
179+
"SignatureChecker",
180+
"ConditionalEscrow",
181+
"Escrow",
182+
"RefundEscrow",
183+
"ERC165",
184+
"ERC165Checker",
185+
"ERC165Storage",
186+
"ERC1820Implementer",
187+
"Math",
188+
"SafeCast",
189+
"SafeMath",
190+
"SignedMath",
191+
"SignedSafeMath",
192+
"MulticallToken",
193+
"StorageSlot",
194+
"BitMap",
195+
"DoubleEndedQueue",
196+
"EnumerableMap",
197+
"EnumerableSet",
198+
"TimersBlockNumber",
199+
"TimersTimestamp"
200+
]
201+
def auto_hardhat_config(contractName,idx):
202+
fileName = "hardhat.config.{contractName}.js".format(contractName = contractName)
203+
with open(fileName,'w') as f:
204+
f.write(HardhatConfigData.format(contractName = contractName,idx = idx))
205+
206+
def auto_cmd(contractName):
207+
f'''
208+
{contractName} =>
209+
"test:{contractName}": "hardhat test --config ./hardhat.config.{contractName}.js --grep \"Contract: {contractName} \"",
210+
:param contractName:
211+
:return:
212+
'''
213+
return '''"test:{contractName}": "hardhat test --config ./hardhat.config.{contractName}.js --network testRpc --grep \\\"Contract: {contractName} \\\"",'''.format(
214+
contractName = contractName
215+
)
216+
217+
def main_config():
218+
for idx in range(0,len(ContractList)):
219+
data = ContractList[idx]
220+
print(idx,data,idx % 5 *10)
221+
auto_hardhat_config(data,idx % 5 *10)
222+
223+
def main_cmd():
224+
for contractName in ContractList:
225+
print(auto_cmd(contractName))
226+
227+
if __name__ == '__main__':
228+
main_cmd()

auto_test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
npm run test:init
2+
npm run test:run51
3+
npm run test:run52
4+
npm run test:run53
5+
npm run test:run54
6+
npm run test:run55
7+
npm run test:run56
8+
npm run test:run57
9+
npm run test:run58
10+
npm run test:run59
11+
npm run test:run511
12+
npm run test:run512
13+
npm run test:run513
14+
npm run test:run514
15+
npm run test:run515
16+
npm run test:run516
17+
npm run test:run517
18+
npm run test:run518
19+
20+

hardhat.config.AccessControl.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
require('@nomiclabs/hardhat-waffle');
2+
require('@nomiclabs/hardhat-web3');
3+
require('dotenv').config();
4+
5+
const fs = require('fs');
6+
const path = require('path');
7+
8+
// const INFURA_PROJECT_ID = '719d739434254b88ac95d53e2b6ac997';
9+
10+
const argv = require('yargs/yargs')()
11+
.env('')
12+
.options({
13+
ci: {
14+
type: 'boolean',
15+
default: false,
16+
},
17+
coverage: {
18+
type: 'boolean',
19+
default: false,
20+
},
21+
gas: {
22+
alias: 'enableGasReport',
23+
type: 'boolean',
24+
default: false,
25+
},
26+
mode: {
27+
alias: 'compileMode',
28+
type: 'string',
29+
choices: ['production', 'development'],
30+
default: 'development',
31+
},
32+
compiler: {
33+
alias: 'compileVersion',
34+
type: 'string',
35+
default: '0.8.9',
36+
},
37+
coinmarketcap: {
38+
alias: 'coinmarketcapApiKey',
39+
type: 'string',
40+
},
41+
})
42+
.argv;
43+
44+
require('@nomiclabs/hardhat-truffle5');
45+
46+
if (argv.enableGasReport) {
47+
require('hardhat-gas-reporter');
48+
}
49+
50+
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
51+
require(path.join(__dirname, 'hardhat', f));
52+
}
53+
54+
const withOptimizations = argv.enableGasReport || argv.compileMode === 'production';
55+
56+
/**
57+
* @type import('hardhat/config').HardhatUserConfig
58+
*/
59+
module.exports = {
60+
solidity: {
61+
version: argv.compiler,
62+
settings: {
63+
optimizer: {
64+
enabled: withOptimizations,
65+
runs: 200,
66+
},
67+
},
68+
},
69+
defaultNetwork: 'testRpc',
70+
networks: {
71+
hardhat: {
72+
loggingEnabled: true,
73+
blockGasLimit: 10000000,
74+
allowUnlimitedContractSize: !withOptimizations,
75+
},
76+
testRpc: {
77+
url: process.env.TEST_RPC,
78+
// gas:10000000,
79+
accounts: {
80+
mnemonic: process.env.MNEMONIC_STR,
81+
path: 'm/44\'/60\'/0\'/0',
82+
initialIndex: 0,
83+
count: 10,
84+
passphrase: '',
85+
},
86+
},
87+
},
88+
mocha: {
89+
timeout: 100000,
90+
reporter: 'mochawesome',
91+
reporterOptions: {
92+
reportFilename: '[status]-AccessControl-report',
93+
},
94+
},
95+
96+
};
97+
98+
if (argv.coverage) {
99+
require('solidity-coverage');
100+
module.exports.networks.hardhat.initialBaseFeePerGas = 0;
101+
}

0 commit comments

Comments
 (0)