-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
90 lines (65 loc) · 3.55 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Notes:
To run each individual test: `npx hardhat test test/Greeter.js`
```npx eslint '**.*.js'```: This command makes things look nice in the code.
Install the eslint package first ```npm i [email protected]```
The code formating and styling is depricated in the latest version of eslint, but we can still install it as plugin "https://eslint.style/packages/default". eslint suggests using preetier.
```npx eslint '**.*.js' --fix```: This line fixes the code on its own as much as possible.
Preetier:
preetier is the industry standard when it comes to code formating
install: ```npm install prettier --save -dev```
To use prettier with eslint
```npm install eslint-config-prettier --save-dev```
This will disable the formating rules in eslint that preetier is responsible for handling.
Also install prettier plugin:
```npm install eslint-plugin-prettier --save-dev```
It runs prettier as eslint rule and reports differences as individual eslint issue.
To run prettier on a file:
```npx pretiter test/Greeter.js```: Returns formatted file but does not change the original file.
```npx pretiter test/Greeter.js --check```: Checks if the file needs to be formatted.
```npx pretiter test/Greeter.js --write```: Changes and formats the original file.
prettier cannot be used with solidity, use solhint instead.
Combined Eslint and Prettier:
To combine the functionalities of the eslint and prettier combine the scripts in the package.json.
```
"scripts":{
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint --fix",
"lint:prettier": "prettier --write"
},
```
Solhint:
Used as a Solidity linter, Solhint detects a wide array of validation and security rules in compliance with Solidity's style guide.
Solhint comes with preconfigured sets of rules but allows the developer to change these rule sets, as well as manage configuration rules at the code level with specific comments.
New version of hardhat does not come with Solhint so install it manually and run command:
```npm install -g solhint``` or ```npm install solhint```
Initialize the solhint:
```(npx) solhint --init```
solhint docs: `https://eslint.org/docs/latest/use/getting-started`
Set the rules in config file link (https://protofire.github.io/solhint/)
Or,
install solidity-solhint extention, press F5, done.
Coverage:
To see how much code has been covered by tests run:
```npx hardhat coverage```
To view in html:
```coverage/lcov-report/index.html```
Slither:
Slither is a tool that helps you identify potential vulnerabilities in your smart contract
```pip3 install slither-analyzer```
Find potential issues and threats in contract
```slither .```
If some warnings are not threats, you can ignore them next time by running:
```slither . -triage```
Then type 'All' for all the warnings, and then type ignore for the ones you want to ignore.
Next time you run `slither .`, the same warnings will not show
Vertigo:
Vertigo is used for mutation testing, install Vertigo
```pip3 install --user eth-vertigo```
Install truffle:
```npm i truffle```
Run Tests:
```vertigo run --hardhat-parallel 8```
This will run the tests in parallel, and the number 8 is the number of workers.
You can change it to whatever number you want.
Output core test results to file
```vertigo run --hardhat-parallel 8 --output TEXT```